Bug 1308 - Don't process self-directed packets
Don't process self-directed packets
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: nix-vector
pre-release
All All
: P5 normal
Assigned To: John Abraham
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-06 10:34 EST by John Abraham
Modified: 2012-07-19 16:04 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Abraham 2011-12-06 10:34:49 EST
NS3 folks,

I've run across an issue with NIX routing that occurs under very specific conditions:

1.       Using a very simple CSMA network (see code below)

2.       Using NIX routing

3.       A single application (OnOff app)  is defined with a remote address.

4.       The application is installed on a node containing the address of the remote destination
Essentially the Node is sending OnOff packets to itself.

I get the following error:
msg="You've tried to extract too many bits of the Nix-vector, 0xb65e680. NumberBits: 2 Remaining: 1", file=../src/network/model/nix-vector.cc, line=174

Although a little unusual, shouldn't this work?

This doesn't occur on P2P networks, nor when using Global routing

Here's the code that will generate the error:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
// nixProblem
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/csma-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-nix-vector-helper.h"
#include "ns3/ipv4-static-routing-helper.h"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("nixProblem");

int           main (int argc, char *argv[]) {

// Allow the user to override any of the defaults and the above
// Bind ()s at run-time, via command-line arguments
CommandLine cmd;
cmd.Parse (argc, argv);

// ==========================================================
// Initialization
// ==========================================================
NS_LOG_INFO ("Create global node container.");
NodeContainer allNodes;
NS_LOG_INFO ("Create CsmaHelper.");
CsmaHelper csmaHelper;
NS_LOG_INFO ("Create InternetStackHelper.");
InternetStackHelper stackHelper;
NS_LOG_INFO ("Create Ipv4AddressHelper.");
Ipv4AddressHelper ipv4Helper;

// ==========================================================
// Processing Node Containers
// ==========================================================
NS_LOG_INFO ("Creating nodeContainer: sn_1_Nodes");

NodeContainer sn_1_Nodes;
sn_1_Nodes.Create(5);

// Append to allNodes
allNodes.Add(sn_1_Nodes);

// ==========================================================
// NixHelper to install nix-vector routing on all nodes
// ==========================================================
Ipv4NixVectorHelper nixRouting;
Ipv4StaticRoutingHelper staticRouting;

Ipv4ListRoutingHelper list;
list.Add (staticRouting, 0);
list.Add (nixRouting, 10);

// ==========================================================
// aggregate IP/TCP/UDP functionality to ALL_NODES
// ==========================================================
NS_LOG_INFO ("Setting Routing Helper");
stackHelper.SetRoutingHelper (list);
stackHelper.Install(allNodes);

// ==========================================================
// Processing csma network
// ==========================================================
NS_LOG_INFO ("Creating sn_1");

// We create the channels first without any IP addressing information
csmaHelper.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csmaHelper.SetChannelAttribute ("Delay", StringValue ("6ms"));
NetDeviceContainer sn_1_Devices = csmaHelper.Install(sn_1_Nodes);

// Assign IP Addresses
ipv4Helper.SetBase ("10.1.2.0", "255.255.255.0");
ipv4Helper.Assign (sn_1_Devices);
Ipv4InterfaceContainer sn_1_Interfaces = ipv4Helper.Assign(sn_1_Devices);


// ==========================================================
// Create simple OnOff app with src & dest being the same node
// ==========================================================
NS_LOG_INFO ("Creating onOff App");

OnOffHelper onoff_0 ("ns3::UdpSocketFactory", InetSocketAddress(sn_1_Interfaces.GetAddress (1), 9));
onoff_0.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
onoff_0.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
onoff_0.SetAttribute ("DataRate", StringValue("300bps"));
onoff_0.SetAttribute ("PacketSize", UintegerValue(50));

ApplicationContainer onOffApp_0;
onOffApp_0.Add(onoff_0.Install (sn_1_Nodes.Get (1)));
onOffApp_0.Start(Seconds (1.0));
onOffApp_0.Stop(Seconds (20.0));

// ==========================================================
// Processing Run Options
// ==========================================================
NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();

NS_LOG_INFO ("Done.");
}
Comment 1 John Abraham 2011-12-06 10:36:20 EST
Yes, I believe this is because you are sending packets to yourself and nix-vector does not currently handle this correctly.

Personally, I don't see any advantage in Nix-vector-routing having to deal with this special case (its not the primary motivation for use nix-vector) and would prefer static routing or other protocols in the list to handle it, so the following may prevent the error.

ns-3-dev john$ hg diff
diff -r 9b0902620ff7 src/nix-vector-routing/model/ipv4-nix-vector-routing.cc
--- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc	Tue Dec 06 08:42:44 2011 -0500
+++ b/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc	Tue Dec 06 10:27:59 2011 -0500
@@ -140,8 +140,9 @@
   // build the nix vector a little differently
   if (source == destNode)
     {
-      BuildNixVectorLocal (nixVector);
-      return nixVector;
+      //BuildNixVectorLocal (nixVector);
+      //return nixVector;
+      return 0;
     }
   else
     {
Comment 2 Tom Henderson 2012-04-23 12:04:22 EDT
will commit if no other comments
Comment 3 HU ZHIMING 2012-07-19 11:50:32 EDT
I found out this bug today.
Comment 4 John Abraham 2012-07-19 12:05:08 EDT
@tom , did we commit  a bug fix for this yet? your previous comment seems to suggest so
Comment 5 Tom Henderson 2012-07-19 16:04:15 EDT
(In reply to comment #4)
> @tom , did we commit  a bug fix for this yet? your previous comment seems to
> suggest so


Forgot to do this earlier, just pushed in changeset c2649ef48eaa