arp packet are always sending in 2 switch openflow network

211 views
Skip to first unread message

Jz bao

unread,
Jan 16, 2016, 7:59:46 AM1/16/16
to ns-3-users

Now i am trying to modify the openflow example file "openflow-switch.cc" and add a openflow switch as follows.  I use n1 to ping n2, but  i am suffering a problem that the host n1 are always send arp request, while the destination n2 has send back arp reply. Can some one help to solve this problem. thank you very much.


//        n0          n2

//        |           |

//       ----       ----

//        S1------S2

//       ----       ----

//        |           |

//        n1         n3


the code is as follows.


NS_LOG_INFO ("Create nodes.");

  NodeContainer terminal_s1;

  terminal_s1.Create (2);


  NodeContainer terminal_s2;

  terminal_s2.Create (2);


  NodeContainer csmaSwitch;

  csmaSwitch.Create (2);


  NS_LOG_INFO ("Build Topology");

  CsmaHelper csma;

  csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));

  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));


  PointToPointHelper p2p;

  p2p.SetDeviceAttribute ("DataRate", DataRateValue (5000000));

  p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));


  // Create the csma links

  NetDeviceContainer terminalDevice_s1;

  NetDeviceContainer terminalDevice_s2;

  NetDeviceContainer switchDevice_s1;

  NetDeviceContainer switchDevice_s2;

  for (int i = 0; i < 2; i++)

    {

      NetDeviceContainer link1 = csma.Install (NodeContainer (terminal_s1.Get (i), csmaSwitch.Get (0)));

      terminalDevice_s1.Add (link1.Get (0));

      switchDevice_s1.Add (link1.Get (1));

    }

  for (int i = 0; i < 2; i++)

    {

      NetDeviceContainer link2 = csma.Install (NodeContainer (terminal_s2.Get (i), csmaSwitch.Get (1)));

      terminalDevice_s2.Add (link2.Get (0));

      switchDevice_s2.Add (link2.Get (1));

    }


  NetDeviceContainer link3 = csma.Install (NodeContainer (csmaSwitch.Get (0), csmaSwitch.Get (1)));

  switchDevice_s1.Add (link3.Get (0));

  switchDevice_s2.Add (link3.Get (1));


  // Create the switch netdevice, which will do the packet switching

  Ptr<Node> switchNode1 = csmaSwitch.Get (0);

  Ptr<Node> switchNode2 = csmaSwitch.Get (1);

  OpenFlowSwitchHelper swtch;


  Ptr<ns3::ofi::LearningController> controller = CreateObject<ns3::ofi::LearningController> ();


  swtch.Install (switchNode1, switchDevice_s1, controller);

  swtch.Install (switchNode2, switchDevice_s2, controller);




Tommaso Pecorella

unread,
Jan 16, 2016, 8:56:28 AM1/16/16
to ns-3-users
Hi,

if you want to attach a script, please use an attachment (i.e., the "Attach a file" button) and add all the necessary stuff, like the OpenFlow switch configuration (if any).
About the specific issue, I can't run the script (I idon'thave OpenFlow) but I'd suggest to check if the ARP reply is arriving at the source node (the one who did made the ARP request).

T.


On Saturday, January 16, 2016 at 1:59:46 PM UTC+1, Jz bao wrote:

Now i am trying to modify the openflow example file "openflow-switch.cc" and add a openflow switch as follows.  I use n1 to ping n2, but  i am suffering a problem that the host n1 are always send arp request, while the destination n2 has send back arp reply. Can some one help to solve this problem. thank you very much.





Jz bao

unread,
Jan 17, 2016, 8:08:20 AM1/17/16
to ns-3-users
ok, i am sorry about that, and now i attach my files of the script and the results. From the openflow-switch-0-0.pcap, it can be found that the nod n0 has received the ARP reply, but it still sends the request repeatedly. Is there the problem of the arp protocol of the node?

Thank you very much for your patiently response.


在 2016年1月16日星期六 UTC+8下午9:56:28,Tommaso Pecorella写道:
openflow-2switch.cc
openflow-switch-0-0.pcap

Tommaso Pecorella

unread,
Jan 17, 2016, 10:47:38 AM1/17/16
to ns-3-users
Hi,

there's a problem for sure, but it's not in the ARP protocol.
The "problem" is that the switches keeps retransmitting the ARP request over and over. This can be seen in the log file:

+ 1.01119 /NodeList/0/DeviceList/0/$ns3::CsmaNetDevice/TxQueue/Enqueue ns3::EthernetHeader ( length/type=0x806, source=00:00:00:00:00:01, destination=ff:ff:ff:ff:ff:ff) ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:01 source ipv4: 10.1.1.1 dest ipv4: 10.1.1.2) Payload (size=18) ns3::EthernetTrailer (fcs=4275504459)

This is the only request sent by node 0.
There are a lot more of them, but they're made by Node 4 and 5 (the switches).
I suspect that the two of them aren't really happy to be two. Please try with just one switch and check if the ARP behavior is correct.
If everything is fine with one switch only, please open a bug on Bugzilla attaching the sample script and the wireshark traces.

Thanks,

T.

Jz bao

unread,
Jan 17, 2016, 10:09:16 PM1/17/16
to ns-3-users
Hi,it works well with only one switch. The problem is caused by the openflow switches, i will try to find the problem, but now i still have no idea how to debug them. 
Thank you very much for your response.

在 2016年1月17日星期日 UTC+8下午11:47:38,Tommaso Pecorella写道:

Jz bao

unread,
Jan 17, 2016, 10:36:22 PM1/17/16
to ns-3-users
I think the openflow has some problem. when Node 5 receives the ARP request from port2, it broadcast to all the ports including port2, so it causes the arp flooding.


在 2016年1月17日星期日 UTC+8下午11:47:38,Tommaso Pecorella写道:
Hi,
屏幕快照 2016-01-18 上午11.32.46.png
屏幕快照 2016-01-18 上午11.33.06.png
Message has been deleted

Jz bao

unread,
Jan 18, 2016, 8:09:42 AM1/18/16
to ns-3-users
Hi, 
I have found the problem is caused by the function OutputAll(), in which the in_port is in the format of htons(). For example, the in_port is 3, while after htons(), it will become 768. So the i wouldn't be equal to the in_port, and the packet will be broadcasted to all the ports. Actually it should be broadcasted to all the ports without the input port.

I revise the code by using ntohs(), the arp flooding problem will be solved. 

// openflow-switch-net-device.cc
//line 708
int prev_port = -1;
  for (size_t i = 0; i < m_ports.size (); i++)
    {
      if (i == (unsigned) ntohs(in_port)) // Originating port
        {
          continue;
        }
      if (flood && m_ports[i].config & OFPPC_NO_FLOOD) // Port configured to not allow flooding
        {
          continue;
        }
    ......

//////////////////////

However, another problem still exists.  The switches connected to the same Learning controller share the m_learnState. In order to work well, every openflow switches will connect to its own controller, shown as follows. But that's not the nature of SDN.

  Ptr<ns3::ofi::LearningController> controller1 = CreateObject<ns3::ofi::LearningController> ();
  Ptr<ns3::ofi::LearningController> controller2 = CreateObject<ns3::ofi::LearningController> ();

  swtch.Install (switchNode1, switchDevice_s1, controller1);
  swtch.Install (switchNode2, switchDevice_s2, controller2);


在 2016年1月17日星期日 UTC+8下午11:47:38,Tommaso Pecorella写道:
Hi,

Tommaso Pecorella

unread,
Jan 18, 2016, 1:55:21 PM1/18/16
to ns-3-users
Hi,

As you can see, I think that the problem root is elsewhere (in interface.cc), but the end result is the same. Most probably the input interface isn't really important beside in your case.

About the double switch / double controller, I think that the problem is even elsewhere.
The switches should have two different LearningController, it's the two LearningController(s) that should talk each other (or with an even higher object in the network hierarchy).

Cheers,

T.

Jz bao

unread,
Jan 18, 2016, 9:50:21 PM1/18/16
to ns-3-users
Hi, i am a newer to NS3 and not familiar with the whole code. So i haven't found the htons inconsistently problem. And in my case, i just met this problem. While i will take care of the htons inconsistence, but that's hard to a new starter.

Now, i want to add an m_learnstate Array in the LearningController, which maintains the states of every connected switches. Or as you have said, use a higher object.

在 2016年1月19日星期二 UTC+8上午2:55:21,Tommaso Pecorella写道:
Reply all
Reply to author
Forward
0 new messages