ns-3 Openflow swiches in wifi ad-hoc mode

466 views
Skip to first unread message

Farzaneh Pakzad

unread,
Oct 30, 2016, 7:34:36 PM10/30/16
to ns-3-users
Hi there,

I wanted to change the openflow-switch.cc in ns-3 to work in wifi ad-hoc mode, I applied the following changes in the file (to use wifi mode instead of csma)

      NS_LOG_INFO ("Create nodes.");
      NodeContainer terminals;
      terminals.Create (2);

      NodeContainer wifiSwitch;
      wifiSwitch.Create (1);

      NS_LOG_INFO ("Build Topology");
      WifiHelper wifi;
     wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
     NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
     YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
     YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

     wifiMac.SetType ("ns3::AdhocWifiMac");

      NS_LOG_DEBUG ("6");
      wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                                "DataMode", StringValue ("OfdmRate6Mbps"));


      YansWifiPhyHelper phy = wifiPhy;
      phy.SetChannel (wifiChannel.Create ());

     NqosWifiMacHelper mac = wifiMac;
     NetDeviceContainer terminalDevices = wifi.Install (phy, mac, terminals);

     NetDeviceContainer switchDevices = wifi.Install (phy, mac, wifiSwitch);


      // Create the switch netdevice, which will do the packet switching
      Ptr<Node> switchNode = wifiSwitch.Get (0);
      OpenFlowSwitchHelper swtch;

But when I run the code I got this error!!

Create nodes.
Build Topology
6
msg="Device does not support SendFrom: cannot be added to switch.", file=../src/openflow/model/openflow-switch-net-device.cc, line=168
terminate called without an active exception

I guess it means we can't add WiFi segment to the switch! Is there any advice of how to solve this problem? Or is there any other way to make an openflow switch works in WiFi ad-hoc mode?

Thanks in advance for your help.

Best regards,
Farzaneh

Tommaso Pecorella

unread,
Oct 30, 2016, 8:12:13 PM10/30/16
to ns-3-users, Sébastien Deronne
Hi,

interesting question, I'll put Sébastien in the loop.

By default Wi-Fi NetDevice doesn't support SendFrom. Well, it does, but it pretends it doesn't and it asks the MAC if it does.
The strange thing is:
- AP can use SendFrom
- AdHoc can't
- STA can't.

Is there any specific reason ?
One could try a "try and see if nothing breaks" approach, simply adding a SupportSendFrom function to AdhocWifiMac, but I'd rather use a more structured way

Cheers,

T.

Farzaneh Pakzad

unread,
Oct 30, 2016, 8:40:22 PM10/30/16
to ns-3-users, sebastie...@gmail.com

I want to apply SDN routing on wireless switches which work in ad-hoc mode.
Actually I want to install only one WiFi interface on each switch to communicate with other switches.  (which is possible in real hardware)


Best regards,
Farzaneh

Farzaneh Pakzad

unread,
Oct 31, 2016, 1:07:16 AM10/31/16
to ns-3-users, sebastie...@gmail.com
I also try your suggestion to add a SupportSendFrom function to AdhocWifiMac (however, I am not sure if I did it correctly or not),
but after that I got SIGSEGV. In the following is the result of debugging.


(gdb) RUN
Starting program: /home/farzaneh/ns-allinone-3.25/ns-3.25/build/scratch/openflow-switch-wifi
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000414757 in ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::Ref (this=0x31)
    at ./ns3/simple-ref-count.h:102
102        NS_ASSERT (m_count < std::numeric_limits<uint32_t>::max());
(gdb) where
#0  0x0000000000414757 in ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::Ref (
    this=0x31) at ./ns3/simple-ref-count.h:102
#1  0x0000000000413db1 in ns3::Ptr<ns3::Node>::Acquire (this=0x7fffffffdc40) at ./ns3/ptr.h:710
#2  0x0000000000412f0d in ns3::Ptr<ns3::Node>::Ptr (this=0x7fffffffdc40, o=...) at ./ns3/ptr.h:741
#3  0x00007fffefec7f35 in ns3::NodeContainer::Get (this=0x7fffffffde40, i=3)
    at ../src/network/helper/node-container.cc:90
#4  0x000000000041096a in main (argc=1, argv=0x7fffffffe458) at ../scratch/openflow-switch-wifi.cc:193

Would you please let me know if you have any idea to solve this issue?

Tommaso Pecorella

unread,
Oct 31, 2016, 9:22:46 AM10/31/16
to ns-3-users
Hi,

