Wifi Packet Forwarding not working

203 views
Skip to first unread message

vahid Saber

unread,
Jan 16, 2018, 2:06:56 AM1/16/18
to ns-3-users
Hi Everyone
(this is in relation to my previous post)

I have a very simple scenario of three nodes in a row. Last node sending udp packets to First node via Middle node.
Using: AdhocWifiMac, Ipv6 addressing, static routing.

I appreciate your help as I am stuck in this for a couple of days
.

Code:



#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include "ns3/ipv6-static-routing-helper.h"
#include "ns3/applications-module.h"


#include <iostream>
#include <fstream>
#include <vector>
#include <string>


using namespace ns3;


NS_LOG_COMPONENT_DEFINE
("wsa");


int main (int argc, char *argv[])
{
  std
::string phyMode ("DsssRate1Mbps");
 
bool verbose = false;


 
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
 
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
 
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
                     
StringValue (phyMode));


 
NodeContainer c;
  c
.Create (3);


 
WifiHelper wifi;
 
if (verbose)
 
{
      wifi
.EnableLogComponents ();
 
}
  wifi
.SetStandard (WIFI_PHY_STANDARD_80211b);


 
YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();
  wifiPhy
.Set ("RxGain", DoubleValue (0) );
  wifiPhy
.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);


 
YansWifiChannelHelper wifiChannel;
  wifiChannel
.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
  wifiChannel
.AddPropagationLoss ("ns3::RangePropagationLossModel", "MaxRange", DoubleValue (100));
  wifiPhy
.SetChannel (wifiChannel.Create ());


 
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
  wifi
.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                               
"DataMode",StringValue (phyMode),
                               
"ControlMode",StringValue (phyMode));
  wifiMac
.SetType ("ns3::AdhocWifiMac");
 
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);


 
MobilityHelper mobility;
 
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
 
  positionAlloc
->Add (Vector (0.0, 0.0, 0.0));
  positionAlloc
->Add (Vector (70.0, 0.0, 0.0));
  positionAlloc
->Add (Vector (140.0, 0.0, 0.0));
  mobility
.SetPositionAllocator (positionAlloc);
  mobility
.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobility
.Install (c);


 
InternetStackHelper internet;
  internet
.Install (c);


 
Ipv6AddressHelper ipv6;
  NS_LOG_UNCOND
("Assign IP Addresses.");
  ipv6
.SetBase (Ipv6Address("3ffe:6:6:1::"), 64);
 
Ipv6InterfaceContainer i = ipv6.Assign (devices);
  i
.SetForwarding (0, true);
  i
.SetDefaultRouteInAllNodes (0);
  NS_LOG_UNCOND
(i.GetAddress(0, 1));
  NS_LOG_UNCOND
(i.GetAddress(1, 1));
  NS_LOG_UNCOND
(i.GetAddress(2, 1));


 
//Static Routing
 
Ipv6StaticRoutingHelper ipv6RoutingHelper;
 
Ptr<Ipv6> ipv6c2 = c.Get (2)->GetObject<Ipv6> ();
 
Ptr<Ipv6StaticRouting> staticRoutingC2 = ipv6RoutingHelper.GetStaticRouting (ipv6c2);
  staticRoutingC2
->AddHostRouteTo (i.GetAddress(0, 1), i.GetAddress(1, 1), 1);
  NS_LOG_UNCOND
("AddHostRouteTo(" << i.GetAddress(0, 1) << ", " << i.GetAddress(1, 1) << ", 1)");


//  Ptr<Ipv6> ipv6c1 = c.Get (1)->GetObject<Ipv6> ();
//  Ptr<Ipv6StaticRouting> staticRoutingC1 = ipv6RoutingHelper.GetStaticRouting (ipv6c1);
//  staticRoutingC1->AddHostRouteTo (i.GetAddress(0, 1), 1);
//  NS_LOG_UNCOND("AddHostRouteTo(" << i.GetAddress(0, 1) << ", 1)");


 
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
 
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
 
// UDP Client Server Applications
  uint16_t port
= 6000;
 
ApplicationContainer serverApps, clientApps;
 
UdpServerHelper server (port);
  serverApps
= server.Install (c.Get(0));


 
//Clinet Application
  uint32_t packetSize
= 1024;
  uint32_t maxPacketCount
= 30;
 
Time interPacketInterval = MilliSeconds(1000);
 
UdpClientHelper udpClient(i.GetAddress(0,1), port);
  udpClient
.SetAttribute ("Interval", TimeValue (interPacketInterval));
  udpClient
.SetAttribute ("PacketSize", UintegerValue (packetSize));
  udpClient
.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
  clientApps
= udpClient.Install (c.Get (2));


  serverApps
.Start (Seconds (1.0));
  clientApps
.Start (Seconds (1.5));
  serverApps
.Stop (Seconds (10.0));
  clientApps
