--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-stack-rework.patch Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,1054 @@
+diff -r b4f69e2ed0b3 example/simple-point-to-point-olsr.cc
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/example/simple-point-to-point-olsr.cc Thu Dec 13 12:27:12 2012 +0900
+@@ -0,0 +1,180 @@
++/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
++/*
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation;
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ *
++ */
++
++//
++// Simple example of OLSR routing over some point-to-point links
++//
++// Network topology
++//
++// n0
++// \ 5 Mb/s, 2ms
++// \ 1.5Mb/s, 10ms
++// n2 -------------------------n3---------n4
++// /
++// / 5 Mb/s, 2ms
++// n1
++//
++// - all links are point-to-point links with indicated one-way BW/delay
++// - CBR/UDP flows from n0 to n4, and from n3 to n1
++// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
++// (i.e., DataRate of 448,000 bps)
++// - DropTail queues
++// - Tracing of queues and packet receptions to file "simple-point-to-point-olsr.tr"
++
++#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/point-to-point-module.h"
++#include "ns3/applications-module.h"
++#include "ns3/olsr-helper.h"
++#include "ns3/ipv4-static-routing-helper.h"
++#include "ns3/ipv4-list-routing-helper.h"
++#include "ns3/dce-module.h"
++
++using namespace ns3;
++
++NS_LOG_COMPONENT_DEFINE ("SimplePointToPointOlsrExample");
++
++int
++main (int argc, char *argv[])
++{
++ // Users may find it convenient to turn on explicit debugging
++ // for selected modules; the below lines suggest how to do this
++#if 0
++ LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
++#endif
++
++ // Set up some default values for the simulation. Use the
++
++ Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
++ Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
++
++ //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);
++
++ // Allow the user to override any of the defaults and the above
++ // DefaultValue::Bind ()s at run-time, via command-line arguments
++ CommandLine cmd;
++ cmd.Parse (argc, argv);
++
++ // Here, we will explicitly create four nodes. In more sophisticated
++ // topologies, we could configure a node factory.
++ NS_LOG_INFO ("Create nodes.");
++ NodeContainer c;
++ c.Create (5);
++ NodeContainer n02 = NodeContainer (c.Get (0), c.Get (2));
++ NodeContainer n12 = NodeContainer (c.Get (1), c.Get (2));
++ NodeContainer n32 = NodeContainer (c.Get (3), c.Get (2));
++ NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4));
++
++ // Enable OLSR
++ NS_LOG_INFO ("Enabling OLSR Routing.");
++ OlsrHelper olsr;
++
++ Ipv4StaticRoutingHelper staticRouting;
++
++ Ipv4ListRoutingHelper list;
++ list.Add (staticRouting, 0);
++ list.Add (olsr, 10);
++
++ DceManagerHelper dceManager;
++ dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
++ "Library", StringValue ("liblinux.so"));
++ LinuxStackHelper internet;
++ internet.SetRoutingHelper (list); // has effect on the next Install ()
++ internet.Install (c);
++
++ // We create the channels first without any IP addressing information
++ NS_LOG_INFO ("Create channels.");
++ PointToPointHelper p2p;
++ p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
++ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
++ NetDeviceContainer nd02 = p2p.Install (n02);
++ NetDeviceContainer nd12 = p2p.Install (n12);
++ p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
++ p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
++ NetDeviceContainer nd32 = p2p.Install (n32);
++ NetDeviceContainer nd34 = p2p.Install (n34);
++
++ // Later, we add IP addresses.
++ NS_LOG_INFO ("Assign IP Addresses.");
++ Ipv4AddressHelper ipv4;
++ ipv4.SetBase ("10.1.1.0", "255.255.255.0");
++ Ipv4InterfaceContainer i02 = ipv4.Assign (nd02);
++
++ ipv4.SetBase ("10.1.2.0", "255.255.255.0");
++ Ipv4InterfaceContainer i12 = ipv4.Assign (nd12);
++
++ ipv4.SetBase ("10.1.3.0", "255.255.255.0");
++ Ipv4InterfaceContainer i32 = ipv4.Assign (nd32);
++
++ ipv4.SetBase ("10.1.4.0", "255.255.255.0");
++ Ipv4InterfaceContainer i34 = ipv4.Assign (nd34);
++
++ dceManager.Install (c);
++
++ // Create the OnOff application to send UDP datagrams of size
++ // 210 bytes at a rate of 448 Kb/s from n0 to n4
++ NS_LOG_INFO ("Create Applications.");
++ uint16_t port = 9; // Discard port (RFC 863)
++
++ OnOffHelper onoff ("ns3::LinuxUdpSocketFactory",
++ InetSocketAddress (i34.GetAddress (1), port));
++ onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
++ onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
++
++ ApplicationContainer apps = onoff.Install (c.Get (0));
++ apps.Start (Seconds (1.0));
++ apps.Stop (Seconds (10.0));
++
++ // Create a packet sink to receive these packets
++ PacketSinkHelper sink ("ns3::LinuxUdpSocketFactory",
++ InetSocketAddress (Ipv4Address::GetAny (), port));
++
++ apps = sink.Install (c.Get (3));
++ apps.Start (Seconds (1.0));
++ apps.Stop (Seconds (10.0));
++
++ // Create a similar flow from n3 to n1, starting at time 1.1 seconds
++ onoff.SetAttribute ("Remote",
++ AddressValue (InetSocketAddress (i12.GetAddress (0), port)));
++ apps = onoff.Install (c.Get (3));
++ apps.Start (Seconds (1.1));
++ apps.Stop (Seconds (10.0));
++
++ // Create a packet sink to receive these packets
++ apps = sink.Install (c.Get (1));
++ apps.Start (Seconds (1.1));
++ apps.Stop (Seconds (10.0));
++
++ AsciiTraceHelper ascii;
++ p2p.EnableAsciiAll (ascii.CreateFileStream ("simple-point-to-point-olsr.tr"));
++ p2p.EnablePcapAll ("simple-point-to-point-olsr");
++
++ Simulator::Stop (Seconds (30));
++
++ NS_LOG_INFO ("Run Simulation.");
++ Simulator::Run ();
++ Simulator::Destroy ();
++ NS_LOG_INFO ("Done.");
++
++ return 0;
++}
+diff -r b4f69e2ed0b3 helper/linux-stack-helper.cc
+--- a/helper/linux-stack-helper.cc Thu Dec 13 12:07:18 2012 +0900
++++ b/helper/linux-stack-helper.cc Thu Dec 13 12:27:12 2012 +0900
+@@ -19,16 +19,56 @@
+ */
+ #include "linux-stack-helper.h"
+ #include "ipv4-linux.h"
++#include "ipv6-linux.h"
+ #include "linux-socket-fd-factory.h"
+ #include "ns3/node.h"
+ #include "ns3/node-container.h"
+ #include "ns3/names.h"
++#include "ns3/ipv4-list-routing-helper.h"
++#include "ns3/ipv4-static-routing-helper.h"
++#include "ns3/ipv4-global-routing-helper.h"
+
+ namespace ns3 {
++LinuxStackHelper::LinuxStackHelper ()
++ : m_routing (0)
++{
++ Initialize ();
++}
++
++// private method called by both constructor and Reset ()
++void
++LinuxStackHelper::Initialize ()
++{
++ Ipv4StaticRoutingHelper staticRouting;
++ Ipv4GlobalRoutingHelper globalRouting;
++ Ipv4ListRoutingHelper listRouting;
++ listRouting.Add (staticRouting, 0);
++ listRouting.Add (globalRouting, -10);
++ SetRoutingHelper (listRouting);
++}
++
++LinuxStackHelper::~LinuxStackHelper ()
++{
++ delete m_routing;
++}
++
++void
++LinuxStackHelper::SetRoutingHelper (const Ipv4RoutingHelper &routing)
++{
++ delete m_routing;
++ m_routing = routing.Copy ();
++}
++
+ void
+ LinuxStackHelper::Install (Ptr<Node> node)
+ {
+ Ipv4Linux::InstallNode (node);
++ // Set routing
++ Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
++ Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
++ ipv4->SetRoutingProtocol (ipv4Routing);
++
++ Ipv6Linux::InstallNode (node);
+ }
+ void
+ LinuxStackHelper::Install (std::string nodeName)
+@@ -94,7 +134,11 @@
+ {
+ continue;
+ }
+- sock->Set (path, value);
++ // i.e., TaskManager::Current() needs it.
++ Simulator::ScheduleWithContext (node->GetId (), Seconds (0.0),
++ &LinuxSocketFdFactory::ScheduleTask, sock,
++ MakeEvent (&LinuxSocketFdFactory::Set, sock,
++ path, value));
+ }
+ }
+
+diff -r b4f69e2ed0b3 helper/linux-stack-helper.h
+--- a/helper/linux-stack-helper.h Thu Dec 13 12:07:18 2012 +0900
++++ b/helper/linux-stack-helper.h Thu Dec 13 12:27:12 2012 +0900
+@@ -27,6 +27,7 @@
+ class Node;
+ class NodeContainer;
+ class Time;
++class Ipv4RoutingHelper;
+
+ /**
+ * \brief aggregate Ipv4Linux to nodes
+@@ -40,6 +41,10 @@
+ class LinuxStackHelper
+ {
+ public:
++
++ LinuxStackHelper ();
++ ~LinuxStackHelper ();
++
+ /**
+ * Aggregate ns3::Ipv4Linux classe onto the provided node.
+ * This method will assert if called on a node that
+@@ -47,7 +52,7 @@
+ *
+ * \param nodeName The name of the node on which to install the stack.
+ */
+- static void Install (std::string nodeName);
++ void Install (std::string nodeName);
+
+ /**
+ * Aggregate ns3::Ipv4Linux classe onto the provided node.
+@@ -56,7 +61,7 @@
+ *
+ * \param node The node on which to install the stack.
+ */
+- static void Install (Ptr<Node> node);
++ void Install (Ptr<Node> node);
+
+ /**
+ * Aggregate ns3::Ipv4Linux class onto the provided node.
+@@ -66,17 +71,30 @@
+ * \param c NodeContainer that holds the set of nodes on which to install the
+ * new stacks.
+ */
+- static void Install (NodeContainer c);
++ void Install (NodeContainer c);
+
+ /**
+ * Aggregate ns3::Ipv4Linux to all nodes in the simulation
+ */
+- static void InstallAll (void);
++ void InstallAll (void);
++
++ /**
++ * \param routing a new routing helper
++ *
++ * Set the routing helper to use during Install. The routing
++ * helper is really an object factory which is used to create
++ * an object of type ns3::Ipv4RoutingProtocol per node. This routing
++ * object is then associated to a single ns3::Ipv4 object through its
++ * ns3::Ipv4::SetRoutingProtocol.
++ */
++ void SetRoutingHelper (const Ipv4RoutingHelper &routing);
+
+ void SysctlSet (NodeContainer c, std::string path, std::string value);
+ static void SysctlGet (Ptr<Node> node, Time at, std::string path,
+ void (*callback)(std::string, std::string));
+ private:
++ void Initialize ();
++ const Ipv4RoutingHelper *m_routing;
+ static void SysctlGetCallback (Ptr<Node> node, std::string path,
+ void (*callback)(std::string, std::string));
+
+diff -r b4f69e2ed0b3 model/linux/ipv6-linux.cc
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/model/linux/ipv6-linux.cc Thu Dec 13 12:27:12 2012 +0900
+@@ -0,0 +1,397 @@
++/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
++/*
++ * Copyright (c) 2012 INRIA
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation;
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ *
++ * Author: Frédéric Urbani
++ * Hajime Tazaki <tazaki@nict.go.jp>
++ */
++
++#include "ipv6-linux.h"
++#include "ns3/log.h"
++#include "ns3/node.h"
++#include "ns3/ipv6-list-routing-helper.h"
++#include "ns3/ipv6-static-routing-helper.h"
++//#include "ns3/ipv6-global-routing-helper.h"
++#include "ns3/ipv6-interface.h"
++//#include "linux-dccp6-socket-factory-impl.h"
++
++NS_LOG_COMPONENT_DEFINE ("Ipv6Linux");
++
++namespace ns3 {
++
++NS_OBJECT_ENSURE_REGISTERED (Ipv6Linux);
++
++TypeId
++Ipv6Linux::GetTypeId (void)
++{
++ static TypeId tid = TypeId ("ns3::Ipv6Linux")
++ .SetParent<Ipv6> ()
++ .AddConstructor<Ipv6Linux> ();
++
++ return tid;
++}
++
++Ipv6Linux::Ipv6Linux()
++{
++ NS_LOG_FUNCTION (this);
++}
++
++Ipv6Linux::~Ipv6Linux ()
++{
++ NS_LOG_FUNCTION (this);
++}
++
++void
++Ipv6Linux::SetRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol)
++{
++ NS_LOG_FUNCTION (this);
++ m_routingProtocol = routingProtocol;
++ m_routingProtocol->SetIpv6 (this);
++}
++
++Ptr<Ipv6RoutingProtocol>
++Ipv6Linux::GetRoutingProtocol (void) const
++{
++ NS_LOG_FUNCTION (this);
++ return m_routingProtocol;
++}
++
++uint32_t
++Ipv6Linux::AddInterface (Ptr<NetDevice> device)
++{
++ NS_LOG_FUNCTION (this << &device);
++
++ Ptr<Ipv6Interface> interface = CreateObject<Ipv6Interface> ();
++ interface->SetDevice (device);
++ interface->SetForwarding (m_ipForward);
++ return AddIpv6Interface (interface);
++}
++uint32_t
++Ipv6Linux::AddIpv6Interface (Ptr<Ipv6Interface>interface)
++{
++ NS_LOG_FUNCTION (this << interface);
++ uint32_t index = m_interfaces.size ();
++ m_interfaces.push_back (interface);
++ return index;
++}
++
++uint32_t
++Ipv6Linux::GetNInterfaces (void) const
++{
++ NS_LOG_FUNCTION (this);
++ return m_interfaces.size ();
++}
++
++int32_t
++Ipv6Linux::GetInterfaceForAddress (Ipv6Address address) const
++{
++ NS_LOG_FUNCTION (this);
++
++ int32_t interface = 0;
++ for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin ();
++ i != m_interfaces.end ();
++ i++, interface++)
++ {
++ for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
++ {
++ if ((*i)->GetAddress (j).GetAddress () == address)
++ {
++ return interface;
++ }
++ }
++ }
++
++ return -1;
++}
++
++void
++Ipv6Linux::Send (Ptr<Packet> packet, Ipv6Address source,
++ Ipv6Address destination, uint8_t protocol, Ptr<Ipv6Route> route)
++{
++ NS_LOG_FUNCTION (this << "empty method.");
++}
++
++void
++Ipv6Linux::SendWithHeader (Ptr<Packet> packet, Ipv6Header ipHeader, Ptr<Ipv6Route> route)
++{
++ NS_LOG_FUNCTION (this << "empty method.");
++}
++
++#if 0
++void
++Ipv6Linux::Insert (Ptr<IpL4Protocol> protocol)
++{
++ NS_LOG_FUNCTION (this << "empty method.");
++}
++#endif
++
++
++int32_t
++Ipv6Linux::GetInterfaceForPrefix (Ipv6Address address, Ipv6Prefix mask) const
++{
++ NS_LOG_FUNCTION (this);
++ int32_t interface = 0;
++ for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin ();
++ i != m_interfaces.end ();
++ i++, interface++)
++ {
++ for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
++ {
++ if ((*i)->GetAddress (j).GetAddress ().CombinePrefix (mask) == address.CombinePrefix (mask))
++ {
++ return interface;
++ }
++ }
++ }
++
++ return -1;
++}
++
++Ptr<NetDevice>
++Ipv6Linux::GetNetDevice (uint32_t i)
++{
++ NS_LOG_FUNCTION (this);
++ return GetInterface (i)->GetDevice ();
++}
++
++int32_t
++Ipv6Linux::GetInterfaceForDevice (Ptr<const NetDevice> device) const
++{
++ NS_LOG_FUNCTION (this);
++ int32_t interface = 0;
++ for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin ();
++ i != m_interfaces.end ();
++ i++, interface++)
++ {
++ if ((*i)->GetDevice () == device)
++ {
++ return interface;
++ }
++ }
++
++ return -1;
++}
++
++bool
++Ipv6Linux::AddAddress (uint32_t i, Ipv6InterfaceAddress address)
++{
++ NS_LOG_FUNCTION (this << i << address);
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ bool retVal = interface->AddAddress (address);
++ if (m_routingProtocol != 0)
++ {
++ m_routingProtocol->NotifyAddAddress (i, address);
++ }
++ return retVal;
++}
++
++uint32_t
++Ipv6Linux::GetNAddresses (uint32_t interface) const
++{
++ Ptr<Ipv6Interface> iface = GetInterface (interface);
++ return iface->GetNAddresses ();
++}
++
++Ipv6InterfaceAddress
++Ipv6Linux::GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const
++{
++ NS_LOG_FUNCTION (this);
++ Ptr<Ipv6Interface> interface = GetInterface (interfaceIndex);
++ return interface->GetAddress (addressIndex);
++}
++
++bool
++Ipv6Linux::RemoveAddress (uint32_t i, uint32_t addressIndex)
++{
++ NS_LOG_FUNCTION (this << i << addressIndex);
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ Ipv6InterfaceAddress address = interface->RemoveAddress (addressIndex);
++ if (address != Ipv6InterfaceAddress ())
++ {
++ if (m_routingProtocol != 0)
++ {
++ m_routingProtocol->NotifyRemoveAddress (i, address);
++ }
++ return true;
++ }
++ return false;
++}
++
++void
++Ipv6Linux::SetMetric (uint32_t i, uint16_t metric)
++{
++ NS_LOG_FUNCTION (this << i << metric);
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ interface->SetMetric (metric);
++}
++
++uint16_t
++Ipv6Linux::GetMetric (uint32_t i) const
++{
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ return interface->GetMetric ();
++}
++
++uint16_t
++Ipv6Linux::GetMtu (uint32_t i) const
++{
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ return interface->GetDevice ()->GetMtu ();
++}
++
++bool
++Ipv6Linux::IsUp (uint32_t i) const
++{
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ return interface->IsUp ();
++}
++
++void
++Ipv6Linux::SetUp (uint32_t i)
++{
++ NS_LOG_FUNCTION (this << i);
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ interface->SetUp ();
++
++ if (m_routingProtocol != 0)
++ {
++ m_routingProtocol->NotifyInterfaceUp (i);
++ }
++}
++
++void
++Ipv6Linux::SetDown (uint32_t ifaceIndex)
++{
++ NS_LOG_FUNCTION (this << ifaceIndex);
++ Ptr<Ipv6Interface> interface = GetInterface (ifaceIndex);
++ interface->SetDown ();
++
++ if (m_routingProtocol != 0)
++ {
++ m_routingProtocol->NotifyInterfaceDown (ifaceIndex);
++ }
++}
++
++bool
++Ipv6Linux::IsForwarding (uint32_t i) const
++{
++ NS_LOG_FUNCTION (this << i);
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ NS_LOG_LOGIC ("Forwarding state: " << interface->IsForwarding ());
++ return interface->IsForwarding ();
++}
++
++void
++Ipv6Linux::SetForwarding (uint32_t i, bool val)
++{
++ NS_LOG_FUNCTION (this << i);
++ Ptr<Ipv6Interface> interface = GetInterface (i);
++ interface->SetForwarding (val);
++}
++
++void
++Ipv6Linux::SetIpForward (bool forward)
++{
++ NS_LOG_FUNCTION (this << forward);
++ m_ipForward = forward;
++ for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
++ {
++ (*i)->SetForwarding (forward);
++ }
++}
++
++bool
++Ipv6Linux::GetIpForward (void) const
++{
++ return m_ipForward;
++}
++
++void
++Ipv6Linux::SetWeakEsModel (bool model)
++{
++ m_weakEsModel = model;
++}
++
++bool
++Ipv6Linux::GetWeakEsModel (void) const
++{
++ return m_weakEsModel;
++}
++
++void
++Ipv6Linux::InstallNode (Ptr<Node> node)
++{
++ ObjectFactory factory;
++ factory.SetTypeId ("ns3::Ipv6Linux");
++ Ptr<Object> protocol = factory.Create <Object> ();
++ node->AggregateObject (protocol);
++ // Set routing
++ Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
++ Ipv6ListRoutingHelper listRoutingv6;
++ Ipv6StaticRoutingHelper staticRoutingv6;
++ listRoutingv6.Add (staticRoutingv6, 0);
++ Ptr<Ipv6RoutingProtocol> ipv6Routing = listRoutingv6.Create (node);
++ ipv6->SetRoutingProtocol (ipv6Routing);
++ // Socket related stuff
++ // Ptr<LinuxDccp6SocketFactoryImpl> dccpFactory = CreateObject<LinuxDccp6SocketFactoryImpl> ();
++ // node->AggregateObject (dccpFactory);
++}
++Ptr<Ipv6Interface>
++Ipv6Linux::GetInterface (uint32_t index) const
++{
++ if (index < m_interfaces.size ())
++ {
++ return m_interfaces[index];
++ }
++ return 0;
++}
++
++#if 0
++Ptr<IpL4Protocol>
++Ipv6Linux::GetProtocol (int protocolNumber) const
++{
++ return 0;
++}
++#endif
++
++Ptr<Socket>
++Ipv6Linux::CreateRawSocket (void)
++{
++ return 0;
++}
++
++/**
++ * Do nothing
++ */
++void
++Ipv6Linux::DeleteRawSocket (Ptr<Socket> socket)
++{
++
++}
++
++void
++Ipv6Linux::RegisterExtensions ()
++{
++ NS_ASSERT (0);
++}
++
++void
++Ipv6Linux::RegisterOptions ()
++{
++ NS_ASSERT (0);
++}
++
++}
+diff -r b4f69e2ed0b3 model/linux/ipv6-linux.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/model/linux/ipv6-linux.h Thu Dec 13 12:27:12 2012 +0900
+@@ -0,0 +1,280 @@
++/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
++/*
++ * Copyright (c) 2012 INRIA
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation;
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ *
++ * Author: Frédéric Urbani
++ */
++
++#ifndef IPV6_LINUX_H
++#define IPV6_LINUX_H
++
++#include "ns3/ipv6.h"
++#include "ns3/ipv6-routing-protocol.h"
++
++namespace ns3 {
++class Ipv6Interface;
++
++/**
++ * \brief This implementation of Ipv6 for nodes using a real Linux Stack.
++ *
++ * The main goal of this class is not to do the stack job which is done by the real code ....
++ * but it is used to not redo the wheel and in particular to be able to reuse these 2 standards NS-3 Helpers for two tasks:
++ * 1 - assign address to devices using Ipv6AddressHelper,
++ * 2 - create the static routes using Ipv6GlobalRoutingHelper
++ *
++ */
++class Ipv6Linux : public Ipv6
++{
++public:
++ static TypeId GetTypeId (void);
++ Ipv6Linux ();
++ virtual ~Ipv6Linux ();
++
++ /**
++ * \brief Register a new routing protocol to be used by this Ipv6 stack
++ *
++ * This call will replace any routing protocol that has been previously
++ * registered. If you want to add multiple routing protocols, you must
++ * add them to a Ipv6ListRoutingProtocol directly.
++ *
++ * \param routingProtocol smart pointer to Ipv6RoutingProtocol object
++ */
++ virtual void SetRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol);
++
++ /**
++ * \brief Get the routing protocol to be used by this Ipv6 stack
++ *
++ * \returns smart pointer to Ipv6RoutingProtocol object, or null pointer if none
++ */
++ virtual Ptr<Ipv6RoutingProtocol> GetRoutingProtocol (void) const;
++
++ /**
++ * \param device device to add to the list of Ipv6 interfaces
++ * which can be used as output interfaces during packet forwarding.
++ * \returns the index of the Ipv6 interface added.
++ *
++ * Once a device has been added, it can never be removed: if you want
++ * to disable it, you can invoke Ipv6::SetDown which will
++ * make sure that it is never used during packet forwarding.
++ */
++ virtual uint32_t AddInterface (Ptr<NetDevice> device);
++
++ /**
++ * \returns the number of interfaces added by the user.
++ */
++ virtual uint32_t GetNInterfaces (void) const;
++
++ /**
++ * \brief Return the interface number of the interface that has been
++ * assigned the specified IP address.
++ *
++ * \param address The IP address being searched for
++ * \returns The interface number of the Ipv6 interface with the given
++ * address or -1 if not found.
++ *
++ * Each IP interface has one or more IP addresses associated with it.
++ * This method searches the list of interfaces for one that holds a
++ * particular address. This call takes an IP address as a parameter and
++ * returns the interface number of the first interface that has been assigned
++ * that address, or -1 if not found. There must be an exact match; this
++ * method will not match broadcast or multicast addresses.
++ */
++ virtual int32_t GetInterfaceForAddress (Ipv6Address address) const;
++
++ /**
++ * Do nothing
++ */
++ virtual void Send (Ptr<Packet> packet, Ipv6Address source,
++ Ipv6Address destination, uint8_t protocol, Ptr<Ipv6Route> route);
++
++ /**
++ * Do nothing
++ */
++ virtual void SendWithHeader (Ptr<Packet> packet, Ipv6Header ipHeader, Ptr<Ipv6Route> route);
++
++ /**
++ * Do nothing
++ */
++ // virtual void Insert (Ptr<IpL4Protocol> protocol);
++
++ /**
++ * \brief Return the interface number of first interface found that
++ * has an Ipv6 address within the prefix specified by the input
++ * address and mask parameters
++ *
++ * \param address The IP address assigned to the interface of interest.
++ * \param mask The IP prefix to use in the mask
++ * \returns The interface number of the Ipv6 interface with the given
++ * address or -1 if not found.
++ *
++ * Each IP interface has one or more IP addresses associated with it.
++ * This method searches the list of interfaces for the first one found
++ * that holds an address that is included within the prefix
++ * formed by the input address and mask parameters. The value -1 is
++ * returned if no match is found.
++ */
++ virtual int32_t GetInterfaceForPrefix (Ipv6Address address,
++ Ipv6Prefix mask) const;
++
++ /**
++ * \param interface The interface number of an Ipv6 interface.
++ * \returns The NetDevice associated with the Ipv6 interface number.
++ */
++ virtual Ptr<NetDevice> GetNetDevice (uint32_t interface);
++
++ /**
++ * \param device The NetDevice for an Ipv6Interface
++ * \returns The interface number of an Ipv6 interface or -1 if not found.
++ */
++ virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
++
++ /**
++ * \param interface Interface number of an Ipv6 interface
++ * \param address Ipv6InterfaceAddress address to associate with the underlying Ipv6 interface
++ * \returns true if the operation succeeded
++ */
++ virtual bool AddAddress (uint32_t interface, Ipv6InterfaceAddress address);
++
++ /**
++ * \param interface Interface number of an Ipv6 interface
++ * \returns the number of Ipv6InterfaceAddress entries for the interface.
++ */
++ virtual uint32_t GetNAddresses (uint32_t interface) const;
++
++ /**
++ * Because addresses can be removed, the addressIndex is not guaranteed
++ * to be static across calls to this method.
++ *
++ * \param interface Interface number of an Ipv6 interface
++ * \param addressIndex index of Ipv6InterfaceAddress
++ * \returns the Ipv6InterfaceAddress associated to the interface and addressIndex
++ */
++ virtual Ipv6InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const;
++
++ /**
++ * Remove the address at addressIndex on named interface. The addressIndex
++ * for all higher indices will decrement by one after this method is called;
++ * so, for example, to remove 5 addresses from an interface i, one could
++ * call RemoveAddress (i, 0); 5 times.
++ *
++ * \param interface Interface number of an Ipv6 interface
++ * \param addressIndex index of Ipv6InterfaceAddress to remove
++ * \returns true if the operation succeeded
++ */
++ virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex);
++
++ /**
++ * \param interface The interface number of an Ipv6 interface
++ * \param metric routing metric (cost) associated to the underlying
++ * Ipv6 interface
++ */
++ virtual void SetMetric (uint32_t interface, uint16_t metric);
++
++ /**
++ * \param interface The interface number of an Ipv6 interface
++ * \returns routing metric (cost) associated to the underlying
++ * Ipv6 interface
++ */
++ virtual uint16_t GetMetric (uint32_t interface) const;
++
++ /**
++ * \param interface Interface number of Ipv6 interface
++ * \returns the Maximum Transmission Unit (in bytes) associated
++ * to the underlying Ipv6 interface
++ */
++ virtual uint16_t GetMtu (uint32_t interface) const;
++
++ /**
++ * \param interface Interface number of Ipv6 interface
++ * \returns true if the underlying interface is in the "up" state,
++ * false otherwise.
++ */
++ virtual bool IsUp (uint32_t interface) const;
++
++ /**
++ * \param interface Interface number of Ipv6 interface
++ *
++ * Set the interface into the "up" state. In this state, it is
++ * considered valid during Ipv6 forwarding.
++ */
++ virtual void SetUp (uint32_t interface);
++
++ /**
++ * \param interface Interface number of Ipv6 interface
++ *
++ * Set the interface into the "down" state. In this state, it is
++ * ignored during Ipv6 forwarding.
++ */
++ virtual void SetDown (uint32_t interface);
++
++ /**
++ * \param interface Interface number of Ipv6 interface
++ * \returns true if IP forwarding enabled for input datagrams on this device
++ */
++ virtual bool IsForwarding (uint32_t interface) const;
++
++ /**
++ * \param interface Interface number of Ipv6 interface
++ * \param val Value to set the forwarding flag
++ *
++ * If set to true, IP forwarding is enabled for input datagrams on this device
++ */
++ virtual void SetForwarding (uint32_t interface, bool val);
++
++ /**
++ * Do nothing
++ */
++ // virtual Ptr<IpL4Protocol> GetProtocol (int protocolNumber) const ;
++
++ /**
++ * Do nothing
++ */
++ virtual Ptr<Socket> CreateRawSocket (void);
++
++ /**
++ * Do nothing
++ */
++ virtual void DeleteRawSocket (Ptr<Socket> socket);
++
++ static void InstallNode (Ptr<Node> node);
++
++ /**
++ * \brief Register the IPv6 Extensions.
++ */
++ virtual void RegisterExtensions ();
++
++ /**
++ * \brief Register the IPv6 Options.
++ */
++ virtual void RegisterOptions ();
++
++private:
++ // Indirect the Ipv6 attributes through private pure virtual methods
++ virtual void SetIpForward (bool forward);
++ virtual bool GetIpForward (void) const;
++ virtual void SetWeakEsModel (bool model);
++ virtual bool GetWeakEsModel (void) const;
++ uint32_t AddIpv6Interface (Ptr<Ipv6Interface> interface);
++ Ptr<Ipv6Interface> GetInterface (uint32_t i) const;
++
++ typedef std::vector<Ptr<Ipv6Interface> > Ipv6InterfaceList;
++ Ptr<Ipv6RoutingProtocol> m_routingProtocol;
++ bool m_ipForward;
++ bool m_weakEsModel;
++ Ipv6InterfaceList m_interfaces;
++};
++}
++#endif // IPV6_LINUX_H
+diff -r b4f69e2ed0b3 wscript
+--- a/wscript Thu Dec 13 12:07:18 2012 +0900
++++ b/wscript Thu Dec 13 12:27:12 2012 +0900
+@@ -35,7 +35,7 @@
+ ns3waf.check_modules(conf, ['wifi', 'point-to-point', 'csma', 'mobility'], mandatory = False)
+ ns3waf.check_modules(conf, ['point-to-point-layout'], mandatory = False)
+ ns3waf.check_modules(conf, ['mpi'], mandatory = False)
+- ns3waf.check_modules(conf, ['applications'], mandatory = False)
++ ns3waf.check_modules(conf, ['applications', 'olsr'], mandatory = False)
+ conf.check_tool('compiler_cc')
+ conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H', mandatory=False)
+ conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H', mandatory=False)
+@@ -281,6 +281,10 @@
+ target='bin/dce-tcp-ns3-nsc-comparison',
+ source=['example/dce-tcp-ns3-nsc-comparison.cc'])
+
++ module.add_example(needed = ['point-to-point', 'internet', 'olsr', 'applications', 'wifi', 'dce'],
++ target='bin/simple-point-to-point-olsr',
++ source=['example/simple-point-to-point-olsr.cc'])
++
+ # Add a script to build system
+ def build_a_script(bld, name, needed = [], **kw):
+ external = [i for i in needed if not i == name]
+@@ -395,6 +399,7 @@
+ 'model/dce-at.cc',
+ 'model/exec-utils.cc',
+ 'model/linux/ipv4-linux.cc',
++ 'model/linux/ipv6-linux.cc',
+ 'model/dce-vfs.cc',
+ 'model/elf-ldd.cc',
+ 'model/dce-termio.cc',
+@@ -423,6 +428,7 @@
+ 'model/dce-application.h',
+ 'model/ipv4-dce-routing.h',
+ 'model/linux/ipv4-linux.h',
++ 'model/linux/ipv6-linux.h',
+ 'model/process-delay-model.h',
+ 'model/linux/linux-socket-impl.h',
+ 'model/linux/linux-ipv4-raw-socket-factory.h',