it could be an error just anywhere, without the code it's impossible to say (but I don't have OpenFlow, so I couldn't run your code).
Double check that you're trying to get a valid node index, the fact that the error is from NodeContainer::Get seems like an out-of-bounds array.

Cheers,

T.
Message has been deleted

Farzaneh Pakzad

unread,
Oct 31, 2016, 6:24:06 PM10/31/16
to ns-3-users

Hi,

Thanks a lot for your reply and support.
I have attached my code. If you could have a brief look.

I also add the following code (before "void AdhocWifiMac::SetLinkUpCallback (Callback<void> linkUp)") to adhoc-wifi-mac.cc

bool
AdhocWifiMac::SupportsSendFrom (void) const
{
  NS_LOG_FUNCTION (this);
  return true;
}


and adhoc-wifi-mac.h (after  " virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to);"):

  virtual bool SupportsSendFrom (void) const;


And here is the error:

(gdb) run

Starting program: /home/farzaneh/ns-allinone-3.25/ns-3.25/build/scratch/openflow-switch-wifi
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7998d85 in ns3::Object::GetObject<ns3::MobilityModel> (this=0x0)
    at ./ns3/object.h:459
459      T *result = dynamic_cast<T *> (m_aggregates->buffer[0]);
(gdb) where
#0  0x00007ffff7998d85 in ns3::Object::GetObject<ns3::MobilityModel> (this=0x0)
    at ./ns3/object.h:459
#1  0x00007ffff1d4c557 in ns3::YansWifiChannel::Send (this=0x727c80,
    sender=..., packet=..., txPowerDbm=17.020600000000002, txVector=...,
    preamble=ns3::WIFI_PREAMBLE_LONG, mpdutype=ns3::NORMAL_MPDU, duration=...)
    at ../src/wifi/model/yans-wifi-channel.cc:84
#2  0x00007ffff1d40550 in ns3::YansWifiPhy::SendPacket (this=0x72b9b0,
    packet=..., txVector=..., preamble=ns3::WIFI_PREAMBLE_LONG,
    mpdutype=ns3::NORMAL_MPDU) at ../src/wifi/model/yans-wifi-phy.cc:829
#3  0x00007ffff1d3fa3a in ns3::YansWifiPhy::SendPacket (this=0x72b9b0,
    packet=..., txVector=..., preamble=ns3::WIFI_PREAMBLE_LONG)
    at ../src/wifi/model/yans-wifi-phy.cc:776
#4  0x00007ffff1d61092 in ns3::MacLow::ForwardDown (this=0x729290, packet=...,
    hdr=0x729420, txVector=..., preamble=ns3::WIFI_PREAMBLE_LONG)
    at ../src/wifi/model/mac-low.cc:1653
#5  0x00007ffff1d66988 in ns3::MacLow::SendDataPacket (this=0x729290)
    at ../src/wifi/model/mac-low.cc:2069
#6  0x00007ffff1d57660 in ns3::MacLow::StartTransmission (this=0x729290,
    packet=..., hdr=0x729b20, params=..., listener=0x729b90)
    at ../src/wifi/model/mac-low.cc:818
#7  0x00007ffff1d90bdf in ns3::DcaTxop::NotifyAccessGranted (this=0x729aa0)
    at ../src/wifi/model/dca-txop.cc:460
#8  0x00007ffff1d95916 in ns3::DcaTxop::Dcf::DoNotifyAccessGranted (
---Type <return> to continue, or q <return> to quit---



Would you please let me know if I did it correctly or not?

Best regards,
Farzaneh
openflow-switch-wifi.cc

Tommaso Pecorella

unread,
Nov 1, 2016, 12:13:43 PM11/1/16
to ns-3-users
Hi,

that's not a problem of the changes you did. You can't use Wi-Fi on nodes that don't have a mobility model (because w/o one they don't know where they are and the propagation loss between them).
Just check one of the examples in the wireless folder.

Cheers,

T.

PS: as I said, I can't run OpenFlow, so I don't know if there are more bugs.

Farzaneh Pakzad

unread,
Nov 1, 2016, 6:43:44 PM11/1/16
to ns-3-users
Hi again,

Thank you very much; your support is greatly appreciated.

I know that I hassle you a lot. Now I added the mobility to the file and the errors has changed.

I appreciate if you could help.

(gdb) run
Starting program: /home/farzaneh/ns-allinone-3.25/ns-3.25/build/scratch/openflow-switch-wifi
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff1dfc421 in ns3::WifiNetDevice::GetAddress (this=0x731850)
    at ../src/wifi/model/wifi-net-device.cc:202
202      return m_mac->GetAddress ();
(gdb) where
#0  0x00007ffff1dfc421 in ns3::WifiNetDevice::GetAddress (this=0x731850)
    at ../src/wifi/model/wifi-net-device.cc:202
#1  0x00007ffff411f890 in ns3::OpenFlowSwitchNetDevice::FillPortDesc (
    this=0x7356b0, p=..., desc=0x732c70)
    at ../src/openflow/model/openflow-switch-net-device.cc:860
#2  0x00007ffff411fcb3 in ns3::OpenFlowSwitchNetDevice::SendPortStatus (
    this=0x7356b0, p=..., status=1 '\001')
    at ../src/openflow/model/openflow-switch-net-device.cc:931
#3  0x00007ffff4117f93 in ns3::OpenFlowSwitchNetDevice::DoDispose (
    this=0x7356b0) at ../src/openflow/model/openflow-switch-net-device.cc:130
#4  0x00007fffef6faf7f in ns3::Object::Dispose (this=0x7356b0)
    at ../src/core/model/object.cc:226
#5  0x00007fffefdf4ee7 in ns3::Node::DoDispose (this=0x729fd0)
    at ../src/network/model/node.cc:192
#6  0x00007fffef6faf7f in ns3::Object::Dispose (this=0x729fd0)
    at ../src/core/model/object.cc:226
#7  0x00007fffefe01573 in ns3::NodeListPriv::DoDispose (this=0x729a40)
    at ../src/network/model/node-list.cc:167
#8  0x00007fffef6fc82d in ns3::Object::DoDelete (this=0x729a40)
    at ../src/core/model/object.cc:404
#9  0x00000000004132c2 in ns3::ObjectDeleter::Delete (object=0x729a40)
    at ./ns3/object.h:450
#10 0x0000000000414c74 in ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::Unref (this=0x729a40) at ./ns3/simple-ref-count.h:116
#11 0x00007fffefe02dff in ns3::Ptr<ns3::NodeListPriv>::operator= (
    this=0x7ffff013adf8 <ns3::NodeListPriv::DoGet()::ptr>, o=...)
    at ./ns3/ptr.h:770
#12 0x00007fffefe00fbd in ns3::NodeListPriv::Delete ()
    at ../src/network/model/node-list.cc:147
#13 0x00007fffef6de2b8 in ns3::EventFunctionImpl0::Notify (this=0x729ad0)
    at ../src/core/model/make-event.cc:53
#14 0x00007fffef6d1801 in ns3::EventImpl::Invoke (this=0x729ad0)
    at ../src/core/model/event-impl.cc:51
#15 0x00007fffef6d5df2 in ns3::DefaultSimulatorImpl::Destroy (this=0x729cd0)
    at ../src/core/model/default-simulator-impl.cc:108
#16 0x00007fffef6d20ca in ns3::Simulator::Destroy ()
    at ../src/core/model/simulator.cc:180
#17 0x0000000000411d08 in main (argc=1, argv=0x7fffffffe458)
    at ../scratch/openflow-switch-wifi.cc:203



Tommaso Pecorella

unread,
Nov 1, 2016, 7:49:27 PM11/1/16
to ns-3-users
Hi,

not a big hassle, don't worry.

This error is a bit harder to spot, and without a working (or not working, in this case) code I can't do much.
However, the error is thrown during the simulation cleanup phase:
#16 0x00007fffef6d20ca in ns3::Simulator::Destroy ()

As a consequence, it's not affecting the normal simulation execution, and if the output files are all there... well, don't worry too much about it.

If the error is affecting the results, try changing this function:
Address
WifiNetDevice::GetAddress (void) const
{
 
return m_mac->GetAddress ();
}

to:
Address
WifiNetDevice::GetAddress (void) const
{
 
if (m_mac)
   
return m_mac->GetAddress ();
 
return Address ();
}

this should fix this particular error, but (again) I have no idea about why OpenFlowSwitchNetDevice::DoDispose is calling OpenFlowSwitchNetDevice::SendPortStatus, and how a "zero" address will affect it.
If you're using the "new" OpenFlow module you should poke the developer to ask him about it.


Cheers,

T.

Farzaneh Pakzad

unread,
Nov 2, 2016, 1:28:01 AM11/2/16
to ns-3-users
Thanks a lot for your help.

Yes, it solves the problem. and now it seems running without errors.

After that I wanted to check the throughput by adding  flowmon, but the program starts to run and then freezing (in the   flowmon->SerializeToXmlFile ("throughput.xml", true, true); line, I guess) without any error!!! (I have to do ctlr+c to exit the program)

here is the last part of it:

Sending packet to controller
^CInterrupted
far@Far-System:~/ns-allinone-3.25/ns-3.25$

Would you please let me know if you have any idea?

here is the code for flowmon:

  Ptr<FlowMonitor> flowmon;
  FlowMonitorHelper flowmonHelper;
  flowmon = flowmonHelper.InstallAll ();


  // Now, do the actual simulation.
  //
  NS_LOG_INFO ("Run Simulation.");
  Simulator::Run ();

  flowmon->SerializeToXmlFile ("throughput.xml", true, true);

  Simulator::Destroy ();


Best regards,
Farzaneh

Mahdi Faghih Imani

unread,
Nov 2, 2016, 3:51:20 AM11/2/16
to ns-3-users
Hi,

As far as I know, and I searched the ns-3 group, it isn't possible to simulate wifi openflow switches for wireless SDN routing in ns-3 yet.
Is it right or my misunderstanding? can you help me?

Thanks.

Tommaso Pecorella

unread,
Nov 2, 2016, 5:16:20 AM11/2/16
to ns-3-users
Hi,

no clue all.

If it freezes without an error, then you found an infinite loop (i.e., a bug). The only thing to do is to use a debugger to spot the problem (and to let us know the results).

Cheers,

T.

Farzaneh Pakzad

unread,
Nov 2, 2016, 5:47:18 PM11/2/16
to ns-3-...@googlegroups.com
Hi,

I think it's possible, but takes time to do it in a structural way. One could start with Mininet+ns-3 integration (https://github.com/mininet/mininet/wiki/Link-modeling-using-ns-3) to get some ideas about how to make WiFi SDN network, however it has its own limitations but worth to investigate.

In my case I want to make an ad-hoc network with WiFi switches in ns-3, that it seems  there is no work around it. But you could have a SDN wireless network with multiple APs which I think should work. (But I haven't tried it )

Best regards,
Farzaneh

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
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/xx_w7oq3YSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
F.P

Farzaneh Pakzad

unread,
Nov 2, 2016, 7:24:24 PM11/2/16
to ns-3-users
Hi,

Thanks for your reply. I tried to use with debugger, but the debugger also freezing.

As I searched in this group this problem has been asked on 2012, and 2014 but there was no solution around it.

I also tried to put the flowmon only on terminals but I couldn't make it work.

here is the result:

Starting program: /home/farzaneh/ns-allinone-3.25/ns-3.25/build/scratch/openflow-switch-wifi
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, main (argc=1, argv=0x7fffffffe458)
    at ../scratch/openflow-switch-wifi.cc:207
207      FlowMonitorHelper flowmonHelper;
(gdb) c
Continuing.

Breakpoint 2, main (argc=1, argv=0x7fffffffe458)
    at ../scratch/openflow-switch-wifi.cc:210
210      flowmon = flowmonHelper.Install(terminals.Get (0));
(gdb) c
Continuing.

Breakpoint 3, main (argc=1, argv=0x7fffffffe458)
    at ../scratch/openflow-switch-wifi.cc:215
215      Simulator::Run ();
(gdb) c
Continuing.



Would you please let me know if you have any suggestion?

Best regards,
Farzaneh

Mahdi Faghih Imani

unread,
Nov 3, 2016, 2:54:49 AM11/3/16
to ns-3-...@googlegroups.com
Thanks a lot.

M.Imani

You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.

Tommaso Pecorella

unread,
Nov 5, 2016, 7:13:02 AM11/5/16
to ns-3-users
Hi,

well, the trick to spot where a script enters an infinite loop is exactly to ... randomly stop it.

You can use two systems: one is rather brutal (but it works), the other is more scientific.

Scientific method: use a profiler and profile your code. Let it run for about half an hour, then stop it. Read the profiler results and the loop is in one in the functions where the script was in for most time.
Brutal method: use a debugger and debug your code. Let it run for about half an hour, then interrupt it (it's called break, see http://web.mit.edu/gnu/doc/html/gdb_7.html). Most probably you ended up in some parts of the endless loop.

From there on, you must examine what's going on.

Good luck,

T.
Reply all
Reply to author
Forward
0 new messages