intermediate hop's IP Address in IPv4 Global Routing

335 views
Skip to first unread message

Krishna Garg

unread,
Nov 24, 2015, 4:04:48 AM11/24/15
to ns-3-users
 Hi

I have been working to come up with few changes in IPv4 Global Routing Protocol. I am stuck up at a place where I need previous (intermediate) router's address more specifically at RouteInput()/ LookUpGlobal() functions i.e. when the packet is received. Though MAC address of previous router is available but RARP is not implemented in NS-3. Is there any way out of this situation?

If I specify the problem in more general way, it would be: I want to carefully avoid sending the packet back to node from where it was received and thus avoid looping. [Actually my (modified) routing table contains multiple ways to reach destination]

Tommaso Pecorella

unread,
Nov 24, 2015, 5:19:33 PM11/24/15
to ns-3-users
Hi,

Sorry to correct you, but what you need is ARP, not RARP. And ARP is implemented in ns-3...
If you have a MAC address and you want to know what IP address is associated with it, simply ask the ArpCache. What you could need to do is to add a reverse lookup function, as is a function to lookup the IP from the MAC address. However, it's still the ARP cache, not the RARP one.

Hope this helps,

T.

Krishna Garg

unread,
Nov 26, 2015, 6:19:00 AM11/26/15
to ns-3-users
Hi

When I query the ArpCache, I don't know the reason why I am getting no entry printed in ArpCache. Infact by debugging I found the ArpCahe itself is null. My simulation time is till 10 seconds.
Following snippet I am using to print from main file.
 
Ipv4GlobalRoutingHelper helper;
Ptr<OutputStreamWrapper> stream = Create<OutputStreamWrapper> ("ArpCacheEntries", std::ios::out);
helper
.PrintNeighborCacheAllEvery (Seconds (1), stream);


The file contains just:
ARP Cache of node 0 at time 1
ARP Cache of node 1 at time 1
ARP Cache of node 2 at time 1
and so on for every interval of 1 second.

Can you please guide where am I going wrong?

Tommaso Pecorella

unread,
Nov 26, 2015, 9:05:08 AM11/26/15
to ns-3-users
The ARP caches seems to be missing, and this is only possible if you have found a bug or if there is no communication between the nodes. Are you sure that the nodes are talking to each other ? ARP cache is built dynamically: no data exchanged, no cache entry.
Where are you wrong... no idea. Without the script it's impossible to say.

T.

Krishna Garg

unread,
Nov 28, 2015, 10:58:07 AM11/28/15
to ns-3-users
Hello Sir

This is a simple code for ECMP protocol for the given topology. In NS-3 simulation everything is working fine(I have attached .cc file for the same). But ARP caches seem to be empty. It would be of great help if you can figure out the fault.

Note that I have added the patch for flow ECMP but it should work without it also with ecmpMode variable = 0.
/*              1
           n6-----n4  
          2|      |  1
           |  4   |
 n0-------n1------n2-------n3
     5      \   /      2
           2 \ / 2
              n5
*/

int main (int argc, char *argv[])
{
  uint32_t ecmpMode
= 0;
 
CommandLine cmd;
  cmd
.AddValue ("EcmpMode", "Ecmp Mode: (0 none, 1 random, 2 flow)", ecmpMode);
  cmd
.Parse (argc, argv);
 
switch (ecmpMode)
   
{
     
case 0:
       
break;  //no ECMP
     
case 1:
       
Config::SetDefault ("ns3::Ipv4GlobalRouting::RandomEcmpRouting", BooleanValue (true));
       
break;
     
case 2:
        Config::SetDefault ("ns3::Ipv4GlobalRouting::FlowEcmpRouting", BooleanValue (true));
        break;  
     
default:
        NS_FATAL_ERROR
("Illegal command value for EcmpMode: " << ecmpMode);
       
break;
   
}
  NS_LOG_INFO
("Create nodes.");
 
int n = 7;
 
NodeContainer c;
  c
.Create (n);
 
NodeContainer n0n1 = NodeContainer (c.Get (0), c.Get (1));
 
NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
 
NodeContainer n2n3 = NodeContainer (c.Get (2), c.Get (3));                
 
NodeContainer n2n4 = NodeContainer (c.Get (2), c.Get (4));
 
NodeContainer n1n6 = NodeContainer (c.Get (1), c.Get (6));
 
NodeContainer n4n6 = NodeContainer (c.Get (4), c.Get (6));
 
NodeContainer n1n5 = NodeContainer (c.Get (1), c.Get (5));
 
NodeContainer n2n5 = NodeContainer (c.Get (2), c.Get (5));
 
InternetStackHelper internet;
  internet
.Install (c);
  NS_LOG_INFO
("Create channels.");
 
PointToPointHelper p2p;
  p2p
.SetDeviceAttribute ("DataRate", StringValue ("500kbps"));
  p2p
.SetChannelAttribute ("Delay", StringValue ("1ms"));
 
NetDeviceContainer d0d1 = p2p.Install (n0n1);
 
NetDeviceContainer d1d2 = p2p.Install (n1n2);
 
NetDeviceContainer d2d3 = p2p.Install (n2n3);  
 
NetDeviceContainer d1d6 = p2p.Install (n1n6);
 
NetDeviceContainer d4d6 = p2p.Install (n4n6);
 
NetDeviceContainer d2d4 = p2p.Install (n2n4);
 
NetDeviceContainer d1d5 = p2p.Install (n1n5);
 
NetDeviceContainer d2d5 = p2p.Install (n2n5);
 
 
Ipv4AddressHelper ipv4;
  ipv4
.SetBase ("10.0.1.0", "255.255.255.0");
 
Ipv4InterfaceContainer i01 = ipv4.Assign (d0d1);
  i01
.SetMetric(0,5);
  i01
.SetMetric(1,5);
  ipv4
.SetBase ("10.2.3.0", "255.255.255.0");
 
Ipv4InterfaceContainer i23 = ipv4.Assign (d2d3);
  i23
.SetMetric(0,2);
  i23
.SetMetric(1,2);
  ipv4
.SetBase ("10.1.2.0", "255.255.255.0");  
 
Ipv4InterfaceContainer i12 = ipv4.Assign (d1d2);
  i12
.SetMetric(0,4);      
  i12
.SetMetric(1,4);
  ipv4
.SetBase ("10.2.4.0", "255.255.255.0");
 
Ipv4InterfaceContainer i24 = ipv4.Assign (d2d4);
  i24
.SetMetric(0,1);
  i24
.SetMetric(1,1);
  ipv4
.SetBase ("10.1.6.0", "255.255.255.0");
 
Ipv4InterfaceContainer i16 = ipv4.Assign (d1d6);
  i16
.SetMetric(0,2);
  i16
.SetMetric(1,2);
  ipv4
.SetBase ("10.4.6.0", "255.255.255.0");
 
Ipv4InterfaceContainer i46 = ipv4.Assign (d4d6);
  i46
.SetMetric(0,1);
  i46
.SetMetric(1,1);
  ipv4
.SetBase ("10.1.5.0", "255.255.255.0");
 
Ipv4InterfaceContainer i15 = ipv4.Assign (d1d5);
  i15
.SetMetric(0,2);
  i15
.SetMetric(1,2);
  ipv4
.SetBase ("10.2.5.0", "255.255.255.0");
 
Ipv4InterfaceContainer i25 = ipv4.Assign (d2d5);
  i25
.SetMetric(0,2);
  i25
.SetMetric(1,2);

  NS_LOG_INFO
("Populate routing tables.");
 
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
 
  NS_LOG_INFO
("Create Applications.");
  uint16_t port
= 9;

 
OnOffHelper onoff ("ns3::UdpSocketFactory",InetSocketAddress (Ipv4Address ("10.2.3.2"), port));    
  onoff
.SetConstantRate (DataRate ("100kbps"));
  onoff
.SetAttribute ("PacketSize", UintegerValue (500));

 
ApplicationContainer apps;
 
for (uint32_t i = 0; i < 3; i++){
  apps
.Add (onoff.Install (c.Get (0)));}
  apps
.Start (Seconds (1.0));
  apps
.Stop (Seconds (10));

 
PacketSinkHelper sink ("ns3::UdpSocketFactory",Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
  sink
.Install (c.Get (3));  
 
 
Ipv4GlobalRoutingHelper helper3;
 
Ptr<OutputStreamWrapper> stream2 = Create<OutputStreamWrapper> ("ArpCacheEntries", std::ios::out);
  helper3
.PrintNeighborCacheAllEvery (Seconds (1), stream2);

 
 
AnimationInterface anim ("ecmp_routing_multi_topo.xml");
  anim
.SetConstantPosition(c.Get(0),0.0,3.0);
  anim
.SetConstantPosition(c.Get(1),2.0,3.0);
  anim
.SetConstantPosition(c.Get(2),6.0,3.0);    
  anim
.SetConstantPosition(c.Get(3),8.0,3.0);  
  anim
.SetConstantPosition(c.Get(4),5.0,1.0);
  anim
.SetConstantPosition(c.Get(5),4.0,5.0);
  anim
.SetConstantPosition(c.Get(6),3.0,1.0);
  anim
.EnablePacketMetadata (true);
 
Simulator::Stop (Seconds(10));
 
Simulator::Run ();
 
Simulator::Destroy ();
}
ecmp-routing.cc

Tommaso Pecorella

unread,
Nov 28, 2015, 1:47:32 PM11/28/15
to ns-3-users
Right... ARP cache entries are missing. Right... 
Guess what ? PointToPoint links do NOT need an ARP cache, simply because there's nothing more than ONE host at the other end.

bool
PointToPointNetDevice::NeedsArp (void) const
{
  NS_LOG_FUNCTION
(this);
 
return false;
}

That's why you don't have an entry, because it's unnecessary. When you have a P2P link you don't need to know the other end MAC address, you just need to know the local interface number !

T.
...
Message has been deleted

f201...@pilani.bits-pilani.ac.in

unread,
Dec 7, 2015, 6:12:54 AM12/7/15
to ns-3-users
Thank you sir for your valuable input, I got the interface IP address corresponding to previous hop address.
Reply all
Reply to author
Forward
0 new messages