Error while doing UDP data transfer on WiFi

307 views
Skip to first unread message

Chinmay Naugaria

unread,
May 31, 2015, 7:43:09 AM5/31/15
to ns-3-...@googlegroups.com
Hello all,

I have a scenario with 2 APs, a server node and a client. Server node and APs are connected with p2p links and APs and clien ( only interface ) are installed using wifi helpers. I have put AP1 and client on one subnet and AP2 on other one and I am expecting data transfer to happen via AP1. But my script throws the following error:

aborted. cond="!(networkHere == networkThere)", msg="GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion", file=../src/internet/model/global-router-interface.cc, line=844
terminate called without an active exception


Here is my script. Can someone help me in locating the mistake?


#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include "ns3/netanim-module.h"

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/netanim-module.h"
#include "ns3/csma-helper.h"
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/internet-stack-helper.h"
#include "ns3/nqos-wifi-mac-helper.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-address-helper.h"
#include "ns3/udp-echo-helper.h"
#include "ns3/ssid.h"
#include "ns3/rectangle.h"
#include "ns3/ipv4-address-helper.h"
#include "ns3/ipv4-flow-classifier.h"
#include "ns3/gnuplot.h"
#include "ns3/mobility-helper.h"
#include "ns3/gnuplot.h"
#include "ns3/flow-monitor.h"
#include "ns3/flow-monitor-helper.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "ns3/csma-module.h"
#include "ns3/olsr-helper.h"
#include "ns3/internet-module.h"


using namespace ns3;
using namespace std;

NS_LOG_COMPONENT_DEFINE
("simulationipv4");
 
int
main
(int argc, char *argv[])
{
  std
::string phyMode ("ErpOfdmRate54Mbps");
  std
::string delay="0.1ms";
  std
::string datarate="1Gbps";

 
Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));

 
CommandLine cmd;
  cmd
.Parse (argc, argv);


  NS_LOG_INFO
("Create 4 nodes.");
 
NodeContainer c;
  c
.Create (4);
 
NodeContainer n0n1 = NodeContainer (c.Get (0), c.Get (1));
 
NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
 
NodeContainer n1n3 = NodeContainer (c.Get (1), c.Get (3));
 
NodeContainer n2n3 = NodeContainer (c.Get (2), c.Get (3));
 
NodeContainer stationary= NodeContainer(c.Get(0),c.Get(1),c.Get(2),c.Get(3));
 
NodeContainer stations = NodeContainer(c.Get(3));
 
NodeContainer accesspoints = NodeContainer(c.Get(1),c.Get(2));

  NS_LOG_INFO
("Create channels.");
 
PointToPointHelper p2p;
  p2p
.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
  p2p
.SetChannelAttribute ("Delay", StringValue ("2ms"));
 
NetDeviceContainer d0d1 = p2p.Install (n0n1);
 
NetDeviceContainer d0d2 = p2p.Install (n0n2);
 
NetDeviceContainer MobileDevice1;
 
NetDeviceContainer MobileDevice2;
 
NetDeviceContainer AP1;
 
NetDeviceContainer AP2;
 
NetDeviceContainer dummy;
 
NetDeviceContainer wifiStationDevices;
 
NetDeviceContainer wifiApDevices;

 
WifiHelper wifi1;
     
  wifi1
.SetStandard (WIFI_PHY_STANDARD_80211g);
 
YansWifiPhyHelper phy1 =  YansWifiPhyHelper::Default ();
  phy1
.Set ("RxGain", DoubleValue (0) );
  phy1
.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
   
 
YansWifiChannelHelper channel1;
  channel1
.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
  channel1
.AddPropagationLoss ("ns3::FriisPropagationLossModel");
  phy1
.SetChannel (channel1.Create ());
  phy1
.Set ("ChannelNumber", UintegerValue (1) );  
 
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
  wifi1
.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                                   
"DataMode",StringValue (phyMode),
                                   
"ControlMode",StringValue (phyMode));
     
 
Ssid ssid = Ssid ("ns-3-ssid");
  mac
.SetType ("ns3::StaWifiMac","Ssid", SsidValue (ssid),"ActiveProbing", BooleanValue (false));

  wifiStationDevices
= wifi1.Install(phy1, mac, stations);

  mac
.SetType ("ns3::ApWifiMac","Ssid", SsidValue (ssid),"BeaconGeneration", BooleanValue (true),"BeaconInterval", TimeValue     (Seconds (2.5)));

  wifiApDevices
= wifi1.Install(phy1,mac,accesspoints); //Add the mobile devices

   
MobilityHelper  mobility;
   
Ptr<ListPositionAllocator> positionAlloc1 = CreateObject<ListPositionAllocator> ();
    positionAlloc1
->Add (Vector (50.0, 0.0, 0.0));
    positionAlloc1
->Add (Vector (0.0, 10.0, 0.0));
    positionAlloc1
->Add (Vector (130.0,10.0, 0.0));
    positionAlloc1
->Add (Vector (50.0, 30.0, 0.0));

    mobility
.SetPositionAllocator (positionAlloc1);
    mobility
.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
    mobility
.Install (stationary);

   
InternetStackHelper stack;
    stack
.Install(c);    


  NS_LOG_INFO
("Assign IP Addresses.");
 
Ipv4AddressHelper ipv4;
  ipv4
.SetBase ("10.1.1.0", "255.255.255.0");
 
Ipv4InterfaceContainer i0i1 = ipv4.Assign (d0d1);

  ipv4
.SetBase ("10.1.2.0", "255.255.255.0");
 
Ipv4InterfaceContainer i0i2 = ipv4.Assign (d0d2);

  ipv4
.SetBase ("10.1.3.0", "255.255.255.0");
 
Ipv4InterfaceContainer i1 = ipv4.Assign (wifiApDevices.Get(0));
 
Ipv4InterfaceContainer i3 = ipv4.Assign (wifiStationDevices);

  ipv4
.SetBase ("10.1.4.0", "255.255.255.0");
 
Ipv4InterfaceContainer i2 = ipv4.Assign (wifiApDevices.Get(1));


 
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();


  NS_LOG_INFO
("Create Applications.");
  uint16_t port
= 9;   // Discard port (RFC 863)
 
OnOffHelper onoff ("ns3::UdpSocketFactory",
                     
InetSocketAddress (i3.GetAddress (0), port));
  onoff
.SetConstantRate (DataRate ("2kbps"));
  onoff
.SetAttribute ("PacketSize", UintegerValue (100));

 
ApplicationContainer apps = onoff.Install (c.Get (0));
  apps
.Start (Seconds (20.0));
  apps
.Stop (Seconds (25.0));

 
PacketSinkHelper sink ("ns3::UdpSocketFactory",
                         
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
 
ApplicationContainer apps11,apps22;
  apps11
= sink.Install (c.Get (3));
  apps11
.Start (Seconds (1.0));
  apps11
.Stop (Seconds (200.0));

  p2p
.EnablePcapAll ("simulationipv4");

  phy1
.EnablePcapAll ("simulationipv4");


  NS_LOG_INFO
("Run Simulation.");
 
AnimationInterface anim ("simulationipv4.xml");
 
Simulator::Stop (Seconds(200.0));


 
Simulator::Run ();
 
   
    uint32_t totalPacketsThrough
= DynamicCast<PacketSink>(apps11.Get(0))->GetTotalRx ();
    std
::cout <<"Total received on client = "<< totalPacketsThrough<<endl;


 
Simulator::Destroy ();
  NS_LOG_INFO
("Done.");
}


Tommaso Pecorella

unread,
May 31, 2015, 7:57:51 AM5/31/15
to ns-3-...@googlegroups.com
GlobalRouting doesn't work on WiFi networks. See its manual page:
"Presently, global centralized IPv4 unicast routing over both point-to-point and shared (CSMA) links is supported."
meaning: other link types are not supported.

Use OLSR, AODV or DSR on the WiFi section.

T.
...

Chinmay Naugaria

unread,
May 31, 2015, 8:50:52 AM5/31/15
to ns-3-...@googlegroups.com
Hi Tommaso,

Thanks for replying. I was confused with this over last couple of days.
I double checked but OLSR isn't responding to change in IP address ( and association ) dynamically although you said that it responds to loss of connectivity (Probably it is mentioned in the routing manual because it doesn't take care of loss of connectivity due to IP address change)

Is there some way I can make it make it possible, I mean making the OLSR respond to dynamic changes in IP address?

I just want the data transfer to happen after changing association from 1 AP to other.

Tommaso Pecorella

unread,
May 31, 2015, 8:59:57 AM5/31/15
to ns-3-...@googlegroups.com
Hi,

you have to study and be precise.
In your previous thread you was talking about handover between AP. Having the connectivity kept is another thing. What you are trying to do is a sort of MIP, do you know ? And like MIP, it's not easy.
I already replied about OLSR: it will need time to rebuild the routes. AODV too will need some time, but it's worse, as it's not meant to be used in multi-subnet scenario.
My suggestion is: stop coding and do some design. Find out what you need to do and how to do it, then simulate it. Right now you're trying to cook a Stroganoff's fillet without using a recipe. Definitely a bad idea.

T.

Chinmay Naugaria

unread,
May 31, 2015, 1:09:28 PM5/31/15
to ns-3-...@googlegroups.com
Hi Tommaso,

Your last reference just cracked me up.

I am sorry, here is what I want to accomplish :

There a some APs and clients ( User-defined ) installed on same wifi channel. The APs are connected to a common server node.  The clients associate to the AP giving them the highest RSSI ( I am not sure, if this is possible yet. Is it possible? ) or in such a way that load is equal in all the APs (As in number of clients associated to an AP are equal). If there are more clients with one AP, a random cliet de-associates and associates to another AP. (Perhaps, adding a separate field in beacon which tells about number clients associated)

The UDP data transfer should happen after new associations and de-associations.

So, I have been working on one client and 2 AP (the simplest possible ) to get the data transfer to work after changing association.

When you say OLSR needs some time to rebuild routes, you mean the data transfer should work after sufficient time right?

I started the new connection after sufficient time after changing association but I still can't get the data transfer happening. Will it possible to add a function to olsr code to make it recompute the routes?










--
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/xUlH_oikZAc/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.



--
Chinmay Naugaria
Final Year
Dual Degree
Electrical Engineering
IIT Madras
"It is the hottest fire, that forges the hardest steel"

Tommaso Pecorella

unread,
May 31, 2015, 5:12:48 PM5/31/15
to ns-3-...@googlegroups.com
Hi,

as you mentioned in the other thread, you are using a "virtual" IP address assigned to the node as the destination address (i.e., one of a CSMA device with nothing attached).
This means that your "MIP-like" system is relying on normal routing to propagate the new network path. It will require time to be aware of the route error and re-establish a path. that's why MIP and NEMO have been created, because relying on normal routing would have been too slow and too heavy for the network.
Anyway, the problem you're trying to tackle (or, at least, the way you are trying to use) is the same as having a backup link and a main link, and the main link breaks. GlobalRouting WOULD work with CSMA, but not with WiFi. OLSR and AODV can work with WiFi, but they're multi hop routing protocols, and they're not built to work with multiple subnets.
I'd say to try Nix (no idea if it can work with WiFi), or OLSR HNA feature.
Again, I have really no idea about how to make it work, simply because it's a case not foreseen by any routing protocols in ns-3. Probably RIP would work, but (again) I can't be sure.
Now, please try to be creative a bit. I can't solve your scenario, also because... will you add me as co-author in all your publications on this topic ?

Cheers,

T.

Chinmay Naugaria

unread,
Jun 3, 2015, 3:53:30 PM6/3/15
to ns-3-...@googlegroups.com
Hi Tommaso,

Haha, I wish I was publishing soon ( You would have definitely given me a very low Erdos Number - or the equivalent in field of CS/Networks ) This is just part of my masters project and somebody else will continue my work.

Thanks for helping out all the time with such detailed explanations.

I had removed the dummy address long back and there is only one interface on client now.
I did manage to get it working with static routing ( I saw the olsr routes and the newly added address was not reachable via the paths in routing tables and so i added a static path )

I have a couple of questions:
1. I am trying the add something in NotifyAddAddress() in Olsr protocol ( something similar to what nix does - it flushes the routing tables ) so that olsr takes care of this. I don't see any function calling this NotifyAddAddress and this only has definition in Ipv4RoutingProtocol which says routing protocols should implements this. So from where exactly is this function called?

2. Is it possible to know RSS from different APs for a client during the simulartion?



Tommaso Pecorella

unread,
Jun 4, 2015, 8:24:59 AM6/4/15
to ns-3-...@googlegroups.com
Hi,

good luck with the master project.

About the NotifyAddAddress, it is called in Ipv4L3Protocol::AddAddress. Quite not easy to find.

The RSS of different APs can be found, but you'd need to receive the beacons of both. For the AP you're connected to, any packet can be used to measure the RSSI. For the other AP only the beacons could be used. Assuming that they are using the same channel number. Otherwise you'd need to do a channel scanning (potentially loosing packets from the AP you're associated with).

Hope this helps,

T.
Reply all
Reply to author
Forward
0 new messages