.Stop (Seconds (10.0));




  wifiPhy
.EnablePcap ("wifi-simple-adhoc", devices);


 
Simulator::Run ();
 
Simulator::Destroy ();


 
return 0;
}

Output: (In case of single hop, I do get TraceDelay RX for each TX, but in above multihop scenario, only TX):
Assign IP Addresses.
3ffe:6:6:1:200:ff:fe00:1
3ffe:6:6:1:200:ff:fe00:2
3ffe:6:6:1:200:ff:fe00:3
AddHostRouteTo(3ffe:6:6:1:200:ff:fe00:1, 3ffe:6:6:1:200:ff:fe00:2, 1)

TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 8 Time: 1.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 16 Time: 2.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 21 Time: 3.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 26 Time: 4.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 31 Time: 5.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 36 Time: 6.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 45 Time: 7.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 50 Time: 8.5
TraceDelay TX 1024 bytes to 3ffe:6:6:1:200:ff:fe00:1 Uid: 55 Time: 9.5


pdbarnes

unread,
Jan 17, 2018, 7:18:42 PM1/17/18
to ns-3-users

First, please attach (don't paste) longer code chunks, like your entire script.

I'm going to take a guess here that it's something to do with your routing setup.  Rather than locking down routing, have you tried enabling more routing?  Then pare back to your desired case.  Beyond that (not very helpful) suggestion, I think someone with better understanding of Wifi and routing will have to weigh in.

Peter

On Monday, January 15, 2018 at 11:06:56 PM UTC-8, vahid Saber wrote:
Hi Everyone
(this is in relation to my previous post)

I have a very simple scenario of three nodes in a row. Last node sending udp packets to First node via Middle node.
Using: AdhocWifiMac, Ipv6 addressing, static routing.
...
Output: (In case of single hop, I do get TraceDelay RX for each TX, but in above multihop scenario, only TX):
... 

Tommaso Pecorella

unread,
Jan 19, 2018, 3:54:08 PM1/19/18
to ns-3-users
Hi,

the short answer is: it won't work.

The long answer is: it won't work because Static Routing is meant to route packets between different networks.
In an AdHoc network all the nodes belong to the same subnet, and forwarding is handling on a per-node basis by an appropriate (Ad Hoc) routing protocol. These routing protocols are very different than Static Routing, RIP or OSPF.
In order to make your system work you'll need to use an IPv6-enabled version of OLSR, AODV, DSR, etc.
There have been in the past some proposed modifications for these, but none has been merged in ns-3 yet. However, you can find them in the past discussions in the group.

T.

vahid Saber

unread,
Jan 21, 2018, 5:36:47 AM1/21/18
to ns-3-...@googlegroups.com
Ah,
where were you Tommaso :)
It was helpful.
I will make a different approach and get back to you on this.
Thanks a bunch.

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

vahid Saber

unread,
Feb 20, 2018, 5:05:46 AM2/20/18
to ns-3-users
Hello Again,
Revisiting this thread,
Is ns3's mesh implementation (802.11s) a potential solution candidate?
Your comments helps a lot, as always.

Thanks
Vahid

Tommaso Pecorella

unread,
Feb 20, 2018, 10:15:57 PM2/20/18
to ns-3-users
Hi,

yes, mesh should work, but... see the other thread :\

Thanks,

T.

Mahesh

unread,
Apr 18, 2018, 5:20:01 PM4/18/18
to ns-3-users
Hi Vahid/Tommaso and other ns-3 experts,

I am running a simulation where I have a 5*5 grid of adhoc wifi nodes. Node 12 is the sink and all other nodes act as sources. I have setup static routes between sources and sink. Also, nodes 6, 8, 16, 18 are using 4 interfaces (on different channels) each and there are 6 flows each going through each of nodes 6, 8, 16, 18. For example, 0-->12, 1-->12, 2-->12, 5-->12, 6-->12, 10-->12 (6 flows) are statically routed through node 6.

The issue is only one of the interfaces is used in routing the packets. As a consequence, only 4 flows out of 24 are showing throughput. Rest all are close to 0 throughput.

0        1          2          3           4

5        6          7          8           9

10      11        12        13         14

15      16        17        18         19

20      21        22        23         24

Tommaso says that static routing won't work with a single subnet (which is what adhoc mode is).

But also, I came across your post here (https://groups.google.com/d/msg/ns-3-users/68wZgNtEYOY/U5aBEBaVAgAJ) where you have said that you got static routing to work on a single subnetwork.

Which is true? Also, what is the way out of this mess? Kindly help me. Looking forward to your kind reply at the earliest. The thing is I need to use static hand picked routes for routing in my adhoc network.

Thanks,
Mahesh

Mahesh

unread,
Apr 19, 2018, 2:04:40 PM4/19/18
to ns-3-...@googlegroups.com
Up

--
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/zYIDUX5gYQA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages