Openflow: Redirect TCP Flow only for Controller - pox

i'm new in openflow, i create with mininet a open flow toplogy with 1 controller (POX), one switch, and 3 hosts.
My question is, how can i create one rule in switch to redirect to controller only tcp flow?
*sorry for my poor english

You can use the dpctl command in mininet (ovs-dpctl in host) to configure flows rules and actions for flows matching the flow rules

There are two ways that you can filter the tcp packets.
Using payload attribute of the packet object which coordinating with pox.lib.packet library.
Using find() method to find the packets that the type is tcp.
And you can find more information in POX wiki:
POX Wiki
Hope this helpful!

You could modify the already provided app l2_learning switch to make it fulfill your needs.
To check if one packet has tcp information:
tcp_pkt=packet.find('tcp')
if tcp_pkt is not None:
#do something

Related

Get subdomain from TCP socket

I am writing a server application that accepts TCP connections from different programs/protocols but I need to pass additional information to my server. I was thinking of passing this information through the subdomain being used. In other words, when connecting to my server, using an address such as somedata.example.com where somedata will be the extra information I need and my DNS will point *.example.com to my server. Would it be possible to fetch the domain/subdomain that the client used to connect to my server?
Code samples are welcome and in Go would be even better.
Thank you.
A TCP connection is conceptually just a stream of bytes in each direction. There is no single way that a hostname with subdomain would be communicated. Most protocols have their own way of communicating that if they need it. Examples:
An http request has a HOST header.
When initiating a tls connection, the handshake usually includes the desired host name.
If you are using some standard protocol, you should use their built-in metadata facilities.
If you are building your own custom binary protocol (I wouldn't if I could avoid it), you may consider adding some header info in some format. Perhaps a standardized header of length|desired-service-name|other-data would be sufficient. If the client sends something like that at the start of a new connection, the server can read it, and dispatch the connection appropriately.

Configuration of JPOS QMUX

I am new in JPOS. I need some help. Please find below my requirement.
In TCP connection terms, the IST Switch is configured to be a Server and the MPOS server is configured to be a Client. MPOS server and IST Switch should communicate via a single TCP connection. Also there should be provision to have multiple TCP connections between MPOS server and IST Switch for scalability, load-sharing and handling fail-over. Once established a TCP connection is maintained continuously.
I have gone through jpos developer guide and get to know QMUX can be used for my requirement. Request to you kindly help me on this.
I couldn't understand your question exactly but QMUX has nothing to do with load-balancing or with fail-over. QMUX get bind with only one Channel Adaptor
Let me tell you what QMUX does so we can clear the understanding of when QMUX would be usefull. For example you have a channel connected to a server and server supports concurrent requests(i.e. second request on the same tcp link while client is waiting for response of the first request). Now here comes a problem to relate requests-response pairs (because its quite possible that second response arrives even before the response of first request) this is what exactly QMUX does. mux part actually stands for multiplexer.
For laod-balancing or fail-over you can use org.jpos.q2.iso.MUXPool class following is a sample q2 xml descriptor
<?xml version="1.0" encoding="UTF-8"?>
<muxpool name="MuxPool" class="org.jpos.q2.iso.MUXPool" logger="Q2">
<muxes>MuxPrimary MuxSecondary</muxes>
<strategy>PRIMARY_SECONDARY</strategy>
</muxpool>
MuxPool provides two strategies primary-secondary or round-robin depends whether you are looking for fail-over or load-balancing.
If you think that I understood your question correctly and I am pointing you toward right direction let me know I may be able to share you one sample application using QMux and Muxpool on coming weekend.
Please take a look at chapter 8.3 of the jPOS Programmer's guide draft conveniently titled "QMUX" you can download here: http://jpos.org/doc/proguide-draft.pdf - You'll need also the companion service "ChannelAdaptor" described in section 8.1

Why we using sip protocol with voip?

What is the purpose for using sip with VOIP ? is it just to know the remote ip address ?
If i know (by server) the remote IP address ,then established a direct TCP socket connection for call negotiation, and send the media over RTP protocol ,so am i still need sip protocol ? or how can sip help me here?
The Session Initiation Protocol does rather a lot more than find out a remote IP address/port/transport triple.
It lets two parties
negotiate the media streams (including codecs and transports) and
establish commonly understood extensions to the protocol.
It also describes how to build scalable infrastructure (proxies, using SRV and NAPTR records, back to back user agents), location services and a host of other details that go into making a voice (or any other kind of) call to arbitrary third parties.
then you have implemented a sip alternative. sip (session instanciation protocol) does just control the "phone call". if you want to do that on your own, why not? the only problem would be that there are many sip clients and just one (or few) clients using your protocol.
SIP allocates a IP:port to a voip call. The RTP flows (one for each direction) will then use this IP:port as a destination address. If you have only one static RTP flow to send to your server, it may be useful and ok to do what you said.
Otherwise, if there are many clients, or if your system has to change a lot, it's better to use a polished protocol which will dynamically allocate ports and establish your sessions.
nobody forces you to implement a standard.
e.g. why do you implement the media stream in RTP? most likely because you already have code that "talks" RTP (e.g. a library, or a raedymade application).
the nice thing about standards is, that it will work "out-of-the-box" with all other applications implementing the same standard.
if it is an open standard, there's another nice thing: other people have already spent a lot of brain power into getting the implementation right. you don't need to fall into the same problems.

IP Spoofing at the IP level

I'm just reading about TCP and UDP and from what I've read when the packet gets encapsulated in the IP protocol and the header gets added is it not possible to create a false IP address at this stage?
Granted, the response will never be received on your connection, but is this possible?
I do not want to do this btw. I'm in no way associated with immoral ethics. It's just something that I had to ask whilst reading about TCP and UDP. I'm actually learning how to use sockets in C++ for a game I'm working on.
Yes, this is possible.
Use raw sockets and craft your own packets
Use scapy, hping, etc
Search for "packet crafting"
EDIT
A nice scapy tutorial that teaches you to send lots of valid and invalid stuff is here.

Ways to listen a UDP port with mozilla firefox

In a nutshell, I am trying to write a C++ XPCOM component which listens on a UDP port and calls a callback function (a javascript function) every time a UDP packet arrives.
Sorry if the answer is too obvious but I was wondering what are the ways to listen on a UDP port with Mozilla (Preferably something easy to do)?
I know that there is an interface called nsIServerSocket which allows some listeners to be attached to it, but this is only for opening TCP ports. Is there any UDP equivalent of this (where I can attach a listener which is notified every time a UDP packet arrives)?
I also know that I could probably use PR_OpenUDPSocket and such. Is there a way of using this without dealing with threads? (As far as I understand I have to return to the calling javascript function after opening the port).
Thanks.
Why do you need to restrict yourself to Mozilla's API if you are writing C++ code? You can use the POSIX socket API directly, see How to set up a Winsock UDP socket? for a WinSock example (the only difference for Linux and OS X should be that WSAStartup() call is unnecessary). nsIServerSocket is mainly useful for JavaScript code that doesn't have the option to use the system libraries directly.
If you prefer a straight answer to your question: no, there is no XPCOM API to create UDP sockets. You already found the NSPR API (PR_OpenUDPSocket()) but it is probably designed with DNS communication in mind since that's pretty much the only UDP communication a browser would do. Don't expect much here.
And a side-note: you might want to avoid binary XPCOM components and create a native library that can be called via js-ctypes instead. See here for the details.