Thanks Murphy. That's what I followed. My message sizes will be very less than 64 KB. So it won't be an issue. I am writing server component in as you described earlier but in that for communicating with C++ client, can I use send/receive function provided by library *messenger.py* in my server component?. If yes, then how can I use receive function of it? Is there any example of it. Can you give me some proper example for send/receive function usage?
From: Murphy McCauley [mailto:jam...@nau.edu] Sent: Tuesday, January 10, 2012 5:57 PM To: Harshil Anil Kumar Shah Cc: nox-dev@noxrepo.org dev Subject: Re: [nox-dev] Nox messenger example for external c++ and nox python The messenger is a suitable mechanism for implementing what you're talking about as long as none of your protobuf messages are over about 64kB (you could still use it even if they are, but it will be a bit more work). But no, you can't use *messenger.py* for this purpose. Quoting myself from earlier: messenger.py is a library for writing messenger *clients*. nox-send-cmd.py is an example of a messenger client written using the messenger.py library. In your case, your client is your external C++ program. But you still need to write the actual *server* portion as a component in NOX that utilizes the messenger component as I described on December 21. An alternate approach is to simply forget about messenger and use Twisted or dbus or something to write the communication part in NOX. -- Murphy On Jan 10, 2012, at 4:06 AM, Harshil Anil Kumar Shah wrote: Hi Murphy, Thanks for clarification. Exactly what I want to do is: I want to parse packet_in and port_status event received from openflow switches, extract the header information like dpid, portid etc. generate protobuf message which includes all these information. And send it to my external C++ module (for which I think plain messenger would do). Also any commands (Add_Flow, Remove_Flow) from C++ module will be received as protobuf message at my component and it should extract the information followed by sending add/remove flow commands to switches. But do I have to generate events even for simple client/server application? Because I want to use send/receive function provided in messenger.py. Can't it be used as used in scripts/nox-send-cmd.py? because I want to receive protobuf message from C++ to my component. Thanks From: Murphy McCauley [mailto:jam...@nau.edu] Sent: Tuesday, January 10, 2012 2:33 PM To: Harshil Anil Kumar Shah Cc: nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> dev Subject: Re: [nox-dev] Nox messenger example for external c++ and nox python Messenger has a message size limit of about 64kB and uses a simple framing format. If you are okay with that, then yes, you can use messenger to build a simple client/server application. I described how to do this in my reply on December 21. Let me know if you run into any problems. -- Murphy On Jan 10, 2012, at 12:56 AM, Harshil Anil Kumar Shah wrote: Hi Murphy, Actually, I am not using json messenger. I am using plain messenger only. And I just want to create simple socket client/server application. Python application using messenger as Server and C++ application as client. Is it possible? From: Murphy McCauley [mailto:jam...@nau.edu] Sent: Tuesday, January 10, 2012 1:31 PM To: Harshil Anil Kumar Shah Cc: nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> dev Subject: Re: [nox-dev] Nox messenger example for external c++ and nox python Actually, no. The version I posted has Python support for the plain messenger too, not just the JSON messenger. But it sounds like you're satisfied with using the JSON messenger. See the channel.receive() method in nox/coreapps/messenger/messenger.py. But really this is just simple socket IO. Hope that helps. -- Murphy On Jan 9, 2012, at 11:00 PM, Harshil Anil Kumar Shah wrote: Hi Murphy, Thanks for the reply. I am using the Zaku beta version. I guess it is the same library that you sent. But one question I have is, I got some working example of send() function from nox-send-cmd.py but for recv() function, I can't find example. How can I use recv() functionof messenger.py?? Thanks, Harshil From: Murphy McCauley [mailto:jam...@nau.edu] Sent: Wednesday, December 21, 2011 4:47 PM To: Harshil Anil Kumar Shah Cc: Kyriakos Zarifis; nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> Subject: Re: [nox-dev] Nox messenger example for external c++ and nox python No, the plain messenger is not exposed to Python. Kyriakos and I did enough of the JSON messenger to get monitoring working, but never did the normal messenger. The messenger.py should really be named messenger_client.py, and maybe shouldn't even be in that directory -- it's a library for writing messenger clients, and not a NOX component. I've taken a quick stab at exposing the plain messenger to Python. You can grab my current messenger directory from: http://www.noxathome.org/x/Murphy/messenger/messenger.zip Using it is very much like using jsonmessenger (as monitoring does). Something like: 1) In your component's install function: from nox.coreapps.messenger.pymsgevent import Msg_event self.register_handler(Msg_event.static_get_name(), myHandler) 2) Implement a handler: def myHandler (e): print e.type, e.body 3) Include pymessenger on the commandline or as a dependency Messages for messenger are prefixed with a three byte header: 2 Byte Network Order Unsigned Integer: Message length (including header) 1 Byte: Message type (can be anything, but I think 0-9 are reserved -- see messenger.hh) Hope that's useful. -- Murphy On Dec 21, 2011, at 2:46 AM, Harshil Anil Kumar Shah wrote: Thanks Murphy. I guess 2nd option is the better to go with. Can I use boost.python for that? And I guess plain messenger is exposed to python. There are messenger.py and messenger.cpp/hh files corresponding to plain messenger. -Harshil From: Murphy McCauley [mailto:jam...@nau.edu] Sent: Wednesday, December 21, 2011 2:33 PM To: Harshil Anil Kumar Shah Cc: Kyriakos Zarifis; nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> Subject: Re: [nox-dev] Nox messenger example for external c++ and nox python So NOX's messenger is a fairly generic method for communicating with external applications over a socket. Built on top of this is jsonmessenger which communicates JSON messages over a socket. If you specifically want to use protobufs (and not JSON messages), then you'd want to use the plain messenger. However, the plain messenger is not exposed to Python -- only jsonmessenger is. So I think your options are: 1) Use JSON messages instead of protobufs, and just use jsonmessenger 2) Expose messenger to Python, and then use this to send/receive protobufs 3) Use protobufs and roll your own method for communicating with your external application (probably using Twisted) -- Murphy On Dec 20, 2011, at 11:02 PM, Harshil Anil Kumar Shah wrote: Hi Murphy. Yes, I have external C++ module which I want to communicate with Nox python module using protobuf. I am using libjson library at C++ module. -Harshil. From: Murphy McCauley [mailto:jam...@nau.edu] Sent: Wednesday, December 21, 2011 1:38 AM To: Harshil Anil Kumar Shah Cc: Kyriakos Zarifis; nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> Subject: Re: [nox-dev] Nox messenger example for external c++ and nox python Do you mean that you have some external program (written in C++) that you want to communicate with a NOX component (written in Python)? jsonmessenger works by sending and receiving JSON (http://json.org) messages. So on the NOX side, you use jsonmessenger. In the external program, you can use any of several libraries for doing JSON encoding/decoding. -- Murphy On Dec 20, 2011, at 1:09 AM, Harshil Anil Kumar Shah wrote: Hi, In my case where external module is C++ then can I use "pyobject" to interact with python module? From: Harshil Anil Kumar Shah Sent: Monday, December 19, 2011 3:32 PM To: 'Kyriakos Zarifis' Cc: nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> Subject: RE: [nox-dev] Nox messenger example for external c++ and nox python Thanks Zarifis... I looked at GUI example. It seems very useful. But in my case, client is external C++ module. So in that case do I have to use use messenger.cpp?? -Harshil. From: nox-dev-boun...@noxrepo.org<mailto:nox-dev-boun...@noxrepo.org> [mailto:nox-dev-boun...@noxrepo.org] On Behalf Of Kyriakos Zarifis Sent: Monday, December 19, 2011 1:38 PM To: Harshil Anil Kumar Shah Cc: nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> Subject: Re: [nox-dev] Nox messenger example for external c++ and nox python Hi Harshil, it might not be the simplest example, but the GUI communicates with NOX using the messenger, so taking a look at that code might be a good starting point. Specifically, the file communication.py is responsible on the GUI side. Similarly on the NOX side, the code that uses the messenger to send messages to the GUI is inside the respective component that talks to the GUI. The component "monitoring" is one of them. Some of this is documented on the wiki here: http://noxrepo.org/noxwiki/index.php/NOX_GUI#Connecting_a_subview_to_a_NOX_component On Sun, Dec 18, 2011 at 10:41 PM, Harshil Anil Kumar Shah <harshil_s...@infosys.com<mailto:harshil_s...@infosys.com>> wrote: Hi, I want to exchange messages between external C++ module and python module in Nox using protobuf messages. I browsed through couple of posts, I figured out I can use coreapps/messenger. Can I get some working example how messenger code can be used for message exchange between external c++ and nox python module. Regards, Harshil Shah, Convergence Lab, Infosys Labs Infosys | Bangalore Mob # : +91 97428 87966<tel:%2B91%2097428%2087966>. **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS*** _______________________________________________ nox-dev mailing list nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> http://noxrepo.org/mailman/listinfo/nox-dev _______________________________________________ nox-dev mailing list nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> http://noxrepo.org/mailman/listinfo/nox-dev
_______________________________________________ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev