imported patch manemo-linuxsock.patch
authorHajime Tazaki <tazaki@sfc.wide.ad.jp>
Fri, 12 Nov 2010 10:53:33 +0900
changeset 6794 454cb903211d
parent 6793 5311b571f9cd
child 6795 a3420f767e78
imported patch manemo-linuxsock.patch
src/dce/example/manemo.cc
src/dce/helper/quagga-helper.cc
src/dce/helper/quagga-helper.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dce/example/manemo.cc	Fri Nov 12 10:53:33 2010 +0900
@@ -0,0 +1,829 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+
+// 
+//             Scenario Overview
+// 
+//          +---------------------------------------------------------------------------------+
+//          |                                                                                 |
+//          |             802.11 (ad hoc) , mobility, OLSR/TDP                                | 
+//          |                                                                                 |
+//          +---------------------------------------------------------------------------------+
+//                   |       o o o (N backbone routers)       |                       |             ^
+//               +--------+                               +--------+              +--------+        |       
+//      < - - - -| mobile |                               | mobile |              | mobile |- - - - +
+//       apDevIF | router |                               | router |              | router |  extDevIF(Emu)  
+//        (Emu)   ---------                                ---------               ---------    
+//                   |*AP                                     |*AP                    |*AP     
+//          +----------------+                       +----------------+      +----------------+
+//          |     802.11     |                       |     802.11     |      |     802.11     |
+//          |      net       |                       |       net      |      |       net      |
+//          |   K-1 hosts    |                       |   K-1 hosts    |      |   K-1 hosts    |
+//          +----------------+                       +----------------+      +----------------+
+
+
+#include "ns3/core-module.h"
+#include "ns3/helper-module.h"
+#include "ns3/mobility-module.h"
+#include "ns3/dce-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/global-route-manager.h"
+#include "ns3/node-module.h"
+#include "ns3/log.h"
+#include "ns3/wifi-module.h"
+#include "ns3/ipv4-l3-protocol.h"
+#include "ns3/ipv4-global-routing-helper.h"
+#include "ns3/ipv6-l3-protocol.h"
+#include "ns3/ipv6-header.h"
+#include "ns3/icmpv6-header.h"
+#include "ns3/udp-header.h"
+#include "ns3/realtime-simulator-impl.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+#include <fstream>
+#include <sstream>
+
+#include "ns3/radvd.h"
+#include "ns3/radvd-interface.h"
+#include "ns3/radvd-prefix.h"
+
+#include "ns3/visualizer.h"
+#include "ns3/pyviz.h"
+#include "ns3/stats-module.h"
+
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("manemo-exp");
+
+// Parameters
+uint32_t mrNodes = 10;
+uint32_t mnnNodes = 2;
+uint32_t stopTime = 60;
+bool olsr = false;
+bool useTap = false;
+bool useEmu = false;
+bool useViz = false;
+int movement = 0;
+bool noPing = false;
+bool useWifi = true;
+std::string PDRate = "0.01Mb/s";
+std::string expSquare = "200";     // meter
+std::string outdir = "./";
+int speed = 20;
+std::string experiment = "manemo-rp-test";
+std::string strategy = "none";
+std::string input;
+std::string runID;
+std::string extDevIF = "eth0";
+std::string apDevIF = "eth1";
+bool rgNet = false;
+
+void 
+CourseChange (std::string context, Ptr<const MobilityModel> model) 
+{ 
+  Vector position = model->GetPosition (); 
+  NS_LOG_UNCOND (context << 
+                 " x = " << position.x << ", y = " << position.y); 
+} 
+
+void
+procExit (std::string path, uint16_t pid, int retcode)
+{
+  std::cout << "Process exit path=" << path << " pid=" << pid << " retcode=" << retcode << std::endl;
+}
+
+
+void
+LogTxCpkt (Ptr<PacketSizeMinMaxAvgTotalCalculator> cpktTx,
+         std::string context, Ptr<const Packet> packet, uint32_t interfaceIndex)
+{
+  // TDP/NINA and OLSR only for egress IF
+  if (interfaceIndex != 1)
+    {
+      return;
+    }
+
+  Ptr<Packet> copy = packet->Copy ();
+  Ipv6Header ipHeader;
+  copy->RemoveHeader(ipHeader);
+
+  // In case of TDP/NINA
+  if (olsr == 0)
+    {
+      if (ipHeader.GetNextHeader() != Ipv6Header::IPV6_ICMPV6)
+        {
+          return;
+        }
+
+      Icmpv6Header icmpHeader;
+      copy->PeekHeader (icmpHeader);
+      uint8_t type = icmpHeader.GetType ();
+
+      if (type != Icmpv6Header::ICMPV6_ND_NEIGHBOR_ADVERTISEMENT &&
+          type != Icmpv6Header::ICMPV6_ND_ROUTER_ADVERTISEMENT)
+        {
+          return;
+        }
+
+      Icmpv6RA raHeader;
+      Icmpv6NA naHeader;
+      Icmpv6OptionHeader optHeader;
+      Icmpv6OptionPrefixInformation prefixHdr;
+      Icmpv6OptionMtu mtuHdr;
+      Icmpv6OptionLinkLayerAddress llaHdr;
+
+      if (type == Icmpv6Header::ICMPV6_ND_NEIGHBOR_ADVERTISEMENT)
+        {
+          copy->RemoveHeader(naHeader);
+        }
+      else if (type == Icmpv6Header::ICMPV6_ND_ROUTER_ADVERTISEMENT)
+        {
+          copy->RemoveHeader(raHeader);
+        }
+
+      int optlen  = copy->GetSize();
+      bool found = false;
+
+      /* XXX search all options following the RA header and the correct type */
+      while (optlen > 0)
+        {
+          type = *copy->PeekData ();
+          if (type == Icmpv6Header::ICMPV6_OPT_PREFIX)
+            {
+              copy->RemoveHeader (prefixHdr);
+              optlen -= prefixHdr.GetLength();
+            }
+          else if (type == Icmpv6Header::ICMPV6_OPT_MTU)
+            {
+              copy->RemoveHeader (mtuHdr);
+              optlen -= mtuHdr.GetLength();
+            }
+          else if(type == Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE)
+            {
+              copy->RemoveHeader (llaHdr);
+              optlen -= llaHdr.GetLength();
+            }
+
+          else if(type == Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET)
+            {
+              copy->RemoveHeader (llaHdr);
+              optlen -= llaHdr.GetLength();
+            }
+
+          // TIO in RA or NINA in NA
+          else if (type == 10 ||
+                   type == 11)
+            {
+              found = true;
+              break;
+            }
+          else 
+            {
+              Icmpv6OptionHeader optHdr;
+              copy->RemoveHeader (optHdr);
+              optlen -= optHdr.GetLength();
+            }
+        }
+
+      if (!found)
+        {
+          NS_LOG_INFO("No TIO/NINA is found in packet");
+          return;
+        }
+
+      //   NS_LOG_INFO(context << " Sent frame ICMPType = " << (int)type << " counted in " <<
+      //               tdpTx->GetKey() << " IP datagram size = " << ipHeader.GetPayloadLength ()+40);
+      cpktTx->Update(ipHeader.GetPayloadLength () + 40);
+    }
+  // In case of OLSR
+  else
+    {
+      if (ipHeader.GetNextHeader() != Ipv6Header::IPV6_UDP)
+        return;
+      UdpHeader udpHeader;
+      copy->PeekHeader (udpHeader);
+      uint16_t port = udpHeader.GetDestinationPort ();
+
+      if (port == 698)
+        cpktTx->Update(ipHeader.GetPayloadLength () + 40);
+    }
+  return;
+}
+
+
+static void RunIp (Ptr<Node> node, Time at, std::string str)
+{
+  DceApplicationHelper process;
+  ApplicationContainer apps;
+  process.SetBinary ("build/debug/ip");
+  process.SetStackSize (1<<16);
+  process.ResetArguments();
+  process.ParseArguments(str.c_str ());
+  apps = process.Install (node);
+  apps.Start (at);
+}
+
+static void AddAddress (Ptr<Node> node, Time at, const char *name, const char *address)
+{
+  std::ostringstream oss;
+  oss << "-f inet6 addr add " << address << " dev " << name;
+  RunIp (node, at, oss.str ());
+}
+
+int
+main (int argc, char *argv[])
+{
+  // 
+  //  Step 0
+  //  Node Basic Configuration
+  // 
+
+  // Enable Packet Pring
+  ns3::PacketMetadata::Enable ();
+
+  {
+    std::stringstream sstr;
+    sstr << "run-" << time(NULL);
+    runID = sstr.str();
+
+    sstr.clear();
+    if (olsr == 0)
+      sstr << "TDP_NINA";
+    else
+      sstr << "OLSR";
+    strategy = sstr.str();
+
+    sstr.clear();
+    sstr << mrNodes;
+    input = sstr.str();
+
+    sstr.clear();
+    if (movement == 0)
+      sstr << "no-movement" ;
+    else if (movement == 1)
+      sstr << "Oneway-movement" ;
+    else if (movement == 2)
+      sstr << "RandomWayPoint" ;
+    else if (movement == 3)
+      sstr << "ManhattanGrid" ;
+    else if (movement == 4)
+      sstr << "DisasterArea" ;
+    else if (movement == 5)
+      sstr << "MCM" ;
+    else if (movement == 6)
+      sstr << "no-movement_circle" ;
+
+    experiment = sstr.str();
+  }
+
+  CommandLine cmd;
+  cmd.AddValue ("olsr", "Test with OLSRv1", olsr);
+  cmd.AddValue ("mrNodes", "Number of MR nodes", mrNodes);
+  cmd.AddValue ("stopTime", "Time to stop(seconds)", stopTime);
+  cmd.AddValue ("useTap", "Use tap device", useTap);
+  cmd.AddValue ("useEmu", "Use tap device", useEmu);
+  cmd.AddValue ("useViz", "Use Visualizer", useViz);
+  cmd.AddValue ("move", "with MR0's movement", movement);
+  cmd.AddValue ("noPing", "prevent use ping6", noPing);
+  cmd.AddValue ("useWifi", "Use Wifi as interfaces", useWifi);
+  cmd.AddValue("run", "Identifier for run.", runID);
+  cmd.AddValue("outdir", "Directory for output file.", outdir);
+  cmd.AddValue("extDevIF", "Interface name for external connectivity.", extDevIF);
+  cmd.AddValue("apDevIF", "Interface name for external connectivity.", apDevIF);
+  cmd.AddValue("rgNet", "RGNet or Camp-Net.", rgNet);
+  cmd.Parse (argc,argv);
+
+  LogComponentEnable("manemo-exp", LOG_LEVEL_INFO);
+
+
+  if (useTap || useEmu)
+    {
+      Config::SetGlobal ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
+//      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->SetAttribute ("SynchronizationMode", EnumValue (RealtimeSimulatorImpl::SYNC_HARD_LIMIT));
+
+      Config::SetGlobal ("ChecksumEnabled", BooleanValue (true));
+    }
+
+
+  // 
+  //  Step 1
+  //  Node Basic Configuration
+  // 
+  NodeContainer mr;
+  mr.Create (mrNodes);
+  NodeContainer mnn;
+  mnn.Create (mnnNodes);
+  NodeContainer mnnDest;
+  //  mnnDest.Create (1);
+  NetDeviceContainer egressDevs;
+  NetDeviceContainer ingressDevs;
+  CsmaHelper csma;
+  EmuHelper emu;
+
+  NodeContainer tapHost;
+  if (useTap)
+    {
+      tapHost.Create (1);
+    }
+
+
+  WifiHelper wifi = WifiHelper::Default (); 
+  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
+
+  // 
+  //  Step 2
+  //  Interface Configuration for Egress (adhoc) IF
+  // 
+  Ssid ssid = Ssid ("ns-3-ssid");
+  Ptr<YansWifiChannel> adhocChannel;
+  if (useWifi)
+    {
+      // Adhoc IF Configuration for egress IF
+      wifiMac.SetType ("ns3::AdhocWifiMac");
+#if 1
+  // disable fragmentation for frames below 2200 bytes
+  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
+  // turn off RTS/CTS for frames below 2200 bytes
+  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
+//  wifiPhy.Set ("RxGain", DoubleValue (-30) ); 
+//  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
+//  wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
+    wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-96.0) );
+    wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-99.0) );
+
+
+
+      wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
+                                    "ControlMode",StringValue("wifia-6mbs"),
+                                    "DataMode", StringValue ("wifia-6mbs"));
+
+//      wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel",
+//                                     "ReferenceDistance", DoubleValue(100.0),
+//                                     "Exponent", DoubleValue(0.1)); //default is 3.0
+#else
+//     wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
+//     NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
+//     Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", 
+//                         StringValue ("wifib-5.5mbs"));
+     wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
+                                   "DataMode",StringValue("wifib-5.5mbs"),
+                                   "ControlMode",StringValue("wifib-5.5mbs"));
+
+#endif
+
+      adhocChannel = wifiChannel.Create ();
+      wifiPhy.SetChannel (adhocChannel);
+      egressDevs = wifi.Install (wifiPhy, wifiMac, mr);
+    }
+  else
+    {
+      egressDevs = csma.Install (mr);
+    }
+
+
+  // address assign to interface on egress IF
+  //  NS_LOG_INFO ("Assign IPv6 Addresses.");
+  for (uint32_t i = 0; i < mrNodes; ++i)
+    {
+      std::stringstream addrstr;
+      addrstr.str("");
+      addrstr << "2001:0:0:1::" << (i+1);
+      AddAddress (mr.Get (i), Seconds (0.1), "sim0", addrstr.str ().c_str ());
+      RunIp (mr.Get (i), Seconds (0.11), "link set lo up");
+      RunIp (mr.Get (i), Seconds (0.11), "link set sim0 up");
+    }
+
+  // 
+  // Step 3
+  // Interface Configuration for Igress Interface
+  // 
+
+  // address assign to interface on ingress IF
+  Ipv6InterfaceContainer v6Ingress;
+  Ptr<YansWifiChannel> mnnChan, mnnDestChan;
+  NetDeviceContainer extDevs;
+  // Configure LAN
+  for (uint32_t i = 0, cnt=0; i < mrNodes; ++i)
+    {
+      NetDeviceContainer tmpDev;
+      wifiMac.SetType ("ns3::NqapWifiMac",
+                       "Ssid", SsidValue (ssid),
+                       "BeaconGeneration", BooleanValue (true),
+                       "BeaconInterval", TimeValue (Seconds (2.5)));
+
+      if(i == 0)
+        {
+          mnnChan = wifiChannel.Create ();
+          wifiPhy.SetChannel (mnnChan);
+
+        }
+      else if(i == mrNodes -1)
+        {
+//           mnnDestChan = wifiChannel.Create ();
+//           wifiPhy.SetChannel (mnnDestChan);
+        }
+      else
+        {
+          continue;
+          wifiPhy.SetChannel (wifiChannel.Create());
+        }
+
+      if (i == 0 && useEmu)
+        {
+          emu.SetAttribute ("DeviceName", StringValue (apDevIF));
+          emu.SetAttribute ("EncapsulationMode", StringValue ("Dix"));
+          emu.SetAttribute ("Address", Mac48AddressValue(Mac48Address ("00:00:00:00:00:10")));
+          tmpDev = emu.Install (mr.Get(i));
+
+          ingressDevs.Add (tmpDev);
+
+          std::stringstream addrstr;
+          addrstr.str("");
+          addrstr << "2001:200:0:ffc0::" << (i+1);
+          AddAddress (mr.Get (i), Seconds (0.2), "sim1", addrstr.str ().c_str ());
+          RunIp (mr.Get (i), Seconds (0.21), "link set sim1 up");
+
+          cnt++;
+        }
+      else
+        {
+          //          tmpDev = wifi.Install (wifiPhy, wifiMac, mr.Get(i));
+        }
+
+      if (i == mrNodes-1 && useEmu)
+        {
+          // Interface for external IF
+          emu.SetAttribute ("DeviceName", StringValue (extDevIF));
+          emu.SetAttribute ("EncapsulationMode", StringValue ("Dix"));
+          emu.SetAttribute ("Address", Mac48AddressValue(Mac48Address ("00:01:02:03:04:05")));
+          extDevs = emu.Install (mr.Get(i));
+
+          std::stringstream addrstr;
+          addrstr.str("");
+          addrstr << "2001:200:0:ffc1::" << (i+1);
+          AddAddress (mr.Get (i), Seconds (0.2), "sim1", addrstr.str ().c_str ());
+          RunIp (mr.Get (i), Seconds (0.21), "link set sim1 up");
+        }
+      RunIp (mr.Get (i), Seconds (0.3), "route show table all");
+      RunIp (mr.Get (i), Seconds (0.4), "addr list");
+    }
+
+  // 
+  // Step 4
+  // Mobility Model Configuration
+  // 
+  MobilityHelper mobility;
+  double distance = 70.0;
+  Ptr<ListPositionAllocator> positionAlloc;
+  if (movement == 2)
+    {
+      Ptr<ns3::RandomDiscPositionAllocator> r_position =
+        CreateObject<RandomDiscPositionAllocator> ();
+      r_position->SetX (atof(expSquare.c_str())/2);
+      r_position->SetY (atof(expSquare.c_str())/2);
+      r_position->SetRho (UniformVariable (0, atof(expSquare.c_str())/2 ));
+      mobility.SetPositionAllocator (r_position);
+
+      mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
+                                 "PositionAllocator", PointerValue (r_position),
+                                 "Speed", RandomVariableValue (ConstantVariable (speed)),
+                                 "Pause", RandomVariableValue (ConstantVariable (0.2)));
+
+      mobility.Install (mr);
+    }
+  else
+    {
+      // No mobility with linear placement
+      // Linear placement
+      positionAlloc = CreateObject<ListPositionAllocator> ();
+      double x = 0.0;
+      for (uint32_t i = 0; i < mrNodes; ++i)
+        {
+          positionAlloc->Add (Vector (x, -x, 0.0));
+          x += distance;
+        }
+      mobility.SetPositionAllocator (positionAlloc);
+
+      mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+      mobility.Install (mr);
+    }
+
+  // 
+  //  Step 5
+  //  Application (zebra/olsr6d) configuration for MR
+  // 
+  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
+
+  //run quagga programs in every node
+  DceManagerHelper processManager;
+  processManager.SetLoader ("ns3::DlmLoaderFactory");
+  processManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
+                                 "Library", StringValue ("libnet-next-2.6.so"));
+  processManager.Install (mr);
+
+  QuaggaHelper quagga;
+  quagga.EnableTdpNina (mr);
+  quagga.Install (mr);
+
+  DceApplicationHelper process;
+  ApplicationContainer apps;
+  if(olsr)
+    {
+      process.SetBinary ("olsr6d");
+      process.SetStackSize (1<<16);
+      apps = process.Install (mr);
+      for (uint32_t i = 0; i < mrNodes; ++i)
+        {
+          apps.Get(i)->SetStartTime (Seconds (1.0 + 1.10 * i));
+        }
+    }
+
+
+  // 
+  //  Step 6
+  //  Mobile Network Node Configuration
+  // 
+  // Mobility model for MNN/ move with (mr0)
+  mobility.PushReferenceMobilityModel (mr.Get (0));
+  Ptr<MobilityModel> parentMobility = mr.Get (0)->GetObject<MobilityModel> ();
+  Vector pos =  parentMobility->GetPosition ();
+  Ptr<ListPositionAllocator> positionAllocMnn = 
+    CreateObject<ListPositionAllocator> ();
+  for (uint32_t i = 0; i < mnnNodes; ++i)
+    {
+      pos.x = 5*(i+1);
+      pos.y = 20;
+      positionAllocMnn->Add (pos);
+    }
+  mobility.SetPositionAllocator (positionAllocMnn);
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (mnn);
+  wifiMac.SetType ("ns3::NqstaWifiMac",
+                   "Ssid", SsidValue (ssid),
+                   "ActiveProbing", BooleanValue (false),
+                   "ProbeRequestTimeout", TimeValue (Seconds(1.0)),
+                   "MaxMissedBeacons", UintegerValue(3));
+  wifiPhy.SetChannel (mnnChan);
+  NetDeviceContainer mnnDevs = wifi.Install (wifiPhy, wifiMac, mnn);
+
+
+  // Tap for external connectivity
+  if (useTap)
+    {
+      mobility.PushReferenceMobilityModel (mr.Get (0));
+      Ptr<MobilityModel> parentMobility = mr.Get (0)->GetObject<MobilityModel> ();
+      Vector pos =  parentMobility->GetPosition ();
+      Ptr<ListPositionAllocator> positionAllocAp = 
+        CreateObject<ListPositionAllocator> ();
+      pos.x = 10;
+      pos.y = 0;
+      positionAllocAp->Add (pos);
+      mobility.SetPositionAllocator (positionAllocAp);
+      mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+      mobility.Install (tapHost);
+
+
+      Ptr<YansWifiChannel> tapWifiChan = wifiChannel.Create ();
+      wifiPhy.SetChannel (tapWifiChan);
+      wifiMac.SetType ("ns3::NqapWifiMac",
+                       "Ssid", SsidValue (Ssid ("ns-3-tap")),
+                       "BeaconGeneration", BooleanValue (true),
+                       "BeaconInterval", TimeValue (Seconds (2.5)));
+      NetDeviceContainer tapDevs = wifi.Install (wifiPhy, wifiMac, tapHost);
+
+      std::string mode = "ConfigureLocal";
+      std::string tapName = "mytapap";
+
+      Ipv4AddressHelper ipv4;
+      ipv4.SetBase ("10.1.1.0", "255.255.255.0");
+      Ipv4InterfaceContainer v4Tap = ipv4.Assign (tapDevs);
+
+      TapBridgeHelper tapBridge (v4Tap.GetAddress (0));
+      tapBridge.SetAttribute ("Mode", StringValue (mode));
+      tapBridge.SetAttribute ("DeviceName", StringValue (tapName));
+      tapBridge.Install (tapHost.Get(0), tapDevs.Get(0));
+
+      // STA devs for MR0
+      wifiMac.SetType ("ns3::NqstaWifiMac",
+                       "Ssid", SsidValue (Ssid ("ns-3-tap")),
+                       "ActiveProbing", BooleanValue (false),
+                       "ProbeRequestTimeout", TimeValue (Seconds(1.0)),
+                       "MaxMissedBeacons", UintegerValue(3));
+      wifiPhy.SetChannel (tapWifiChan);
+      NetDeviceContainer mrTapDev = wifi.Install (wifiPhy, wifiMac, mr.Get (0));
+
+      std::stringstream addrstr;
+      addrstr.str("");
+      addrstr << "2001:200:0:888d::1";
+      AddAddress (mr.Get (0), Seconds (0.3), tapName.c_str(), addrstr.str ().c_str ());
+    }
+
+
+
+  // 
+  // Step 7: Statistics Part Configuration
+  // To measure Packet Delivery Ratio
+  // 
+  // Create a DataCollector object to hold information about this run.
+  {
+    std::stringstream sstr;
+    sstr << "run-" << strategy << "_" << runID << "-m" << movement << "-v" << speed;
+    runID = sstr.str();
+  }
+  DataCollector data;
+  data.DescribeRun(experiment,
+                   strategy,
+                   input,
+                   runID);
+  // Add any information we wish to record about this run.
+  data.AddMetadata("author", "tazakivic");
+
+  // Collect UDP Tx Packet
+  Ptr<PacketCounterCalculator> udp6Tx =
+    CreateObject<PacketCounterCalculator>();
+  udp6Tx->SetKey("sender-tx-packets");
+  Config::Connect("/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx",
+                  MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                               udp6Tx));
+  data.AddDataCalculator(udp6Tx);
+
+  // Collect UDP Rx Packet
+  Ptr<PacketCounterCalculator> udp6Rx =
+    CreateObject<PacketCounterCalculator>();
+  udp6Rx->SetKey("receiver-rx-packets");
+  Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                udp6Rx));
+  data.AddDataCalculator(udp6Rx);
+
+
+  // Collect Overhead of control packet (TDP/NINA, OLSR)
+  Ptr<PacketSizeMinMaxAvgTotalCalculator> cpktTx =
+    CreateObject<PacketSizeMinMaxAvgTotalCalculator>();
+  cpktTx->SetKey("tx-cpkt-size");
+  Config::Connect ("/NodeList/*/$ns3::Ipv6L3Protocol/Tx",
+                   MakeBoundCallback(&LogTxCpkt, cpktTx));
+  data.AddDataCalculator(cpktTx);
+
+  // Mac Counter
+  // Mac RX counter
+  Ptr<PacketCounterCalculator> macRx =
+    CreateObject<PacketCounterCalculator>();
+  macRx->SetKey("mac-rx-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacRx",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                macRx));
+  data.AddDataCalculator(macRx);
+
+  // Mac RX Drop Counter
+  Ptr<PacketCounterCalculator> macDropRx =
+    CreateObject<PacketCounterCalculator>();
+  macDropRx->SetKey("mac-rx-drop-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacRxDrop",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                macDropRx));
+  data.AddDataCalculator(macDropRx);
+
+  // Mac TX counter
+  Ptr<PacketCounterCalculator> macTx =
+    CreateObject<PacketCounterCalculator>();
+  macTx->SetKey("mac-tx-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacTx",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                macTx));
+  data.AddDataCalculator(macTx);
+  // Mac TX Drop Counter
+  Ptr<PacketCounterCalculator> macDropTx =
+    CreateObject<PacketCounterCalculator>();
+  macDropTx->SetKey("mac-tx-drop-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacTxDrop",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                macDropTx));
+  data.AddDataCalculator(macDropTx);
+
+  // Phy
+  // Phy TX counter
+  Ptr<PacketCounterCalculator> phyTx =
+    CreateObject<PacketCounterCalculator>();
+  phyTx->SetKey("phy-tx-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Phy/PhyTxEnd",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                phyTx));
+  data.AddDataCalculator(phyTx);
+  // Phy TX Drop Counter
+  Ptr<PacketCounterCalculator> phyDropTx =
+    CreateObject<PacketCounterCalculator>();
+  phyDropTx->SetKey("phy-tx-drop-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Phy/PhyTxDrop",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                phyDropTx));
+  data.AddDataCalculator(phyDropTx);
+
+  // Phy RX counter
+  Ptr<PacketCounterCalculator> phyRx =
+    CreateObject<PacketCounterCalculator>();
+  phyRx->SetKey("phy-rx-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Phy/PhyRxEnd",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                phyRx));
+  data.AddDataCalculator(phyRx);
+  // Phy RX Drop Counter
+  Ptr<PacketCounterCalculator> phyDropRx =
+    CreateObject<PacketCounterCalculator>();
+  phyDropRx->SetKey("phy-rx-drop-packets");
+  Config::Connect ("/NodeList/*/DeviceList/*/Phy/PhyRxDrop",
+                   MakeCallback(&PacketCounterCalculator::PacketUpdate,
+                                phyDropRx));
+  data.AddDataCalculator(phyDropRx);
+
+
+  // 
+  // Output (generate file) section
+  // 
+
+#if 0
+  std::ofstream ascii;
+  ascii.open ("process-zebra.tr");
+  YansWifiPhyHelper::EnableAsciiAll (ascii);
+  std::ofstream mob;
+  mob.open ("process-zebra.mob");
+  MobilityHelper::EnableAsciiAll (mob);
+#endif
+
+  // 
+  // Step 8: Pcap generation
+  // To measure Packet Delivery Ratio
+  // 
+#if 1
+  if(!olsr)
+    {
+      if (useWifi)
+        wifiPhy.EnablePcap ("output/zebra.z", mr);
+      else
+        csma.EnablePcap ("output/zebra.z", mr, true);
+
+
+      emu.EnablePcap ("output/zebra.z-emu", NodeContainer(mr.Get(0)), true);
+      emu.EnablePcap ("output/zebra.z-emu", extDevs, true);
+      wifiPhy.EnablePcap ("output/zebra.z", tapHost);
+    }
+  else
+    {
+      wifiPhy.EnablePcap ("output/zebra.o", mr);
+      emu.EnablePcap ("output/zebra.o-emu", NodeContainer(mr.Get(0)), true);
+      emu.EnablePcap ("output/zebra.o-emu", NodeContainer(mr.Get(mrNodes - 1)), true);
+      wifiPhy.EnablePcap ("output/zebra.o", tapHost);
+    }
+#endif
+
+
+  // Make trace on mobility
+  std::ostringstream oss; 
+  oss << 
+    "/NodeList/" << mr.Get (0)->GetId () << 
+    "/$ns3::MobilityModel/CourseChange"; 
+  //  Config::Connect (oss.str (), MakeCallback (&CourseChange));
+  //  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/State", MakeCallback (&PhyStateTrace));
+
+  // For debug of process
+  Config::Connect ("/NodeList/*/$ns3::DceManager/Exit", MakeCallback (&procExit));
+
+
+  // 
+  // Step 10
+  // Now It's ready to GO!
+  // 
+  if (stopTime != 0)
+    {
+	  Simulator::Stop (Seconds (stopTime));
+    }
+  if (useViz)
+    {
+      Visualizer::Run ();
+    }
+  else
+    {
+      Simulator::Run ();
+    }
+  Simulator::Destroy ();
+
+  // 
+  // Step 11
+  // After Execution
+  // 
+  Ptr<DataOutputInterface> output = 0;
+#ifdef STATS_HAS_SQLITE3
+  output = CreateObject<SqliteDataOutput>();
+  if (output != 0){
+    output->SetFilePrefix ("ieice0912/" + outdir + "/data");
+    output->Output(data);
+  }
+#endif
+
+  std::cout << "End of experiment" << std::endl;
+
+  return 0;
+}
--- a/src/dce/helper/quagga-helper.cc	Fri Nov 12 10:53:29 2010 +0900
+++ b/src/dce/helper/quagga-helper.cc	Fri Nov 12 10:53:33 2010 +0900
@@ -42,6 +42,24 @@
   {
   }
 
+  static TypeId 
+  GetTypeId (void)
+  {
+    static TypeId tid = TypeId ("ns3::QuaggaConfig")
+      .SetParent<Object> ()
+      .AddConstructor<QuaggaConfig> ()
+      ;
+    return tid;
+  }
+#if 0
+  TypeId 
+  GetInstanceTypeId (void) const
+  {
+    return GetTypeId ();
+  }
+#endif
+  bool m_tdpenable;
+  bool m_zebradebug;
 
   virtual void
   Print (std::ostream& os) const
@@ -73,6 +91,8 @@
     delete iflist;
   }
 
+  bool m_ospfdebug;
+
   static TypeId 
   GetTypeId (void)
   {
@@ -95,12 +115,14 @@
   Print (std::ostream& os) const
   {
     QuaggaConfig::Print (os);
-    //os << "log trap errors" << std::endl;
-    os << "debug ospf event " << std::endl;
-    //os << "debug ospf nsm " << std::endl;
-    //     os << "debug ospf ism " << std::endl;
-    // os << "debug ospf packet all " << std::endl;
-    os << "!" << std::endl;
+    if (m_ospfdebug)
+      {
+        //os << "log trap errors" << std::endl;
+        os << "debug ospf event " << std::endl;
+        os << "debug ospf nsm " << std::endl;
+        os << "debug ospf ism " << std::endl;
+        os << "debug ospf packet all " << std::endl;
+      }
 
     for (std::vector<uint32_t>::iterator i = iflist->begin (); 
          i != iflist->end (); ++i)
@@ -121,7 +143,6 @@
 
 
 QuaggaHelper::QuaggaHelper ()
-  : m_ospfenable (false)
 {
 }
 
@@ -138,7 +159,7 @@
   for (uint32_t i = 0; i < nodes.GetN (); i ++)
     {
       Ptr<OspfConfig> ospf_conf = CreateObject<OspfConfig> ();
-      nodes.Get (i)->AggregateObject(ospf_conf);
+      nodes.Get (i)->AggregateObject (ospf_conf);
 
       for (uint32_t j = 0; j < nodes.Get (i)->GetNDevices (); j ++)
         {
@@ -149,14 +170,61 @@
         }
     }
 
-  m_ospfenable = true;
+  return;
+}
+
+void
+QuaggaHelper::EnableOspfDebug (NodeContainer nodes)
+{
+  for (uint32_t i = 0; i < nodes.GetN (); i ++)
+    {
+      Ptr<OspfConfig> ospf_conf = nodes.Get (i)->GetObject<OspfConfig>();
+      if (!ospf_conf)
+        {
+          ospf_conf = new OspfConfig ();
+          nodes.Get (i)->AggregateObject (ospf_conf);
+        }
+      ospf_conf->m_ospfdebug = true;
+    }
+  return;
+}
+
+void
+QuaggaHelper::EnableTdpNina (NodeContainer nodes)
+{
+  for (uint32_t i = 0; i < nodes.GetN (); i ++)
+    {
+      Ptr<QuaggaConfig> zebra_conf = nodes.Get (i)->GetObject<QuaggaConfig>();
+      if (!zebra_conf)
+        {
+          zebra_conf = new QuaggaConfig ();
+          nodes.Get (i)->AggregateObject (zebra_conf);
+        }
+      zebra_conf->m_tdpenable = true;
+    }
+  return;
+}
+
+void
+QuaggaHelper::EnableZebraDebug (NodeContainer nodes)
+{
+  for (uint32_t i = 0; i < nodes.GetN (); i ++)
+    {
+      Ptr<QuaggaConfig> zebra_conf = nodes.Get (i)->GetObject<QuaggaConfig>();
+      if (!zebra_conf)
+        {
+          zebra_conf = new QuaggaConfig ();
+          nodes.Get (i)->AggregateObject (zebra_conf);
+        }
+      zebra_conf->m_zebradebug = true;
+    }
   return;
 }
 
 void
 QuaggaHelper::GenerateConfigZebra (Ptr<Node> node)
 {
-  QuaggaConfig *zebra_conf = new QuaggaConfig ();
+  Ptr<QuaggaConfig> zebra_conf = node->GetObject<QuaggaConfig>();
   Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
 
   // config generation
@@ -175,10 +243,28 @@
   std::ofstream conf;
   conf.open (conf_file.str ().c_str ());
   conf << *zebra_conf;
-  conf << "debug zebra kernel" << std::endl;
-  conf << "debug zebra events" << std::endl;
-  conf << "debug zebra route" << std::endl;
-  conf << "debug zebra packet" << std::endl;
+  if (zebra_conf->m_zebradebug)
+    {
+      conf << "debug zebra kernel" << std::endl;
+      conf << "debug zebra events" << std::endl;
+      conf << "debug zebra route" << std::endl;
+      conf << "debug zebra packet" << std::endl;
+    }
+  if (zebra_conf->m_tdpenable)
+    {
+      conf << "interface sim0" << std::endl;
+      conf << " ipv6 nd ra-interval 5" << std::endl;
+      conf << " ipv6 nd prefix-advertisement" << std::endl;
+      conf << " no ipv6 nd suppress-ra" << std::endl;
+      conf << " ipv6 nd home-agent-config-flag" << std::endl;
+      conf << "!" << std::endl;
+      conf << "interface sim1" << std::endl;
+      //      conf << " ipv6 nd td ingress" << std::endl;
+      conf << " ipv6 nd ra-interval 5" << std::endl;
+      conf << " ipv6 nd prefix-advertisement" << std::endl;
+      conf << " no ipv6 nd suppress-ra" << std::endl;
+      conf << "!" << std::endl;
+    }
   conf.close ();
 
 }
@@ -256,6 +342,12 @@
   DceApplicationHelper process;
   ApplicationContainer apps;
 
+  Ptr<QuaggaConfig> zebra_conf = node->GetObject<QuaggaConfig>();
+  if (!zebra_conf)
+    {
+      zebra_conf = new QuaggaConfig ();
+      node->AggregateObject (zebra_conf);
+    }
   GenerateConfigZebra (node);
   process.SetBinary ("build/debug/zebra");
   process.SetStackSize (1<<16);
@@ -263,8 +355,9 @@
   apps.Get(0)->SetStartTime (Seconds (1.0 + 0.01 * node->GetId ()));
   node->AddApplication (apps.Get (0));
 
+  Ptr<OspfConfig> ospf_conf = node->GetObject<OspfConfig>();
   // OSPF
-  if (m_ospfenable)
+  if (ospf_conf)
     {
       GenerateConfigOspf (node);
       process.ResetArguments ();
--- a/src/dce/helper/quagga-helper.h	Fri Nov 12 10:53:29 2010 +0900
+++ b/src/dce/helper/quagga-helper.h	Fri Nov 12 10:53:33 2010 +0900
@@ -80,6 +80,9 @@
   void SetAttribute (std::string name, const AttributeValue &value);
 
   void EnableOspf (NodeContainer nodes);
+  void EnableOspfDebug (NodeContainer nodes);
+  void EnableTdpNina (NodeContainer nodes);
+  void EnableZebraDebug (NodeContainer nodes);
 private:
   /**
    * \internal
@@ -87,7 +90,6 @@
   ApplicationContainer InstallPriv (Ptr<Node> node);
   void GenerateConfigZebra (Ptr<Node> node);
   void GenerateConfigOspf (Ptr<Node> node);
-  bool m_ospfenable;
 };
 
 } // namespace ns3