openflow based network

293 views
Skip to first unread message

Janki Chhatbar

unread,
Jan 29, 2015, 6:20:50 AM1/29/15
to ns-3-...@googlegroups.com
Hi all

I am trying to create a network with 1 openflow switch and 4 hosts. All hosts are in different subnets. The leftmost host must be able to ping the rightmost host. I have written a code but not able to figure out what to write at few places. I am attaching the code here with.

Kindly help me fill the gaps. I dont want to use DROPCONTROLLER.

Can I use OpenDayLight controller to communicate with the switch? If yes, how?
of-router.cc

Tommaso Pecorella

unread,
Jan 29, 2015, 6:44:24 AM1/29/15
to ns-3-...@googlegroups.com
Hi,

I think you should:
1) read the #§@*%% documentation. The OpenFlow documentation I mean.
2) Repeat point 1
3) Go back to point 1 and repeat.

Once you have done that, you'll find out that:
1) A switch is not a router
2) you can not have an external Controller, only an internal one. Hence, the answer is: no, you can't.

Good luck,

T.

Janki Chhatbar

unread,
Jan 29, 2015, 6:54:29 AM1/29/15
to ns-3-...@googlegroups.com
I have read the documentation. It says "A user versed in a standard OFSID, and/or OF protocol, can write virtual controllers to create switches of all kinds of types." My question is in which folder virtual controllers?

NetDeviceContainer ns3::OpenFlowSwitchHelper::Install ( Ptr< Node node,


NetDeviceContainer  c,


Ptr< ns3::ofi::Controller controller 

)
In my case, I am not able to understand what would be NetDeviceContainer c.

Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/4PEPXvZ32dI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Tommaso Pecorella

unread,
Jan 29, 2015, 10:48:32 AM1/29/15
to ns-3-...@googlegroups.com
Hi,

I'm sorry if I'm pedantic and repetitive. In the documentation it is written:

NetDeviceContainer ns3::OpenFlowSwitchHelper::Install (PtrNode > node, 
NetDeviceContainer c, 
Ptrns3::ofi::Controller > controller 
)

This method creates an ns3::OpenFlowSwitchNetDevice with the attributes configured by OpenFlowSwitchHelper::SetDeviceAttribute, adds the device to the node, attaches the given NetDevices as ports of the switch, and sets up a controller connection using the provided Controller. 

Parameters
nodeThe node to install the device in 
cContainer of NetDevices to add as switch ports 
controllerThe controller connection. 
Returns
A container holding the added net device.

What part of "Container of NetDevices to add as switch ports" is unclear ?

About the other question, in the folder src/openflow/model there are only four files. Two of them are the switch sources. In the other two you will find the implementation of the controllers. Study them.

T.

Janki Chhatbar

unread,
Jan 29, 2015, 11:43:06 PM1/29/15
to ns-3-...@googlegroups.com
Thanks a lot.

I wrote a code with 4 hosts connected to openflow switch. The leftmost host must ping the rightmost host. Also all hosts are in different subnets. The code builds successfully however there is no flow of data.

Can anyone help me in this? I am attaching the code.

Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

of-switch.cc

Tommaso Pecorella

unread,
Jan 30, 2015, 1:30:49 AM1/30/15
to ns-3-...@googlegroups.com
Hi,

what part of "switch" is unclear to you ?
I mean, it's a SWITCH. It can not route packets, because it's a switch. If it could, it would have been a router.

T.

Janki Chhatbar

unread,
Jan 30, 2015, 1:47:10 AM1/30/15
to ns-3-...@googlegroups.com
It is with reference to the code that I have written. The code creates an openflow switch connected to 4 hosts. All hosts are in different subnets. The code builds successfully but there are no packets flowing. The application is a ping where the leftmost host must be able to ping the rightmost host.

I am attaching the code. Can you look into it?

Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

of-switch.cc

Tommaso Pecorella

unread,
Jan 30, 2015, 1:54:20 AM1/30/15
to ns-3-...@googlegroups.com
Hi,

I have read your code and my eyes are bleeding, my soul is furious and my nervs are tingling.
Mind to understand what people write instead of just reading the words ?

You can NOT route packets through a switch. Not even an OpenFlow one. Point.
You have a network with FOUR subnets and NO ROUTER. It-will-not-work.
It will not work in ns-3 and it will not work in a real testbed, because IP does not work in this way, and switches don't work in this way.

Please study and understand a decent IP networking 101 class textbook, it seems that you are forgetting the IP basics.

T.

Janki Chhatbar

unread,
Jan 30, 2015, 4:15:50 AM1/30/15
to ns-3-...@googlegroups.com
Thanks a lot.. I appreciate that you are replying despite of your busy schedule. Ya sure I will revise the basics. 1 more doubt.

Suppose in NS3, I have a network with 4 hosts attached to a switch. All hosts are in same network. Then how will 1 host ping another?

V4PingHelper ping = V4PingHelper(ip.GetAddress(3));

This will get the IP address of the remote host to be pinged. Is there any helper, function, attribute in NS3 that will get the MAC address of remote host to be pinged? How can make this ping work in NS3?

Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

Tommaso Pecorella

unread,
Jan 30, 2015, 5:03:31 AM1/30/15
to ns-3-...@googlegroups.com
On Friday, January 30, 2015 at 10:15:50 AM UTC+1, Janki Chhatbar wrote:
Thanks a lot.. I appreciate that you are replying despite of your busy schedule. Ya sure I will revise the basics. 1 more doubt.

Suppose in NS3, I have a network with 4 hosts attached to a switch. All hosts are in same network. Then how will 1 host ping another?

Yes, they will. In the examples folder the Ping application is used sometimes.
 
V4PingHelper ping = V4PingHelper(ip.GetAddress(3));

This will get the IP address of the remote host to be pinged. Is there any helper, function, attribute in NS3 that will get the MAC address of remote host to be pinged? How can make this ping work in NS3?

Not really. The IP layer will find the remote host's MAC address through ARP. You can, of course, write some code to list the MAC and IP addresses associated in a node. However, the IP layer will take care of this.
If you're thinking to use this information in the switch controller, remember that this info is in the ARP requests and replies (and you could/should read from those), but that a switch should not rely on IP addresses analysis. Otherwise it's not a switch.

T.

Janki Chhatbar

unread,
Jan 30, 2015, 6:12:10 AM1/30/15
to ns-3-...@googlegroups.com
Sorry please bare with me. I am new to networking, NS3 and C++.

I have solved the issue with openflow switch. I want the same network but instead of openflow switch, the switch is traditional. How can I make switch forward the packet from host 1 to host 3. All hosts are in same network.

I surfed through the documentation and found this.

bool ns3::CsmaNetDevice::Send ( Ptr< Packet packet,


const Address dest,


uint16_t  protocolNumber 

)

l

Start sending a packet down the channel.

Parameters
packetpacket to send
destlayer 2 destination address
protocolNumberprotocol number
Returns
true if successfull, false otherwise (drop, ...)


so I added this portion in my code as

uint_16 protocol = 6; (for TCP)

NetDeviceContainer link;
NetDeviceContainer terminalDevices;
NetDeviceContainer switchDevices;

for (int i = 0; i < 4; i++)
{
        link = csma.Install (NodeContainer (hosts.Get (i), router));
        terminalDevices.Add (link.Get(0));
        switchDevices.Add (link.Get(1));
       
}
Mac48Address dest_address = Mac48Address::ConvertFrom (hosts.Get(3));

CsmaNetDevice csmanetdevice;
csmanetdevice::Send(ping, dest_address, protocol);


This is throwing an error of

.../scratch/normalrouter.cc:19:1: error: ‘uint_16’ does not name a type
 uint_16 protocol = 6;
 ^
../scratch/normalrouter.cc: In function ‘int main(int, char**)’:
../scratch/normalrouter.cc:68:69: error: no matching function for call to ‘ns3::Mac48Address::ConvertFrom(ns3::Ptr<ns3::Node>)’
  Mac48Address dest_address = Mac48Address::ConvertFrom (hosts.Get(3));
                                                                     ^
../scratch/normalrouter.cc:68:69: note: candidate is:
In file included from ./ns3/address-utils.h:28:0,
                 from ./ns3/network-module.h:10,
                 from ../scratch/normalrouter.cc:9:
./ns3/mac48-address.h:79:23: note: static ns3::Mac48Address ns3::Mac48Address::ConvertFrom(const ns3::Address&)
   static Mac48Address ConvertFrom (const Address &address);
                       ^
./ns3/mac48-address.h:79:23: note:   no known conversion for argument 1 from ‘ns3::Ptr<ns3::Node>’ to ‘const ns3::Address&’
../scratch/normalrouter.cc:72:2: error: ‘csmanetdevice’ is not a class or namespace
  csmanetdevice::Send(ping, dest_address, protocol);
  ^
../scratch/normalrouter.cc:72:22: error: ‘ping’ was not declared in this scope
  csmanetdevice::Send(ping, dest_address, protocol);
                      ^
../scratch/normalrouter.cc:72:42: error: ‘protocol’ was not declared in this scope
  csmanetdevice::Send(ping, dest_address, protocol);

Basically, I want a code that will ping 1 host to another host connected through a switch.


Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

Tommaso Pecorella

unread,
Jan 30, 2015, 8:40:09 AM1/30/15
to ns-3-...@googlegroups.com
Hi,

check this example: src/bridge/examples/csma-bridge.cc

Actually there is no model for a switch in ns-3 (as far as I know). The closest thing is the bridge, or the OpenFlow switch.

Beside that, the errors you posted are all quite self-explicative.
- uint_16 should be uint16_t
- hosts.Get(3) is a pointer to a node, not a MAC address
- C++ is case-sensitive...


Hope this helps,

T.

Janki Chhatbar

unread,
Feb 2, 2015, 4:07:36 AM2/2/15
to ns-3-...@googlegroups.com
Thanks a lot. I looked into the bridge example. I created the topology and ran the application. It is running fine. 

I want to compare the traditional network with SDN network. For that, I have 4 hosts connected to
1. OpenFlow switch
2. Bridge

I am comparing the pings for both cases.

Is this comparison fair? Or should it be switches in both case.

Also when I run Netanim for 10 secs, the packets are recorded only for 5 or 6 seconds. Why so? What is the remedy?

Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

Tommaso Pecorella

unread,
Feb 2, 2015, 4:12:14 AM2/2/15
to ns-3-...@googlegroups.com
Hi,

no, the comparison is extremely unfair. it's like comparing an Hub and a Switch, the Switch always wins.
However, mind that if you compare a "normal" Switch and the OpenFlow Switch... the normal one will win :)
OpenFlow isn't made to increase the performances, it's made to increase the flexibility.

About NetAnim, check of how long your apps are sending packets.

Cheers,

T.

Janki Chhatbar

unread,
Feb 2, 2015, 4:17:50 AM2/2/15
to ns-3-...@googlegroups.com
App start and stop time is 1 and 10 seconds respectively. Also the packets are shown to be exchanged but in the table, data is only till 5 seconds.

Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

Tommaso Pecorella

unread,
Feb 2, 2015, 4:53:15 AM2/2/15
to ns-3-...@googlegroups.com
Hi,

start a new thread and put John Abraham in copy.

Cheers,

T.

Janki Chhatbar

unread,
Feb 2, 2015, 4:54:53 AM2/2/15
to ns-3-...@googlegroups.com
Ya sure...And thanks a lot for hanging around with me so far.

Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106

sean hughes

unread,
Feb 9, 2016, 12:11:01 PM2/9/16
to ns-3-users
Hi Tommaso,

I've been looking through various forums and noticed your comment "

However, mind that if you compare a "normal" Switch and the OpenFlow Switch... the normal one will win :)
OpenFlow isn't made to increase the performances, it's made to increase the flexibility."

I'm currently undertaking a research project to show that OpenFlow reduces delay and jitter across a network when compared to a normal network. Could you explain what you mean by the statement above?

It would be greatly appreciated,
Sean


...

Tommaso Pecorella

unread,
Feb 9, 2016, 12:28:00 PM2/9/16
to ns-3-users
Hi,

let me explain the statement. First and foremost, I was talking about ONE switch alone, not about an homogeneous domain.
If you consider a single switch, the "normal" one will have its own built-in intelligence (or dumbness). We can discuss about how much it can be mad intelligent, but its processing time only depends on local hardware.
The OpenFlow one will need to:
1) classy a packet (according to some rules)
2) find a match in the rule table
3a) if a match is found, forward, or
3b) if a match is not found, ask the controller for an appropriate rule

Now, steps 1+2+3a shouldn't take longer than a "normal" switch, but not much less either. if there's an evident difference, then there's something wrong in the slowest one.
Indeed, even the non-openflow one does the same things... classify, find a match, forward.

Point 3b, however, is slow(er) because it involves sending the packet signature to the controller, potentially through another network, waiting some processing and receiving the rule.
Of course operation 3b is done once in a while, so there's not much penalty, and it's greatly balanced by the enhanced flexibility and the reduced cost of the switch.

However, this is a valid reasoning for ONE switch. If you have a mesh network of OpenFlow switches, then you should compare a different thing: OpenFlow best patch decisions with "traditional" switch path decisions. Basically it becomes a comparison about L2  routing, which is a totally different problem.

I hope that this clarifies my point.

Cheers,

T.
Reply all
Reply to author
Forward
0 new messages