second phase of IPv6 checkins from Univ. of Strasbourg team
authorSebastien Vincent <vincent@clarinet.u-strasbg.fr>
Sat Aug 22 14:36:55 2009 -0700 (5 months ago)
changeset 4731510db8599bfb
parent 4730 e433617c8376
child 4732 5ea754089561
second phase of IPv6 checkins from Univ. of Strasbourg team
AUTHORS
CHANGES.html
RELEASE_NOTES
examples/icmpv6-redirect.cc
examples/ping6.cc
examples/radvd-two-prefix.cc
examples/radvd.cc
examples/simple-routing-ping6.cc
examples/wscript
src/applications/ping6/ping6.cc
src/applications/ping6/ping6.h
src/applications/ping6/waf
src/applications/ping6/wscript
src/applications/radvd/radvd-interface.cc
src/applications/radvd/radvd-interface.h
src/applications/radvd/radvd-prefix.cc
src/applications/radvd/radvd-prefix.h
src/applications/radvd/radvd.cc
src/applications/radvd/radvd.h
src/applications/radvd/wscript
src/helper/internet-stack-helper.cc
src/helper/internet-stack-helper.h
src/helper/ipv6-address-helper.cc
src/helper/ipv6-address-helper.h
src/helper/ipv6-interface-container.cc
src/helper/ipv6-interface-container.h
src/helper/ipv6-list-routing-helper.cc
src/helper/ipv6-list-routing-helper.h
src/helper/ipv6-routing-helper.cc
src/helper/ipv6-routing-helper.h
src/helper/ipv6-static-routing-helper.cc
src/helper/ipv6-static-routing-helper.h
src/helper/ping6-helper.cc
src/helper/ping6-helper.h
src/helper/wscript
src/internet-stack/icmpv6-header.cc
src/internet-stack/icmpv6-header.h
src/internet-stack/icmpv6-l4-protocol.cc
src/internet-stack/icmpv6-l4-protocol.h
src/internet-stack/ipv6-autoconfigured-prefix.cc
src/internet-stack/ipv6-autoconfigured-prefix.h
src/internet-stack/ipv6-end-point-demux.cc
src/internet-stack/ipv6-end-point-demux.h
src/internet-stack/ipv6-end-point.cc
src/internet-stack/ipv6-end-point.h
src/internet-stack/ipv6-interface.cc
src/internet-stack/ipv6-interface.h
src/internet-stack/ipv6-l3-protocol.cc
src/internet-stack/ipv6-l3-protocol.h
src/internet-stack/ipv6-l4-protocol.cc
src/internet-stack/ipv6-l4-protocol.h
src/internet-stack/ipv6-raw-socket-factory-impl.cc
src/internet-stack/ipv6-raw-socket-factory-impl.h
src/internet-stack/ipv6-raw-socket-impl.cc
src/internet-stack/ipv6-raw-socket-impl.h
src/internet-stack/ipv6-test.cc
src/internet-stack/ndisc-cache.cc
src/internet-stack/ndisc-cache.h
src/internet-stack/wscript
src/node/inet6-socket-address.cc
src/node/ipv6-address.cc
src/node/ipv6-address.h
src/node/ipv6-header.cc
src/node/ipv6-header.h
src/node/ipv6-interface-address.cc
src/node/ipv6-interface-address.h
src/node/ipv6-raw-socket-factory.cc
src/node/ipv6-raw-socket-factory.h
src/node/ipv6-route.cc
src/node/ipv6-route.h
src/node/ipv6-routing-protocol.cc
src/node/ipv6-routing-protocol.h
src/node/ipv6.cc
src/node/ipv6.h
src/node/wscript
src/routing/list-routing/ipv6-list-routing.cc
src/routing/list-routing/ipv6-list-routing.h
src/routing/list-routing/wscript
src/routing/static-routing/ipv6-routing-table-entry.cc
src/routing/static-routing/ipv6-routing-table-entry.h
src/routing/static-routing/ipv6-static-routing.cc
src/routing/static-routing/ipv6-static-routing.h
src/routing/static-routing/wscript
src/wscript
     1.1 --- a/AUTHORS	Sun Aug 23 14:00:50 2009 -0700
     1.2 +++ b/AUTHORS	Sat Aug 22 14:36:55 2009 -0700
     1.3 @@ -26,6 +26,6 @@
     1.4  Providence Salumu Munga (Providence.Salumu@gmail.com, Providence.Salumu_Munga@it-sudparis.eu)
     1.5  Kulin Shah (m.kulin@gmail.com)
     1.6  Mauro Tortonesi (mauro.tortonesi@unife.it)
     1.7 -Sebastien Vincent (vincent@lsiit.u-strasbg.fr)
     1.8 +Sebastien Vincent (vincent@clarinet.u-strasbg.fr)
     1.9  Guillaume Vu-Brugier (gvubrugier@gmail.com)
    1.10  Florian Westphal (fw@strlen.de)
     2.1 --- a/CHANGES.html	Sun Aug 23 14:00:50 2009 -0700
     2.2 +++ b/CHANGES.html	Sat Aug 22 14:36:55 2009 -0700
     2.3 @@ -52,6 +52,18 @@
     2.4  
     2.5  <h2>New API:</h2>
     2.6  <ul>
     2.7 +<li><b> IPv6 additions</b>
     2.8 +<p> Add an IPv6 protocol and ICMPv6 capability.
     2.9 +<ul>
    2.10 +<li> new classes Ipv6, Ipv6Interface, Ipv6L3Protocol, Ipv6L4Protocol
    2.11 +<li> Ipv6RawSocket (no UDP or TCP capability yet)
    2.12 +<li> a set of classes to implement Icmpv6, including neighbor discovery,
    2.13 +router solicitation, DAD
    2.14 +<li> new applications Ping6 and Radvd
    2.15 +<li> routing objects Ipv6Route and Ipv6MulticastRoute
    2.16 +<li> routing protocols Ipv6ListRouting and Ipv6StaticRouting
    2.17 +<li> examples: icmpv6-redirect.cc, ping6.cc, radvd.cc, radvd-two-prefix.cc, simple-routing-ping6.cc
    2.18 +</ul> 
    2.19  </ul>
    2.20  
    2.21  <h2>Changes to existing API:</h2>
     3.1 --- a/RELEASE_NOTES	Sun Aug 23 14:00:50 2009 -0700
     3.2 +++ b/RELEASE_NOTES	Sat Aug 22 14:36:55 2009 -0700
     3.3 @@ -30,13 +30,26 @@
     3.4  New user-visible features
     3.5  -------------------------
     3.6  
     3.7 -  - Add an implementation of the minstrel rate control algorithm 
     3.8 -    (Duy Nguyen for gsoc)
     3.9 -
    3.10 +  a) Add an implementation of the minstrel rate control algorithm 
    3.11 +     (Duy Nguyen for gsoc)
    3.12 +  
    3.13 +  b) IPv6 models:
    3.14 +    - IPv6 interface;
    3.15 +    - IPv6 layer;
    3.16 +    - IPv6 raw socket;
    3.17 +    - Static IPv6 routing;
    3.18 +    - ICMPv6 layer;
    3.19 +    - Some ICMPv6 error messages (destination unreachable, ...);
    3.20 +    - Neighbor Discovery Protocol (NS/NA, RS/RA, redirection);
    3.21 +    - Ping6 application (send Echo request);
    3.22 +    - Radvd application (send RA);
    3.23 +    - Examples (ping6, simple-routing-ping6, radvd, radvd-two-prefix,
    3.24 +      icmpv6-redirect).
    3.25 + 
    3.26   
    3.27  API changes from ns-3.5
    3.28  -----------------------
    3.29 -API changes for this release are documented in the file CHANGES.html.  
    3.30 +API changes for this release are documented in the file CHANGES.html. 
    3.31  XXX
    3.32  
    3.33  Known issues
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/examples/icmpv6-redirect.cc	Sat Aug 22 14:36:55 2009 -0700
     4.3 @@ -0,0 +1,176 @@
     4.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     4.5 +/*
     4.6 + * Copyright (c) 2009 Strasbourg University
     4.7 + *
     4.8 + * This program is free software; you can redistribute it and/or modify
     4.9 + * it under the terms of the GNU General Public License version 2 as
    4.10 + * published by the Free Software Foundation;
    4.11 + *
    4.12 + * This program is distributed in the hope that it will be useful,
    4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.15 + * GNU General Public License for more details.
    4.16 + *
    4.17 + * You should have received a copy of the GNU General Public License
    4.18 + * along with this program; if not, write to the Free Software
    4.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    4.20 + *
    4.21 + * Author: David Gross <david.gross@eturs.u-strasbg.fr>
    4.22 + */
    4.23 +
    4.24 +// Network topology
    4.25 +//
    4.26 +//             STA2
    4.27 +//              |
    4.28 +//              |
    4.29 +//   R1         R2
    4.30 +//   |          |
    4.31 +//   |          |
    4.32 +//   ------------
    4.33 +//           |
    4.34 +//           |
    4.35 +//          STA 1
    4.36 +//
    4.37 +// - Initial configuration :
    4.38 +//         - STA1 default route : R1
    4.39 +//         - R1 static route to STA2 : R2
    4.40 +//         - STA2 default route : R2
    4.41 +// - STA1 send Echo Request to STA2 using its default route to R1
    4.42 +// - R1 receive Echo Request from STA1, and forward it to R2
    4.43 +// - R1 send an ICMPv6 Redirection to STA1 with Target STA2 and Destination R2
    4.44 +// - Next Echo Request from STA1 to STA2 are directly sent to R2
    4.45 +
    4.46 +#include <fstream>
    4.47 +#include "ns3/core-module.h"
    4.48 +#include "ns3/simulator-module.h"
    4.49 +#include "ns3/helper-module.h"
    4.50 +
    4.51 +#include "ns3/ipv6-routing-table-entry.h"
    4.52 +
    4.53 +using namespace ns3;
    4.54 +
    4.55 +NS_LOG_COMPONENT_DEFINE ("Icmpv6RedirectExample");
    4.56 +
    4.57 +class StackHelper
    4.58 +{
    4.59 +  public:
    4.60 +    /**
    4.61 +     * \brief Print the routing table.
    4.62 +     * \param n the node
    4.63 +     */
    4.64 +    inline void PrintRoutingTable (Ptr<Node>& n)
    4.65 +    {
    4.66 +      Ptr<Ipv6StaticRouting> routing = 0;
    4.67 +      Ipv6StaticRoutingHelper routingHelper;
    4.68 +      Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
    4.69 +      uint32_t nbRoutes = 0;
    4.70 +      Ipv6RoutingTableEntry route;
    4.71 +
    4.72 +      routing = routingHelper.GetStaticRouting (ipv6);
    4.73 +
    4.74 +      std::cout << "Routing table of " << n << " : " << std::endl;
    4.75 +      std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << std::endl;
    4.76 +
    4.77 +      nbRoutes = routing->GetNRoutes ();
    4.78 +      for(uint32_t i = 0 ; i < nbRoutes ; i++)
    4.79 +      {
    4.80 +        route = routing->GetRoute (i);
    4.81 +        std::cout << route.GetDest () << "\t"
    4.82 +          << route.GetGateway () << "\t"
    4.83 +          << route.GetInterface () << "\t" << std::endl;
    4.84 +      }
    4.85 +    }
    4.86 +
    4.87 +    inline void AddHostRouteTo (Ptr<Node>& n, Ipv6Address dst, Ipv6Address nextHop, uint32_t interface)
    4.88 +    {
    4.89 +      Ptr<Ipv6StaticRouting> routing = 0;
    4.90 +      Ipv6StaticRoutingHelper routingHelper;
    4.91 +      Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
    4.92 +
    4.93 +      routing = routingHelper.GetStaticRouting (ipv6);
    4.94 +
    4.95 +      routing->AddHostRouteTo (dst, nextHop, interface);
    4.96 +    }
    4.97 +};
    4.98 +
    4.99 +
   4.100 +int main (int argc, char **argv)
   4.101 +{
   4.102 +#if 0 
   4.103 +  LogComponentEnable ("Icmpv6RedirectExample", LOG_LEVEL_INFO);
   4.104 +  LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_INFO);
   4.105 +  LogComponentEnable("Ipv6L3Protocol", LOG_LEVEL_ALL);
   4.106 +  LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL);
   4.107 +  LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL);
   4.108 +  LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL);
   4.109 +  LogComponentEnable("NdiscCache", LOG_LEVEL_ALL);
   4.110 +#endif
   4.111 +
   4.112 +  CommandLine cmd;
   4.113 +  cmd.Parse (argc, argv);
   4.114 +
   4.115 +  NS_LOG_INFO ("Create nodes.");
   4.116 +  Ptr<Node> sta1 = CreateObject<Node> ();
   4.117 +  Ptr<Node> r1 = CreateObject<Node> ();
   4.118 +  Ptr<Node> r2 = CreateObject<Node> ();
   4.119 +  Ptr<Node> sta2 = CreateObject<Node> ();
   4.120 +  NodeContainer net1(sta1, r1, r2);
   4.121 +  NodeContainer net2(r2, sta2);
   4.122 +  NodeContainer all(sta1, r1, r2, sta2);
   4.123 +
   4.124 +  StackHelper stackHelper;
   4.125 +  
   4.126 +  InternetStackHelper internetv6;
   4.127 +  internetv6.Install (all);
   4.128 +
   4.129 +  NS_LOG_INFO ("Create channels.");
   4.130 +  CsmaHelper csma;
   4.131 +  csma.SetChannelAttribute ("DataRate", DataRateValue(5000000));
   4.132 +  csma.SetChannelAttribute ("Delay", TimeValue(MilliSeconds (2)));
   4.133 +  NetDeviceContainer ndc1 = csma.Install (net1); 
   4.134 +  NetDeviceContainer ndc2 = csma.Install (net2);
   4.135 +
   4.136 +  NS_LOG_INFO ("Assign IPv6 Addresses.");
   4.137 +  Ipv6AddressHelper ipv6;
   4.138 +
   4.139 +  ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
   4.140 +  Ipv6InterfaceContainer iic1 = ipv6.Assign (ndc1);
   4.141 +  iic1.SetRouter (2, true);
   4.142 +  iic1.SetRouter (1, true);
   4.143 +
   4.144 +  ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
   4.145 +  Ipv6InterfaceContainer iic2 = ipv6.Assign (ndc2);
   4.146 +  iic2.SetRouter (0, true);
   4.147 +
   4.148 +  stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 1), iic1.GetInterfaceIndex (1));
   4.149 +  
   4.150 +  Simulator::Schedule(Seconds(0.0), &StackHelper::PrintRoutingTable, &stackHelper, r1);
   4.151 +  Simulator::Schedule(Seconds(3.0), &StackHelper::PrintRoutingTable, &stackHelper, sta1);
   4.152 +
   4.153 +  NS_LOG_INFO ("Create Applications.");
   4.154 +  uint32_t packetSize = 1024;
   4.155 +  uint32_t maxPacketCount = 5;
   4.156 +  Time interPacketInterval = Seconds (1.);
   4.157 +  Ping6Helper ping6;
   4.158 +
   4.159 +  ping6.SetLocal (iic1.GetAddress(0, 1));
   4.160 +  ping6.SetRemote (iic2.GetAddress(1, 1));
   4.161 +  ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
   4.162 +  ping6.SetAttribute ("Interval", TimeValue(interPacketInterval));
   4.163 +  ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
   4.164 +  ApplicationContainer apps = ping6.Install (sta1);
   4.165 +  apps.Start (Seconds (2.0));
   4.166 +  apps.Stop (Seconds (10.0));
   4.167 +
   4.168 +  std::ofstream ascii;
   4.169 +  ascii.open ("icmpv6-redirect.tr");
   4.170 +  CsmaHelper::EnablePcapAll ("icmpv6-redirect", true);
   4.171 +  CsmaHelper::EnableAsciiAll (ascii);
   4.172 +
   4.173 +  /* Now, do the actual simulation. */
   4.174 +  NS_LOG_INFO ("Run Simulation.");
   4.175 +  Simulator::Run ();
   4.176 +  Simulator::Destroy ();
   4.177 +  NS_LOG_INFO ("Done.");
   4.178 +}
   4.179 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/examples/ping6.cc	Sat Aug 22 14:36:55 2009 -0700
     5.3 @@ -0,0 +1,111 @@
     5.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     5.5 +/*
     5.6 + * Copyright (c) 2008-2009 Strasbourg University
     5.7 + *
     5.8 + * This program is free software; you can redistribute it and/or modify
     5.9 + * it under the terms of the GNU General Public License version 2 as
    5.10 + * published by the Free Software Foundation;
    5.11 + *
    5.12 + * This program is distributed in the hope that it will be useful,
    5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.15 + * GNU General Public License for more details.
    5.16 + *
    5.17 + * You should have received a copy of the GNU General Public License
    5.18 + * along with this program; if not, write to the Free Software
    5.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.20 + *
    5.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
    5.22 + */
    5.23 +
    5.24 +// Network topology
    5.25 +//
    5.26 +//       n0    n1  
    5.27 +//       |     |
    5.28 +//       =================
    5.29 +//              LAN
    5.30 +//
    5.31 +// - ICMPv6 echo request flows from n0 to n1 and back with ICMPv6 echo reply
    5.32 +// - DropTail queues 
    5.33 +// - Tracing of queues and packet receptions to file "ping6.tr"
    5.34 +
    5.35 +#include <fstream>
    5.36 +#include "ns3/core-module.h"
    5.37 +#include "ns3/simulator-module.h"
    5.38 +#include "ns3/helper-module.h"
    5.39 +
    5.40 +using namespace ns3;
    5.41 +
    5.42 +NS_LOG_COMPONENT_DEFINE ("Ping6Example");
    5.43 +
    5.44 +int main (int argc, char **argv)
    5.45 +{
    5.46 +#if 0 
    5.47 +  LogComponentEnable ("Ping6Example", LOG_LEVEL_INFO);
    5.48 +  LogComponentEnable ("Ipv6EndPointDemux", LOG_LEVEL_ALL);
    5.49 +  LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
    5.50 +  LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
    5.51 +  LogComponentEnable ("Ipv6ListRouting", LOG_LEVEL_ALL);
    5.52 +  LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
    5.53 +  LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
    5.54 +  LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
    5.55 +  LogComponentEnable ("NdiscCache", LOG_LEVEL_ALL);
    5.56 +#endif
    5.57 +
    5.58 +  CommandLine cmd;
    5.59 +  cmd.Parse (argc, argv);
    5.60 +  
    5.61 +  NS_LOG_INFO ("Create nodes.");
    5.62 +  NodeContainer n;
    5.63 +  n.Create (4);
    5.64 +
    5.65 +  /* Install IPv4/IPv6 stack */
    5.66 +  InternetStackHelper internetv6;
    5.67 +  internetv6.SetIpv4StackInstall (false);
    5.68 +  internetv6.Install (n);
    5.69 +
    5.70 +  NS_LOG_INFO ("Create channels.");
    5.71 +  CsmaHelper csma;
    5.72 +  csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
    5.73 +  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
    5.74 +  NetDeviceContainer d = csma.Install (n);
    5.75 +
    5.76 +  Ipv6AddressHelper ipv6;
    5.77 +  NS_LOG_INFO ("Assign IPv6 Addresses.");
    5.78 +  Ipv6InterfaceContainer i = ipv6.Assign (d);
    5.79 +
    5.80 +  NS_LOG_INFO ("Create Applications.");
    5.81 +
    5.82 +  /* Create a Ping6 application to send ICMPv6 echo request from node zero to
    5.83 +   * all-nodes (ff02::1).
    5.84 +   */
    5.85 +  uint32_t packetSize = 1024;
    5.86 +  uint32_t maxPacketCount = 5;
    5.87 +  Time interPacketInterval = Seconds (1.);
    5.88 +  Ping6Helper ping6;
    5.89 +
    5.90 +/*
    5.91 +  ping6.SetLocal (i.GetAddress (0, 1)); 
    5.92 +  ping6.SetRemote (i.GetAddress (1, 1));
    5.93 +*/
    5.94 +  ping6.SetIfIndex (i.GetInterfaceIndex (0));
    5.95 +  ping6.SetRemote (Ipv6Address::GetAllNodesMulticast ());
    5.96 +
    5.97 +  ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
    5.98 +  ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
    5.99 +  ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
   5.100 +  ApplicationContainer apps = ping6.Install (n.Get (0));
   5.101 +  apps.Start (Seconds (2.0));
   5.102 +  apps.Stop (Seconds (10.0));
   5.103 +
   5.104 +  std::ofstream ascii;
   5.105 +  ascii.open ("ping6.tr");
   5.106 +  CsmaHelper::EnablePcapAll (std::string ("ping6"), true);
   5.107 +  CsmaHelper::EnableAsciiAll (ascii);
   5.108 +
   5.109 +  NS_LOG_INFO ("Run Simulation.");
   5.110 +  Simulator::Run ();
   5.111 +  Simulator::Destroy ();
   5.112 +  NS_LOG_INFO ("Done.");
   5.113 +}
   5.114 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/examples/radvd-two-prefix.cc	Sat Aug 22 14:36:55 2009 -0700
     6.3 @@ -0,0 +1,216 @@
     6.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     6.5 +/*
     6.6 + * Copyright (c) 2009 Strasbourg University
     6.7 + *
     6.8 + * This program is free software; you can redistribute it and/or modify
     6.9 + * it under the terms of the GNU General Public License version 2 as
    6.10 + * published by the Free Software Foundation;
    6.11 + *
    6.12 + * This program is distributed in the hope that it will be useful,
    6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.15 + * GNU General Public License for more details.
    6.16 + *
    6.17 + * You should have received a copy of the GNU General Public License
    6.18 + * along with this program; if not, write to the Free Software
    6.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    6.20 + *
    6.21 + * Author: David Gross <gdavid.devel@gmail.com>
    6.22 + *         Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
    6.23 + */
    6.24 +
    6.25 +// Network topology
    6.26 +// //
    6.27 +// //             n0   R    n1
    6.28 +// //             |    _    |
    6.29 +// //             ====|_|====
    6.30 +// //                router
    6.31 +// // - R sends RA to n0's subnet (2001:1::/64 and 2001:ABCD::/64);
    6.32 +// // - R interface to n0 has two addresses with following prefixes 2001:1::/64 and 2001:ABCD::/64;
    6.33 +// // - R sends RA to n1's subnet (2001:2::/64);
    6.34 +// // - n0 ping6 n1.
    6.35 +// //
    6.36 +// // - Tracing of queues and packet receptions to file "radvd-two-prefix.tr"
    6.37 +
    6.38 +#include <fstream>
    6.39 +#include "ns3/core-module.h"
    6.40 +#include "ns3/simulator-module.h"
    6.41 +#include "ns3/helper-module.h"
    6.42 +
    6.43 +#include "ns3/ipv6-routing-table-entry.h"
    6.44 +#include "ns3/radvd.h"
    6.45 +#include "ns3/radvd-interface.h"
    6.46 +#include "ns3/radvd-prefix.h"
    6.47 +
    6.48 +using namespace ns3;
    6.49 +
    6.50 +NS_LOG_COMPONENT_DEFINE ("RadvdExample");
    6.51 +
    6.52 +class StackHelper
    6.53 +{
    6.54 +  public:
    6.55 +
    6.56 +    /**
    6.57 +     * \brief Add an address to a IPv6 node.
    6.58 +     * \param n node
    6.59 +     * \param interface interface index
    6.60 +     * \param address IPv6 address to add
    6.61 +     */
    6.62 +    inline void AddAddress (Ptr<Node>& n, uint32_t interface, Ipv6Address address)
    6.63 +    {
    6.64 +      Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
    6.65 +      ipv6->AddAddress (interface, address);
    6.66 +    }
    6.67 +
    6.68 +    /**
    6.69 +     * \brief Print the routing table.
    6.70 +     * \param n the node
    6.71 +     */
    6.72 +    inline void PrintRoutingTable (Ptr<Node>& n)
    6.73 +    {
    6.74 +      Ptr<Ipv6StaticRouting> routing = 0;
    6.75 +      Ipv6StaticRoutingHelper routingHelper;
    6.76 +      Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
    6.77 +      uint32_t nbRoutes = 0;
    6.78 +      Ipv6RoutingTableEntry route;
    6.79 +
    6.80 +      routing = routingHelper.GetStaticRouting (ipv6);
    6.81 +
    6.82 +      std::cout << "Routing table of " << n << " : " << std::endl;
    6.83 +      std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << std::endl;
    6.84 +
    6.85 +      nbRoutes = routing->GetNRoutes ();
    6.86 +      for (uint32_t i = 0 ; i < nbRoutes ; i++)
    6.87 +      {
    6.88 +        route = routing->GetRoute (i);
    6.89 +        std::cout << route.GetDest () << "\t"
    6.90 +          << route.GetGateway () << "\t"
    6.91 +          << route.GetInterface () << "\t" << std::endl;
    6.92 +      }
    6.93 +    }
    6.94 +};
    6.95 +
    6.96 +int main (int argc, char** argv)
    6.97 +{
    6.98 +#if 0 
    6.99 +  LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
   6.100 +  LogComponentEnable ("Ipv6RawSocketImpl", LOG_LEVEL_ALL);
   6.101 +  LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
   6.102 +  LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
   6.103 +  LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
   6.104 +  LogComponentEnable ("RadvdApplication", LOG_LEVEL_ALL);
   6.105 +  LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
   6.106 +#endif
   6.107 +
   6.108 +	CommandLine cmd;
   6.109 +  cmd.Parse (argc, argv);
   6.110 +  
   6.111 +	NS_LOG_INFO ("Create nodes.");
   6.112 +	Ptr<Node> n0 = CreateObject<Node> ();
   6.113 +	Ptr<Node> r = CreateObject<Node> ();
   6.114 +	Ptr<Node> n1 = CreateObject<Node> ();
   6.115 +
   6.116 +	NodeContainer net1 (n0, r);
   6.117 +	NodeContainer net2 (r, n1);
   6.118 +	NodeContainer all (n0, r, n1);
   6.119 +  StackHelper stackHelper;
   6.120 +
   6.121 +	NS_LOG_INFO ("Create IPv6 Internet Stack");
   6.122 +  InternetStackHelper internetv6;
   6.123 +  internetv6.Install (all);
   6.124 +
   6.125 +  NS_LOG_INFO ("Create channels.");
   6.126 +	CsmaHelper csma;
   6.127 +  csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
   6.128 +  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
   6.129 +	NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */
   6.130 +	NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */
   6.131 +
   6.132 +	NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
   6.133 +	Ipv6AddressHelper ipv6;
   6.134 +
   6.135 +  /* first subnet */
   6.136 +  ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
   6.137 +  NetDeviceContainer tmp;
   6.138 +  tmp.Add (d1.Get (0)); /* n0 */
   6.139 +  Ipv6InterfaceContainer iic1 = ipv6.AssignWithoutAddress (tmp); /* n0 interface */
   6.140 +
   6.141 +  NetDeviceContainer tmp2;
   6.142 +  tmp2.Add (d1.Get (1)); /* R */
   6.143 +  Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
   6.144 +  iicr1.SetRouter (0, true);
   6.145 +  iic1.Add (iicr1);
   6.146 +
   6.147 +  /* add another IPv6 address for second prefix advertised on first subnet */
   6.148 +  stackHelper.AddAddress (r, iic1.GetInterfaceIndex (1), Ipv6Address ("2001:ABCD::2"));
   6.149 +
   6.150 +  /* second subnet R - n1 */
   6.151 +  ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
   6.152 +  NetDeviceContainer tmp3;
   6.153 +  tmp3.Add (d2.Get (0)); /* R */
   6.154 +  Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
   6.155 +  iicr2.SetRouter (0, true);
   6.156 +
   6.157 +  NetDeviceContainer tmp4;
   6.158 +  tmp4.Add (d2.Get (1)); /* n1 */
   6.159 +  Ipv6InterfaceContainer iic2 = ipv6.AssignWithoutAddress (tmp4); 
   6.160 +  iic2.Add (iicr2);
   6.161 +
   6.162 +  /* radvd configuration */
   6.163 +  Ipv6Address prefix ("2001:1::0"); /* create the prefix */
   6.164 +  Ipv6Address prefixBis ("2001:ABCD::0"); /* create the prefix */
   6.165 +  Ipv6Address prefix2 ("2001:2::0"); /* create the prefix */
   6.166 +  uint32_t indexRouter = iic1.GetInterfaceIndex (1); /* R interface (n0 - R) */
   6.167 +  uint32_t indexRouter2 = iic2.GetInterfaceIndex (1); /* R interface (R - n1) */
   6.168 +  Ptr<Radvd> radvd = CreateObject<Radvd> ();
   6.169 +  Ptr<RadvdInterface> routerInterface = Create<RadvdInterface> (indexRouter, 2000, 1000);
   6.170 +  Ptr<RadvdPrefix> routerPrefix = Create<RadvdPrefix> (prefix, 64, 3, 5);
   6.171 +  Ptr<RadvdPrefix> routerPrefixBis = Create<RadvdPrefix> (prefixBis, 64, 3, 5);
   6.172 +  Ptr<RadvdInterface> routerInterface2 = Create<RadvdInterface> (indexRouter2, 2000, 1000);
   6.173 +  Ptr<RadvdPrefix> routerPrefix2 = Create<RadvdPrefix> (prefix2, 64, 3, 5);
   6.174 +
   6.175 +  /* first interface advertise two prefixes (2001:1::/64 and 2001:ABCD::/64) */
   6.176 +  /* prefix is added in the inverse order in packet */
   6.177 +  routerInterface->AddPrefix (routerPrefix);
   6.178 +  routerInterface->AddPrefix (routerPrefixBis);
   6.179 +  routerInterface2->AddPrefix (routerPrefix2);
   6.180 +  radvd->AddConfiguration (routerInterface);
   6.181 +  radvd->AddConfiguration (routerInterface2);
   6.182 +
   6.183 +  r->AddApplication (radvd);
   6.184 +  radvd->Start (Seconds (1.0));
   6.185 +  radvd->Stop (Seconds (2.0));
   6.186 +
   6.187 +  /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */
   6.188 +  uint32_t packetSize = 1024;
   6.189 +  uint32_t maxPacketCount = 8;
   6.190 +  Time interPacketInterval = Seconds (1.);
   6.191 +  Ping6Helper ping6;
   6.192 +
   6.193 +  /* ping6.SetLocal (iic1.GetAddress (0, 1)); */
   6.194 +  ping6.SetRemote (Ipv6Address ("2001:2::200:ff:fe00:4")); /* should be n1 address after autoconfiguration */
   6.195 +  ping6.SetIfIndex (iic1.GetInterfaceIndex (0));
   6.196 +
   6.197 +  ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
   6.198 +  ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
   6.199 +  ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
   6.200 +  ApplicationContainer apps = ping6.Install (net1.Get (0));
   6.201 +  apps.Start (Seconds (2.0));
   6.202 +  apps.Stop (Seconds (9.0));
   6.203 +
   6.204 +  /* RA should be received, two prefixes + routes + default route should be present */
   6.205 +  Simulator::Schedule (Seconds (2.0), &StackHelper::PrintRoutingTable, &stackHelper, n0); 
   6.206 +  /* at the end, RA addresses and routes should be cleared */
   6.207 +  Simulator::Schedule (Seconds (10.0), &StackHelper::PrintRoutingTable, &stackHelper, n0); 
   6.208 +
   6.209 +	std::ofstream ascii;
   6.210 +  ascii.open ("radvd-two-prefix.tr");
   6.211 +  CsmaHelper::EnablePcapAll (std::string ("radvd-two-prefix"), true);
   6.212 +  CsmaHelper::EnableAsciiAll (ascii);
   6.213 +
   6.214 +  NS_LOG_INFO ("Run Simulation.");
   6.215 +  Simulator::Run ();
   6.216 +  Simulator::Destroy ();
   6.217 +  NS_LOG_INFO ("Done.");
   6.218 +}
   6.219 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/examples/radvd.cc	Sat Aug 22 14:36:55 2009 -0700
     7.3 @@ -0,0 +1,156 @@
     7.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     7.5 +/*
     7.6 + * Copyright (c) 2009 Strasbourg University
     7.7 + *
     7.8 + * This program is free software; you can redistribute it and/or modify
     7.9 + * it under the terms of the GNU General Public License version 2 as
    7.10 + * published by the Free Software Foundation;
    7.11 + *
    7.12 + * This program is distributed in the hope that it will be useful,
    7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.15 + * GNU General Public License for more details.
    7.16 + *
    7.17 + * You should have received a copy of the GNU General Public License
    7.18 + * along with this program; if not, write to the Free Software
    7.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    7.20 + *
    7.21 + * Author: David Gross <gdavid.devel@gmail.com>
    7.22 + *         Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
    7.23 + */
    7.24 +
    7.25 +// Network topology
    7.26 +// //
    7.27 +// //             n0   R    n1
    7.28 +// //             |    _    |
    7.29 +// //             ====|_|====
    7.30 +// //                router
    7.31 +// // - R sends RA to n0's subnet (2001:1::/64);
    7.32 +// // - R sends RA to n1's subnet (2001:2::/64);
    7.33 +// // - n0 ping6 n1.
    7.34 +// //
    7.35 +// // - Tracing of queues and packet receptions to file "radvd.tr"
    7.36 +
    7.37 +#include <fstream>
    7.38 +#include "ns3/core-module.h"
    7.39 +#include "ns3/simulator-module.h"
    7.40 +#include "ns3/helper-module.h"
    7.41 +
    7.42 +#include "ns3/radvd.h"
    7.43 +#include "ns3/radvd-interface.h"
    7.44 +#include "ns3/radvd-prefix.h"
    7.45 +
    7.46 +using namespace ns3;
    7.47 +
    7.48 +NS_LOG_COMPONENT_DEFINE ("RadvdExample");
    7.49 +
    7.50 +int main (int argc, char** argv)
    7.51 +{
    7.52 +#if 0 
    7.53 +  LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
    7.54 +  LogComponentEnable ("Ipv6RawSocketImpl", LOG_LEVEL_ALL);
    7.55 +  LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
    7.56 +  LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
    7.57 +  LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
    7.58 +  LogComponentEnable ("RadvdApplication", LOG_LEVEL_ALL);
    7.59 +  LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
    7.60 +#endif
    7.61 +
    7.62 +	CommandLine cmd;
    7.63 +  cmd.Parse (argc, argv);
    7.64 +  
    7.65 +	NS_LOG_INFO ("Create nodes.");
    7.66 +	Ptr<Node> n0 = CreateObject<Node> ();
    7.67 +	Ptr<Node> r = CreateObject<Node> ();
    7.68 +	Ptr<Node> n1 = CreateObject<Node> ();
    7.69 +
    7.70 +	NodeContainer net1 (n0, r);
    7.71 +	NodeContainer net2 (r, n1);
    7.72 +	NodeContainer all (n0, r, n1);
    7.73 +
    7.74 +	NS_LOG_INFO ("Create IPv6 Internet Stack");
    7.75 +  InternetStackHelper internetv6;
    7.76 +  internetv6.Install (all);
    7.77 +
    7.78 +  NS_LOG_INFO ("Create channels.");
    7.79 +	CsmaHelper csma;
    7.80 +  csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
    7.81 +  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
    7.82 +	NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */
    7.83 +	NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */
    7.84 +
    7.85 +	NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
    7.86 +	Ipv6AddressHelper ipv6;
    7.87 +
    7.88 +  /* first subnet */
    7.89 +  ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
    7.90 +  NetDeviceContainer tmp;
    7.91 +  tmp.Add (d1.Get (0)); /* n0 */
    7.92 +  Ipv6InterfaceContainer iic1 = ipv6.AssignWithoutAddress (tmp); /* n0 interface */
    7.93 +
    7.94 +  NetDeviceContainer tmp2;
    7.95 +  tmp2.Add (d1.Get (1)); /* R */
    7.96 +  Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
    7.97 +  iicr1.SetRouter (0, true);
    7.98 +  iic1.Add (iicr1);
    7.99 +
   7.100 +  /* second subnet R - n1 */
   7.101 +  ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
   7.102 +  NetDeviceContainer tmp3;
   7.103 +  tmp3.Add (d2.Get (0)); /* R */
   7.104 +  Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
   7.105 +  iicr2.SetRouter (0, true);
   7.106 +
   7.107 +  NetDeviceContainer tmp4;
   7.108 +  tmp4.Add (d2.Get (1)); /* n1 */
   7.109 +  Ipv6InterfaceContainer iic2 = ipv6.AssignWithoutAddress (tmp4); 
   7.110 +  iic2.Add (iicr2);
   7.111 +
   7.112 +  /* radvd configuration */
   7.113 +  Ipv6Address prefix ("2001:1::0"); /* create the prefix */
   7.114 +  Ipv6Address prefix2 ("2001:2::0"); /* create the prefix */
   7.115 +  uint32_t indexRouter = iic1.GetInterfaceIndex (1); /* R interface (n0 - R) */
   7.116 +  uint32_t indexRouter2 = iic2.GetInterfaceIndex (1); /* R interface (R - n1) */
   7.117 +  Ptr<Radvd> radvd = CreateObject<Radvd> ();
   7.118 +  Ptr<RadvdInterface> routerInterface = Create<RadvdInterface> (indexRouter, 5000, 1000);
   7.119 +  Ptr<RadvdPrefix> routerPrefix = Create<RadvdPrefix> (prefix, 64, 3, 5);
   7.120 +  Ptr<RadvdInterface> routerInterface2 = Create<RadvdInterface> (indexRouter2, 5000, 1000);
   7.121 +  Ptr<RadvdPrefix> routerPrefix2 = Create<RadvdPrefix> (prefix2, 64, 3, 5);
   7.122 +
   7.123 +  routerInterface->AddPrefix (routerPrefix);
   7.124 +  routerInterface2->AddPrefix (routerPrefix2);
   7.125 +  radvd->AddConfiguration (routerInterface);
   7.126 +  radvd->AddConfiguration (routerInterface2);
   7.127 +
   7.128 +  r->AddApplication (radvd);
   7.129 +  radvd->Start (Seconds (1.0));
   7.130 +  radvd->Stop (Seconds (10.0));
   7.131 +
   7.132 +  /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */
   7.133 +  uint32_t packetSize = 1024;
   7.134 +  uint32_t maxPacketCount = 5;
   7.135 +  Time interPacketInterval = Seconds (1.);
   7.136 +  Ping6Helper ping6;
   7.137 +
   7.138 +  /* ping6.SetLocal (iic1.GetAddress (0, 1)); */
   7.139 +  ping6.SetRemote (Ipv6Address ("2001:2::200:ff:fe00:4")); /* should be n1 address after autoconfiguration */
   7.140 +  ping6.SetIfIndex (iic1.GetInterfaceIndex (0));
   7.141 +
   7.142 +  ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
   7.143 +  ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
   7.144 +  ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
   7.145 +  ApplicationContainer apps = ping6.Install (net1.Get (0));
   7.146 +  apps.Start (Seconds (2.0));
   7.147 +  apps.Stop (Seconds (7.0));
   7.148 +
   7.149 +	std::ofstream ascii;
   7.150 +  ascii.open ("radvd.tr");
   7.151 +  CsmaHelper::EnablePcapAll (std::string ("radvd"), true);
   7.152 +  CsmaHelper::EnableAsciiAll (ascii);
   7.153 +
   7.154 +  NS_LOG_INFO ("Run Simulation.");
   7.155 +  Simulator::Run ();
   7.156 +  Simulator::Destroy ();
   7.157 +  NS_LOG_INFO ("Done.");
   7.158 +}
   7.159 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/examples/simple-routing-ping6.cc	Sat Aug 22 14:36:55 2009 -0700
     8.3 @@ -0,0 +1,110 @@
     8.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     8.5 +/*
     8.6 + * Copyright (c) 2008-2009 Strasbourg University
     8.7 + *
     8.8 + * This program is free software; you can redistribute it and/or modify
     8.9 + * it under the terms of the GNU General Public License version 2 as
    8.10 + * published by the Free Software Foundation;
    8.11 + *
    8.12 + * This program is distributed in the hope that it will be useful,
    8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.15 + * GNU General Public License for more details.
    8.16 + *
    8.17 + * You should have received a copy of the GNU General Public License
    8.18 + * along with this program; if not, write to the Free Software
    8.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.20 + *
    8.21 + * Author: David Gross <david.gross@eturs.u-strasbg.fr>
    8.22 + *         Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
    8.23 + */
    8.24 +
    8.25 +// Network topology
    8.26 +// //
    8.27 +// //             n0   r    n1
    8.28 +// //             |    _    |
    8.29 +// //             ====|_|====
    8.30 +// //                router
    8.31 +// //
    8.32 +// // - Tracing of queues and packet receptions to file "simple-routing-ping6.tr"
    8.33 +
    8.34 +#include <fstream>
    8.35 +#include "ns3/core-module.h"
    8.36 +#include "ns3/simulator-module.h"
    8.37 +#include "ns3/helper-module.h"
    8.38 +
    8.39 +using namespace ns3;
    8.40 +
    8.41 +NS_LOG_COMPONENT_DEFINE ("SimpleRoutingUdp6Example");
    8.42 +
    8.43 +int 
    8.44 +main (int argc, char** argv)
    8.45 +{
    8.46 +#if 0 
    8.47 +  LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
    8.48 +  LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
    8.49 +  LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
    8.50 +  LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
    8.51 +  LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
    8.52 +#endif
    8.53 +
    8.54 +	CommandLine cmd;
    8.55 +  cmd.Parse (argc, argv);
    8.56 +  
    8.57 +	NS_LOG_INFO ("Create nodes.");
    8.58 +	Ptr<Node> n0 = CreateObject<Node> ();
    8.59 +	Ptr<Node> r = CreateObject<Node> ();
    8.60 +	Ptr<Node> n1 = CreateObject<Node> ();
    8.61 +
    8.62 +	NodeContainer net1 (n0, r);
    8.63 +	NodeContainer net2 (r, n1);
    8.64 +	NodeContainer all (n0, r, n1);
    8.65 +
    8.66 +	NS_LOG_INFO ("Create IPv6 Internet Stack");
    8.67 +  InternetStackHelper internetv6;
    8.68 +  internetv6.Install (all);
    8.69 +
    8.70 +  NS_LOG_INFO ("Create channels.");
    8.71 +	CsmaHelper csma;
    8.72 +  csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
    8.73 +  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
    8.74 +	NetDeviceContainer d1 = csma.Install (net1);
    8.75 +	NetDeviceContainer d2 = csma.Install (net2);
    8.76 +
    8.77 +	NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
    8.78 +	Ipv6AddressHelper ipv6;
    8.79 +	ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
    8.80 +	Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
    8.81 +  i1.SetRouter (1, true);
    8.82 +	ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
    8.83 +	Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
    8.84 +  i2.SetRouter (0, true);
    8.85 +
    8.86 +  /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */
    8.87 +  uint32_t packetSize = 1024;
    8.88 +  uint32_t maxPacketCount = 5;
    8.89 +  Time interPacketInterval = Seconds (1.);
    8.90 +  Ping6Helper ping6;
    8.91 +
    8.92 +  ping6.SetLocal (i1.GetAddress (0, 1));
    8.93 +  ping6.SetRemote (i2.GetAddress (1, 1)); 
    8.94 +  /* ping6.SetRemote (Ipv6Address::GetAllNodesMulticast ()); */
    8.95 +
    8.96 +  ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
    8.97 +  ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
    8.98 +  ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
    8.99 +  ApplicationContainer apps = ping6.Install (net1.Get (0));
   8.100 +  apps.Start (Seconds (2.0));
   8.101 +  apps.Stop (Seconds (20.0));
   8.102 +
   8.103 +	std::ofstream ascii;
   8.104 +  ascii.open ("simple-routing-ping6.tr");
   8.105 +  CsmaHelper::EnablePcapAll (std::string ("simple-routing-ping6"), true);
   8.106 +  CsmaHelper::EnableAsciiAll (ascii);
   8.107 +
   8.108 +  NS_LOG_INFO ("Run Simulation.");
   8.109 +  Simulator::Run ();
   8.110 +  Simulator::Destroy ();
   8.111 +  NS_LOG_INFO ("Done.");
   8.112 +}
   8.113 +
     9.1 --- a/examples/wscript	Sun Aug 23 14:00:50 2009 -0700
     9.2 +++ b/examples/wscript	Sat Aug 22 14:36:55 2009 -0700
     9.3 @@ -147,6 +147,26 @@
     9.4        ['point-to-point', 'internet-stack'])
     9.5      obj.source = 'test-ipv6.cc'
     9.6  
     9.7 +    obj = bld.create_ns3_program('ping6',
     9.8 +      ['csma', 'internet-stack'])
     9.9 +    obj.source = 'ping6.cc'
    9.10 +
    9.11 +    obj = bld.create_ns3_program('simple-routing-ping6',
    9.12 +      ['csma', 'internet-stack'])
    9.13 +    obj.source = 'simple-routing-ping6.cc'
    9.14 +
    9.15 +    obj = bld.create_ns3_program('icmpv6-redirect',
    9.16 +      ['csma', 'internet-stack'])
    9.17 +    obj.source = 'icmpv6-redirect.cc'
    9.18 +
    9.19 +    obj = bld.create_ns3_program('radvd',
    9.20 +      ['csma', 'internet-stack'])
    9.21 +    obj.source = 'radvd.cc'
    9.22 +
    9.23 +    obj = bld.create_ns3_program('radvd-two-prefix',
    9.24 +      ['csma', 'internet-stack'])
    9.25 +    obj.source = 'radvd-two-prefix.cc'
    9.26 +
    9.27      env = bld.env_of_name('default')
    9.28      if env['ENABLE_EMU']:
    9.29          obj = bld.create_ns3_program('emu-udp-echo', ['emu', 'internet-stack'])
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/applications/ping6/ping6.cc	Sat Aug 22 14:36:55 2009 -0700
    10.3 @@ -0,0 +1,236 @@
    10.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    10.5 +/*
    10.6 + * Copyright (c) 2007-2009 Strasbourg University
    10.7 + *
    10.8 + * This program is free software; you can redistribute it and/or modify
    10.9 + * it under the terms of the GNU General Public License version 2 as
   10.10 + * published by the Free Software Foundation;
   10.11 + *
   10.12 + * This program is distributed in the hope that it will be useful,
   10.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.15 + * GNU General Public License for more details.
   10.16 + *
   10.17 + * You should have received a copy of the GNU General Public License
   10.18 + * along with this program; if not, write to the Free Software
   10.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.20 + *
   10.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   10.22 + */
   10.23 +
   10.24 +#include "ns3/log.h"
   10.25 +#include "ns3/nstime.h"
   10.26 +#include "ns3/simulator.h"
   10.27 +#include "ns3/socket-factory.h"
   10.28 +#include "ns3/packet.h"
   10.29 +#include "ns3/socket.h"
   10.30 +#include "ns3/uinteger.h"
   10.31 +#include "ns3/ipv6.h"
   10.32 +#include "ns3/ipv6-address.h"
   10.33 +#include "ns3/inet6-socket-address.h"
   10.34 +#include "ns3/icmpv6-header.h"
   10.35 +#include "ns3/ipv6-raw-socket-factory.h"
   10.36 +#include "ns3/ipv6-header.h"
   10.37 +
   10.38 +#include "ping6.h"
   10.39 +
   10.40 +namespace ns3 
   10.41 +{
   10.42 +
   10.43 +NS_LOG_COMPONENT_DEFINE ("Ping6Application");
   10.44 +
   10.45 +NS_OBJECT_ENSURE_REGISTERED (Ping6);
   10.46 +
   10.47 +TypeId Ping6::GetTypeId ()
   10.48 +{
   10.49 +  static TypeId tid = TypeId ("ns3::Ping6")
   10.50 +    .SetParent<Application>()
   10.51 +    .AddConstructor<Ping6>()
   10.52 +    .AddAttribute ("MaxPackets", 
   10.53 +        "The maximum number of packets the application will send",
   10.54 +        UintegerValue (100),
   10.55 +        MakeUintegerAccessor (&Ping6::m_count),
   10.56 +        MakeUintegerChecker<uint32_t>())
   10.57 +    .AddAttribute ("Interval", 
   10.58 +        "The time to wait between packets",
   10.59 +        TimeValue (Seconds (1.0)),
   10.60 +        MakeTimeAccessor (&Ping6::m_interval),
   10.61 +        MakeTimeChecker ())
   10.62 +    .AddAttribute ("RemoteIpv6", 
   10.63 +        "The Ipv6Address of the outbound packets",
   10.64 +        Ipv6AddressValue (),
   10.65 +        MakeIpv6AddressAccessor (&Ping6::m_peerAddress),
   10.66 +        MakeIpv6AddressChecker ())
   10.67 +    .AddAttribute ("LocalIpv6", 
   10.68 +        "Local Ipv6Address of the sender",
   10.69 +        Ipv6AddressValue (),
   10.70 +        MakeIpv6AddressAccessor (&Ping6::m_localAddress),
   10.71 +        MakeIpv6AddressChecker ())
   10.72 +    .AddAttribute ("PacketSize", 
   10.73 +        "Size of packets generated",
   10.74 +        UintegerValue (100),
   10.75 +        MakeUintegerAccessor (&Ping6::m_size),
   10.76 +        MakeUintegerChecker<uint32_t>())
   10.77 +    ;
   10.78 +  return tid;
   10.79 +}
   10.80 +
   10.81 +Ping6::Ping6 ()
   10.82 +{
   10.83 +  NS_LOG_FUNCTION_NOARGS ();
   10.84 +  m_sent = 0;
   10.85 +  m_socket = 0;
   10.86 +  m_seq = 0;
   10.87 +  m_sendEvent = EventId ();
   10.88 +}
   10.89 +
   10.90 +Ping6::~Ping6 ()
   10.91 +{
   10.92 +  NS_LOG_FUNCTION_NOARGS ();
   10.93 +  m_socket = 0;
   10.94 +}
   10.95 +
   10.96 +void Ping6::DoDispose ()
   10.97 +{
   10.98 +  NS_LOG_FUNCTION_NOARGS ();
   10.99 +  Application::DoDispose ();
  10.100 +}
  10.101 +
  10.102 +void Ping6::StartApplication ()
  10.103 +{
  10.104 +  NS_LOG_FUNCTION_NOARGS ();
  10.105 +
  10.106 +  if (!m_socket)
  10.107 +  {
  10.108 +    TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory");
  10.109 +    m_socket = Socket::CreateSocket (GetNode (), tid);
  10.110 +
  10.111 +    NS_ASSERT (m_socket);
  10.112 +
  10.113 +    m_socket->Bind (Inet6SocketAddress (m_localAddress, 0));
  10.114 +    m_socket->Connect (Inet6SocketAddress (m_peerAddress, 0));
  10.115 +    m_socket->SetAttribute ("Protocol", UintegerValue (58)); /* ICMPv6 */
  10.116 +    m_socket->SetRecvCallback (MakeCallback (&Ping6::HandleRead, this));
  10.117 +  }
  10.118 +
  10.119 +  ScheduleTransmit (Seconds (0.));
  10.120 +}
  10.121 +
  10.122 +void Ping6::SetLocal (Ipv6Address ipv6) 
  10.123 +{
  10.124 +  NS_LOG_FUNCTION (this << ipv6);
  10.125 +  m_localAddress = ipv6;
  10.126 +}
  10.127 +
  10.128 +void Ping6::SetRemote (Ipv6Address ipv6)
  10.129 +{
  10.130 +  NS_LOG_FUNCTION (this << ipv6);
  10.131 +  m_peerAddress = ipv6;
  10.132 +}
  10.133 +
  10.134 +void Ping6::StopApplication ()
  10.135 +{
  10.136 +  NS_LOG_FUNCTION_NOARGS ();
  10.137 +
  10.138 +  if (m_socket)
  10.139 +  {
  10.140 +    m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> >());
  10.141 +  }
  10.142 +
  10.143 +  Simulator::Cancel (m_sendEvent);
  10.144 +}
  10.145 +
  10.146 +void Ping6::SetIfIndex (uint32_t ifIndex)
  10.147 +{
  10.148 +  m_ifIndex = ifIndex;
  10.149 +}
  10.150 +
  10.151 +void Ping6::ScheduleTransmit (Time dt)
  10.152 +{
  10.153 +  NS_LOG_FUNCTION (this << dt);
  10.154 +  m_sendEvent = Simulator::Schedule (dt, &Ping6::Send, this);
  10.155 +}
  10.156 +
  10.157 +void Ping6::Send ()
  10.158 +{
  10.159 +  NS_LOG_FUNCTION_NOARGS ();
  10.160 +  NS_ASSERT (m_sendEvent.IsExpired ());
  10.161 +  Ptr<Packet> p = 0;
  10.162 +  uint8_t data[4];
  10.163 +  Ipv6Address src;
  10.164 +  Ptr<Ipv6> ipv6 = GetNode ()->GetObject<Ipv6> ();
  10.165 +
  10.166 +  if (m_ifIndex > 0)
  10.167 +  {
  10.168 +    /* hack to have ifIndex in Ipv6RawSocketImpl
  10.169 +     * maybe add a SetIfIndex in Ipv6RawSocketImpl directly 
  10.170 +     */
  10.171 +    src = GetNode ()->GetObject<Ipv6> ()->GetAddress (m_ifIndex, 0).GetAddress ();
  10.172 +  }
  10.173 +  else
  10.174 +  {
  10.175 +    src = m_localAddress;
  10.176 +  }
  10.177 +
  10.178 +  data[0] = 0xDE;
  10.179 +  data[1] = 0xAD;
  10.180 +  data[2] = 0xBE;
  10.181 +  data[3] = 0xEF;
  10.182 +
  10.183 +  p = Create<Packet>(data, sizeof (data));
  10.184 +  Icmpv6Echo req (1);
  10.185 +
  10.186 +  req.SetId (0xBEEF);
  10.187 +  req.SetSeq (m_seq);
  10.188 +  m_seq++;
  10.189 +  
  10.190 +  /* we do not calculate pseudo header checksum here, because we are not sure about 
  10.191 +   * source IPv6 address. Checksum is calculated in Ipv6RawSocketImpl.
  10.192 +   */
  10.193 +
  10.194 +  p->AddHeader (req);
  10.195 +  m_socket->Bind (Inet6SocketAddress (src, 0));
  10.196 +  m_socket->Send (p, 0);
  10.197 +  ++m_sent;
  10.198 +
  10.199 +  NS_LOG_INFO ("Sent " << p->GetSize () << " bytes to " << m_peerAddress);
  10.200 +
  10.201 +  if (m_sent < m_count)
  10.202 +  {
  10.203 +    ScheduleTransmit (m_interval);
  10.204 +  }
  10.205 +}
  10.206 +
  10.207 +void Ping6::HandleRead (Ptr<Socket> socket)
  10.208 +{
  10.209 +  NS_LOG_FUNCTION (this << socket);
  10.210 +
  10.211 +  Ptr<Packet> packet=0;
  10.212 +  Address from;
  10.213 +  while (packet = socket->RecvFrom (from))
  10.214 +  {
  10.215 +    if (Inet6SocketAddress::IsMatchingType (from))
  10.216 +    {
  10.217 +      Ipv6Header hdr;
  10.218 +      Icmpv6Echo reply (0);
  10.219 +      Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from);
  10.220 +
  10.221 +      packet->RemoveHeader (hdr);
  10.222 +
  10.223 +      switch (*packet->PeekData ())
  10.224 +      {
  10.225 +        case Icmpv6Header::ICMPV6_ECHO_REPLY:
  10.226 +          packet->RemoveHeader (reply);
  10.227 +
  10.228 +          NS_LOG_INFO ("Received Echo Reply size  = " << std::dec << packet->GetSize () << " bytes from " << address.GetIpv6 () << " id =  " << (uint16_t)reply.GetId () << " seq = " << (uint16_t)reply.GetSeq ());
  10.229 +          break;
  10.230 +        default:
  10.231 +          /* other type, discard */
  10.232 +          break;
  10.233 +      }
  10.234 +    }
  10.235 +  }
  10.236 +}
  10.237 +
  10.238 +} /* namespace ns3 */
  10.239 +
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/applications/ping6/ping6.h	Sat Aug 22 14:36:55 2009 -0700
    11.3 @@ -0,0 +1,171 @@
    11.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    11.5 +/*
    11.6 + * Copyright (c) 2007-2009 Strasbourg University
    11.7 + *
    11.8 + * This program is free software; you can redistribute it and/or modify
    11.9 + * it under the terms of the GNU General Public License version 2 as
   11.10 + * published by the Free Software Foundation;
   11.11 + *
   11.12 + * This program is distributed in the hope that it will be useful,
   11.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.15 + * GNU General Public License for more details.
   11.16 + *
   11.17 + * You should have received a copy of the GNU General Public License
   11.18 + * along with this program; if not, write to the Free Software
   11.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   11.20 + *
   11.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   11.22 + */
   11.23 +
   11.24 +#ifndef PING6_H
   11.25 +#define PING6_H
   11.26 +
   11.27 +#include "ns3/application.h"
   11.28 +#include "ns3/event-id.h"
   11.29 +#include "ns3/ptr.h"
   11.30 +#include "ns3/ipv6-address.h"
   11.31 +
   11.32 +namespace ns3
   11.33 +{
   11.34 +
   11.35 +class Packet;
   11.36 +class Socket;
   11.37 +
   11.38 +/**
   11.39 + * \class Ping6
   11.40 + * \brief A ping6 application.
   11.41 + */
   11.42 +class Ping6 : public Application
   11.43 +{
   11.44 +  public:
   11.45 +    /**
   11.46 +     * \brief Get the type ID.
   11.47 +     * \return type ID
   11.48 +     */
   11.49 +    static TypeId GetTypeId ();
   11.50 +
   11.51 +    /**
   11.52 +     * \brief Constructor.
   11.53 +     */
   11.54 +    Ping6 ();
   11.55 +
   11.56 +    /**
   11.57 +     * \brief Destructor.
   11.58 +     */
   11.59 +    virtual ~Ping6 ();
   11.60 +
   11.61 +    /**
   11.62 +     * \brief Set the local address.
   11.63 +     * \param ipv6 the local IPv6 address
   11.64 +     */
   11.65 +    void SetLocal (Ipv6Address ipv6);
   11.66 +
   11.67 +    /**
   11.68 +     * \brief Set the remote peer.
   11.69 +     * \param ipv6 IPv6 address of the peer
   11.70 +     */
   11.71 +    void SetRemote (Ipv6Address ipv6);
   11.72 +
   11.73 +    /**
   11.74 +     * \brief Set the out interface index.
   11.75 +     * This is to send to link-local (unicast or multicast) address
   11.76 +     * when a node has multiple interfaces.
   11.77 +     * \param ifIndex interface index
   11.78 +     */
   11.79 +    void SetIfIndex (uint32_t ifIndex);
   11.80 +
   11.81 +  protected:
   11.82 +    /**
   11.83 +     * \brief Dispose this object;
   11.84 +     */
   11.85 +    virtual void DoDispose ();
   11.86 +
   11.87 +  private:
   11.88 +    /**
   11.89 +     * \brief Start the application.
   11.90 +     */
   11.91 +    virtual void StartApplication ();
   11.92 +
   11.93 +    /**
   11.94 +     * \brief Stop the application.
   11.95 +     */
   11.96 +    virtual void StopApplication ();
   11.97 +
   11.98 +    /**
   11.99 +     * \brief Schedule sending a packet.
  11.100 +     * \param dt interval between packet
  11.101 +     */
  11.102 +    void ScheduleTransmit (Time dt);
  11.103 +
  11.104 +    /**
  11.105 +     * \brief Send a packet.
  11.106 +     */
  11.107 +    void Send ();
  11.108 +
  11.109 +    /**
  11.110 +     * \brief Receive method.
  11.111 +     * \param socket socket that receive a packet
  11.112 +     */
  11.113 +    void HandleRead (Ptr<Socket> socket);
  11.114 +
  11.115 +    /**
  11.116 +     * \brief Peer IPv6 address.
  11.117 +     */
  11.118 +    Ipv6Address m_address;
  11.119 +
  11.120 +    /**
  11.121 +     * \brief Number of "Echo request" packets that will be sent.
  11.122 +     */
  11.123 +    uint32_t m_count;
  11.124 +
  11.125 +    /**
  11.126 +     * \brief Number of packets sent.
  11.127 +     */
  11.128 +    uint32_t m_sent;
  11.129 +
  11.130 +    /**
  11.131 +     * \brief Size of the packet.
  11.132 +     */
  11.133 +    uint32_t m_size;
  11.134 +
  11.135 +    /**
  11.136 +     * \brief Intervall between packets sent.
  11.137 +     */
  11.138 +    Time m_interval;
  11.139 +
  11.140 +    /**
  11.141 +     * \brief Local address.
  11.142 +     */
  11.143 +    Ipv6Address m_localAddress;
  11.144 +
  11.145 +    /**
  11.146 +     * \brief Peer address.
  11.147 +     */
  11.148 +    Ipv6Address m_peerAddress;
  11.149 +
  11.150 +    /**
  11.151 +     * \brief Local socket.
  11.152 +     */
  11.153 +    Ptr<Socket> m_socket;
  11.154 +
  11.155 +    /**
  11.156 +     * \brief Sequence number.
  11.157 +     */
  11.158 +    uint16_t m_seq;
  11.159 +
  11.160 +    /**
  11.161 +     * \brief Event ID.
  11.162 +     */
  11.163 +    EventId m_sendEvent;
  11.164 +
  11.165 +    /**
  11.166 +     * \brief Out interface (i.e. for link-local communication).
  11.167 +     */
  11.168 +    uint32_t m_ifIndex;
  11.169 +};
  11.170 +
  11.171 +} /* namespace ns3 */
  11.172 +
  11.173 +#endif /* PING6_H */
  11.174 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/applications/ping6/waf	Sat Aug 22 14:36:55 2009 -0700
    12.3 @@ -0,0 +1,1 @@
    12.4 +exec "`dirname "$0"`"/../../../waf "$@"
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/applications/ping6/wscript	Sat Aug 22 14:36:55 2009 -0700
    13.3 @@ -0,0 +1,13 @@
    13.4 +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
    13.5 +
    13.6 +def build(bld):
    13.7 +    module = bld.create_ns3_module('ping6', ['internet-stack'])
    13.8 +    module.source = [
    13.9 +        'ping6.cc',
   13.10 +        ]
   13.11 +    headers = bld.new_task_gen('ns3header')
   13.12 +    headers.module = 'ping6'
   13.13 +    headers.source = [
   13.14 +        'ping6.h',
   13.15 +        ]
   13.16 +
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/applications/radvd/radvd-interface.cc	Sat Aug 22 14:36:55 2009 -0700
    14.3 @@ -0,0 +1,292 @@
    14.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    14.5 +/*
    14.6 + * Copyright (c) 2009 Strasbourg University
    14.7 + *
    14.8 + * This program is free software; you can redistribute it and/or modify
    14.9 + * it under the terms of the GNU General Public License version 2 as
   14.10 + * published by the Free Software Foundation;
   14.11 + *
   14.12 + * This program is distributed in the hope that it will be useful,
   14.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.15 + * GNU General Public License for more details.
   14.16 + *
   14.17 + * You should have received a copy of the GNU General Public License
   14.18 + * along with this program; if not, write to the Free Software
   14.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   14.20 + *
   14.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   14.22 + */
   14.23 +
   14.24 +#include "radvd-interface.h"
   14.25 +
   14.26 +namespace ns3 
   14.27 +{
   14.28 +
   14.29 +RadvdInterface::RadvdInterface (uint32_t interface)
   14.30 +  : m_interface (interface)
   14.31 +{
   14.32 +  /* initialize default value as specified in radvd.conf manpage */
   14.33 +  m_sendAdvert = true;
   14.34 +  m_maxRtrAdvInterval = 600000;
   14.35 +  m_minRtrAdvInterval = (uint32_t)(double)(0.33 * m_maxRtrAdvInterval);
   14.36 +  m_minDelayBetweenRAs = 3000;
   14.37 +  m_managedFlag = false;
   14.38 +  m_otherConfigFlag = false;
   14.39 +  m_linkMtu = 0; /* 0 means not sending MTU option in RA */
   14.40 +  m_reachableTime = 0; /* means unspecified for the router */
   14.41 +  m_retransTimer = 0; /* means unspecified for the router */
   14.42 +  m_curHopLimit = 64;
   14.43 +  m_defaultLifeTime = 3 * m_maxRtrAdvInterval;
   14.44 +  m_defaultPreference = 1;
   14.45 +  m_sourceLLAddress = true;
   14.46 +  m_homeAgentFlag = false;
   14.47 +  m_homeAgentInfo = false;
   14.48 +  m_homeAgentLifeTime = 0;
   14.49 +  m_homeAgentPreference = 0;
   14.50 +  m_mobRtrSupportFlag = false;
   14.51 +  m_intervalOpt = false;
   14.52 +}
   14.53 +
   14.54 +RadvdInterface::RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval)
   14.55 +  : m_interface (interface)
   14.56 +{
   14.57 +  NS_ASSERT (maxRtrAdvInterval > minRtrAdvInterval);
   14.58 +  m_sendAdvert = true;
   14.59 +  m_maxRtrAdvInterval = maxRtrAdvInterval;
   14.60 +  m_minRtrAdvInterval = minRtrAdvInterval;
   14.61 +  m_minDelayBetweenRAs = 3000;
   14.62 +  m_managedFlag = false;
   14.63 +  m_otherConfigFlag = false;
   14.64 +  m_linkMtu = 0; /* 0 means not sending MTU option in RA */
   14.65 +  m_reachableTime = 0; /* means unspecified for the router */
   14.66 +  m_retransTimer = 0; /* means unspecified for the router */
   14.67 +  m_curHopLimit = 64;
   14.68 +  m_defaultLifeTime = 3 * m_maxRtrAdvInterval;
   14.69 +  m_defaultPreference = 1;
   14.70 +  m_sourceLLAddress = true;
   14.71 +  m_homeAgentFlag = false;
   14.72 +  m_homeAgentInfo = false;
   14.73 +  m_homeAgentLifeTime = 0;
   14.74 +  m_homeAgentPreference = 0;
   14.75 +  m_mobRtrSupportFlag = false;
   14.76 +  m_intervalOpt = false;
   14.77 +}
   14.78 +
   14.79 +RadvdInterface::~RadvdInterface ()
   14.80 +{
   14.81 +  /* clear prefixes */
   14.82 +  for (RadvdPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it)
   14.83 +  {
   14.84 +    (*it) = 0;
   14.85 +  }
   14.86 +  m_prefixes.clear ();
   14.87 +}
   14.88 +
   14.89 +void RadvdInterface::AddPrefix (Ptr<RadvdPrefix> routerPrefix)
   14.90 +{
   14.91 +  m_prefixes.push_back (routerPrefix);
   14.92 +}
   14.93 +
   14.94 +
   14.95 +uint32_t RadvdInterface::GetInterface () const
   14.96 +{
   14.97 +  return m_interface;
   14.98 +}
   14.99 +
  14.100 +std::list<Ptr<RadvdPrefix> > RadvdInterface::GetPrefixes () const
  14.101 +{
  14.102 +  return m_prefixes;
  14.103 +}
  14.104 +
  14.105 +bool RadvdInterface::IsSendAdvert () const
  14.106 +{
  14.107 +  return m_sendAdvert;
  14.108 +}
  14.109 +
  14.110 +void RadvdInterface::SetSendAdvert (bool sendAdvert)
  14.111 +{
  14.112 +  m_sendAdvert = sendAdvert;
  14.113 +}
  14.114 +
  14.115 +uint32_t RadvdInterface::GetMaxRtrAdvInterval () const
  14.116 +{
  14.117 +  return m_maxRtrAdvInterval;
  14.118 +}
  14.119 +
  14.120 +void RadvdInterface::SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval)
  14.121 +{
  14.122 +  m_maxRtrAdvInterval = maxRtrAdvInterval;
  14.123 +}
  14.124 +
  14.125 +uint32_t RadvdInterface::GetMinRtrAdvInterval () const
  14.126 +{
  14.127 +  return m_minRtrAdvInterval;
  14.128 +}
  14.129 +
  14.130 +void RadvdInterface::SetMinRtrAdvInterval (uint32_t minRtrAdvInterval)
  14.131 +{
  14.132 +  m_minRtrAdvInterval = minRtrAdvInterval;
  14.133 +}
  14.134 +
  14.135 +uint32_t RadvdInterface::GetMinDelayBetweenRAs () const
  14.136 +{
  14.137 +  return m_minDelayBetweenRAs;
  14.138 +}
  14.139 +
  14.140 +void RadvdInterface::SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs)
  14.141 +{
  14.142 +  m_minDelayBetweenRAs = minDelayBetweenRAs;
  14.143 +}
  14.144 +
  14.145 +bool RadvdInterface::IsManagedFlag () const
  14.146 +{
  14.147 +  return m_managedFlag;
  14.148 +}
  14.149 +
  14.150 +void RadvdInterface::SetManagedFlag (bool managedFlag)
  14.151 +{
  14.152 +  m_managedFlag = managedFlag;
  14.153 +}
  14.154 +
  14.155 +bool RadvdInterface::IsOtherConfigFlag () const
  14.156 +{
  14.157 +  return m_otherConfigFlag;
  14.158 +}
  14.159 +
  14.160 +void RadvdInterface::SetOtherConfigFlag (bool otherConfigFlag)
  14.161 +{
  14.162 +  m_otherConfigFlag = otherConfigFlag;
  14.163 +}
  14.164 +
  14.165 +uint32_t RadvdInterface::GetLinkMtu () const
  14.166 +{
  14.167 +  return m_linkMtu;
  14.168 +}
  14.169 +
  14.170 +void RadvdInterface::SetLinkMtu (uint32_t linkMtu)
  14.171 +{
  14.172 +  m_linkMtu = linkMtu;
  14.173 +}
  14.174 +
  14.175 +uint32_t RadvdInterface::GetReachableTime () const
  14.176 +{
  14.177 +  return m_reachableTime;
  14.178 +}
  14.179 +
  14.180 +void RadvdInterface::SetReachableTime (uint32_t reachableTime)
  14.181 +{
  14.182 +  m_reachableTime = reachableTime;
  14.183 +}
  14.184 +
  14.185 +uint32_t RadvdInterface::GetDefaultLifeTime () const
  14.186 +{
  14.187 +  return m_defaultLifeTime;
  14.188 +}
  14.189 +
  14.190 +void RadvdInterface::SetDefaultLifeTime (uint32_t defaultLifeTime)
  14.191 +{
  14.192 +  m_defaultLifeTime = defaultLifeTime;
  14.193 +}
  14.194 +
  14.195 +uint32_t RadvdInterface::GetRetransTimer () const
  14.196 +{
  14.197 +  return m_retransTimer;
  14.198 +}
  14.199 +
  14.200 +void RadvdInterface::SetRetransTimer (uint32_t retransTimer)
  14.201 +{
  14.202 +  m_retransTimer = retransTimer;
  14.203 +}
  14.204 +
  14.205 +uint8_t RadvdInterface::GetCurHopLimit () const
  14.206 +{
  14.207 +  return m_curHopLimit;
  14.208 +}
  14.209 +
  14.210 +void RadvdInterface::SetCurHopLimit (uint8_t curHopLimit)
  14.211 +{
  14.212 +  m_curHopLimit = curHopLimit;
  14.213 +}
  14.214 +
  14.215 +uint8_t RadvdInterface::GetDefaultPreference () const
  14.216 +{
  14.217 +  return m_defaultPreference;
  14.218 +}
  14.219 +
  14.220 +void RadvdInterface::SetDefaultPreference (uint8_t defaultPreference)
  14.221 +{
  14.222 +  m_defaultPreference = defaultPreference;
  14.223 +}
  14.224 +
  14.225 +bool RadvdInterface::IsSourceLLAddress () const
  14.226 +{
  14.227 +  return m_sourceLLAddress;
  14.228 +}
  14.229 +
  14.230 +void RadvdInterface::SetSourceLLAddress (bool sourceLLAddress)
  14.231 +{
  14.232 +  m_sourceLLAddress = sourceLLAddress;
  14.233 +}
  14.234 +
  14.235 +bool RadvdInterface::IsHomeAgentFlag () const
  14.236 +{
  14.237 +  return m_homeAgentFlag;
  14.238 +}
  14.239 +
  14.240 +void RadvdInterface::SetHomeAgentFlag (bool homeAgentFlag)
  14.241 +{
  14.242 +  m_homeAgentFlag = homeAgentFlag;
  14.243 +}
  14.244 +
  14.245 +bool RadvdInterface::IsHomeAgentInfo () const
  14.246 +{
  14.247 +  return m_homeAgentInfo;
  14.248 +}
  14.249 +
  14.250 +void RadvdInterface::SetHomeAgentInfo (bool homeAgentInfo)
  14.251 +{
  14.252 +  m_homeAgentInfo = homeAgentInfo;
  14.253 +}
  14.254 +
  14.255 +uint32_t RadvdInterface::GetHomeAgentLifeTime () const
  14.256 +{
  14.257 +  return m_homeAgentLifeTime;
  14.258 +}
  14.259 +
  14.260 +void RadvdInterface::SetHomeAgentLifeTime (uint32_t homeAgentLifeTime)
  14.261 +{
  14.262 +  m_homeAgentLifeTime = homeAgentLifeTime;
  14.263 +}
  14.264 +
  14.265 +uint32_t RadvdInterface::GetHomeAgentPreference () const
  14.266 +{
  14.267 +  return m_homeAgentPreference;
  14.268 +}
  14.269 +
  14.270 +void RadvdInterface::SetHomeAgentPreference (uint32_t homeAgentPreference)
  14.271 +{
  14.272 +  m_homeAgentPreference = homeAgentPreference;
  14.273 +}
  14.274 +
  14.275 +bool RadvdInterface::IsMobRtrSupportFlag () const
  14.276 +{
  14.277 +  return m_mobRtrSupportFlag;
  14.278 +}
  14.279 +
  14.280 +void RadvdInterface::SetMobRtrSupportFlag (bool mobRtrSupportFlag)
  14.281 +{
  14.282 +  m_mobRtrSupportFlag = mobRtrSupportFlag;
  14.283 +}
  14.284 +
  14.285 +bool RadvdInterface::IsIntervalOpt () const
  14.286 +{
  14.287 +  return m_intervalOpt;
  14.288 +}
  14.289 +
  14.290 +void RadvdInterface::SetIntervalOpt (bool intervalOpt)
  14.291 +{
  14.292 +  m_intervalOpt = intervalOpt;
  14.293 +}
  14.294 +} /* namespace ns3 */
  14.295 +
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/applications/radvd/radvd-interface.h	Sat Aug 22 14:36:55 2009 -0700
    15.3 @@ -0,0 +1,420 @@
    15.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    15.5 +/*
    15.6 + * Copyright (c) 2009 Strasbourg University
    15.7 + *
    15.8 + * This program is free software; you can redistribute it and/or modify
    15.9 + * it under the terms of the GNU General Public License version 2 as
   15.10 + * published by the Free Software Foundation;
   15.11 + *
   15.12 + * This program is distributed in the hope that it will be useful,
   15.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15.15 + * GNU General Public License for more details.
   15.16 + *
   15.17 + * You should have received a copy of the GNU General Public License
   15.18 + * along with this program; if not, write to the Free Software
   15.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   15.20 + *
   15.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   15.22 + */
   15.23 +
   15.24 +#ifndef RADVD_INTERFACE_H
   15.25 +#define RADVD_INTERFACE_H
   15.26 +
   15.27 +#include <list>
   15.28 +
   15.29 +#include "radvd-prefix.h"
   15.30 +
   15.31 +namespace ns3
   15.32 +{
   15.33 +
   15.34 +/**
   15.35 + * \class RadvdInterface
   15.36 + * \brief Radvd interface configuration.
   15.37 + */
   15.38 +class RadvdInterface : public RefCountBase
   15.39 +{
   15.40 +  public:
   15.41 +    /**
   15.42 +     * \brief Constructor.
   15.43 +     * \param interface interface index
   15.44 +     */
   15.45 +    RadvdInterface (uint32_t interface);
   15.46 +
   15.47 +    /**
   15.48 +     * \brief Constructor.
   15.49 +     * \param interface interface index
   15.50 +     * \param maxRtrAdvInterval maximum RA interval
   15.51 +     * \param minRtrAdvInterval minimum RA interval
   15.52 +     */
   15.53 +    RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval);
   15.54 +
   15.55 +    /**
   15.56 +     * \brief Destructor.
   15.57 +     */
   15.58 +    ~RadvdInterface ();
   15.59 +
   15.60 +    /**
   15.61 +     * \brief Get interface index for this configuration.
   15.62 +     * \return interface index
   15.63 +     */
   15.64 +    uint32_t GetInterface () const;
   15.65 +
   15.66 +    /**
   15.67 +     * \brief Get list of prefixes advertised for this interface.     
   15.68 +     * \return list of IPv6 prefixes
   15.69 +     */
   15.70 +    std::list <Ptr<RadvdPrefix> > GetPrefixes () const;
   15.71 +
   15.72 +    /**
   15.73 +     * \brief Add a prefix to advertise on interface.
   15.74 +     * \param routerPrefix prefix to advertise
   15.75 +     */
   15.76 +    void AddPrefix (Ptr<RadvdPrefix> routerPrefix);
   15.77 +    
   15.78 +    /**
   15.79 +     * \brief Is send advert enabled (periodic RA and reply to RS) ?
   15.80 +     * \return send advert flag
   15.81 +     */
   15.82 +    bool IsSendAdvert () const;
   15.83 +    
   15.84 +    /**
   15.85 +     * \brief Set send advert flag.
   15.86 +     * \return sendAdvert value
   15.87 +     */
   15.88 +    void SetSendAdvert (bool sendAdvert);
   15.89 +
   15.90 +    /**
   15.91 +     * \brief Get maximum RA interval.
   15.92 +     * \return RA interval
   15.93 +     */
   15.94 +    uint32_t GetMaxRtrAdvInterval () const;
   15.95 +
   15.96 +    /**
   15.97 +     * \brief Get maximum RA interval.
   15.98 +     * \param maxRtrAdvInterval RA interval
   15.99 +     */
  15.100 +    void SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval);
  15.101 +
  15.102 +    /**
  15.103 +     * \brief Get minimum RA interval.
  15.104 +     * \return RA interval
  15.105 +     */
  15.106 +    uint32_t GetMinRtrAdvInterval () const;
  15.107 +    
  15.108 +    /**
  15.109 +     * \brief Get minimum RA interval.
  15.110 +     * \param minRtrAdvInterval RA interval
  15.111 +     */
  15.112 +    void SetMinRtrAdvInterval (uint32_t minRtrAdvInterval);
  15.113 +
  15.114 +    /**
  15.115 +     * \brief Get minimum delay between RAs.
  15.116 +     * \return minimum delay
  15.117 +     */
  15.118 +    uint32_t GetMinDelayBetweenRAs () const;
  15.119 +    
  15.120 +    /**
  15.121 +     * \brief Set minimum delay between RAs.
  15.122 +     * \param minDelayBetweenRAs minimum delay
  15.123 +     */
  15.124 +    void SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs);
  15.125 +
  15.126 +    /**
  15.127 +     * \brief Is managed flag enabled ?
  15.128 +     * \return managed flag
  15.129 +     */
  15.130 +    bool IsManagedFlag () const;
  15.131 +    
  15.132 +    /**
  15.133 +     * \brief Set managed flag
  15.134 +     * \param managedFlag value
  15.135 +     */
  15.136 +    void SetManagedFlag (bool managedFlag);
  15.137 +
  15.138 +    /**
  15.139 +     * \brief Is "other config" flag enabled ?
  15.140 +     * \return other config flag
  15.141 +     */
  15.142 +    bool IsOtherConfigFlag () const;
  15.143 +    
  15.144 +    /**
  15.145 +     * \brief Set "other config" flag
  15.146 +     * \param otherConfigFlag value
  15.147 +     */
  15.148 +    void SetOtherConfigFlag (bool otherConfigFlag);
  15.149 +
  15.150 +    /**
  15.151 +     * \brief Get link MTU.
  15.152 +     * \return link MTU
  15.153 +     */
  15.154 +    uint32_t GetLinkMtu () const;
  15.155 +    
  15.156 +    /**
  15.157 +     * \brief Set link MTU.
  15.158 +     * \param linkMtu link MTU
  15.159 +     */
  15.160 +    void SetLinkMtu (uint32_t linkMtu); 
  15.161 +
  15.162 +    /**
  15.163 +     * \brief Get reachable time.
  15.164 +     * \return reachable time
  15.165 +     */
  15.166 +    uint32_t GetReachableTime () const;
  15.167 +    
  15.168 +    /**
  15.169 +     * \brief Set reachable time.
  15.170 +     * \param reachableTime reachable time
  15.171 +     */
  15.172 +    void SetReachableTime (uint32_t reachableTime);
  15.173 +
  15.174 +    /**
  15.175 +     * \brief Get default lifetime.
  15.176 +     * \return default lifetime
  15.177 +     */
  15.178 +    uint32_t GetDefaultLifeTime () const;
  15.179 +    
  15.180 +    /**
  15.181 +     * \brief Set default lifetime.
  15.182 +     * \param defaultLifeTime default lifetime
  15.183 +     */
  15.184 +    void SetDefaultLifeTime (uint32_t defaultLifeTime);
  15.185 +
  15.186 +    /**
  15.187 +     * \brief Get retransmission timer.
  15.188 +     * \return retransmission timer
  15.189 +     */
  15.190 +    uint32_t GetRetransTimer () const;
  15.191 +    
  15.192 +    /**
  15.193 +     * \brief Set retransmission timer.
  15.194 +     * \param retransTimer retransmission timer
  15.195 +     */
  15.196 +    void SetRetransTimer (uint32_t retransTimer);
  15.197 +
  15.198 +    /**
  15.199 +     * \brief Get current hop limit.
  15.200 +     * \return current hop limit for the link
  15.201 +     */
  15.202 +    uint8_t GetCurHopLimit () const;
  15.203 +    
  15.204 +    /**
  15.205 +     * \brief Set current hop limit.
  15.206 +     * \param curHopLimit current hop limit for the link
  15.207 +     */
  15.208 +    void SetCurHopLimit (uint8_t curHopLimit); 
  15.209 +
  15.210 +    /**
  15.211 +     * \brief Get default preference.
  15.212 +     * \return default preference
  15.213 +     */
  15.214 +    uint8_t GetDefaultPreference () const;
  15.215 +    
  15.216 +    /**
  15.217 +     * \brief Set default preference.
  15.218 +     * \param defaultPreference default preference
  15.219 +     */
  15.220 +    void SetDefaultPreference (uint8_t defaultPreference);
  15.221 +
  15.222 +    /**
  15.223 +     * \brief Is source LLA option should be included in RA ?
  15.224 +     * \return true if source address is added in RA, false otherwise
  15.225 +     */
  15.226 +    bool IsSourceLLAddress () const;
  15.227 +    
  15.228 +    /**
  15.229 +     * \brief Set flag to add or not LLA to RA.
  15.230 +     * \param sourceLLAddress value
  15.231 +     */
  15.232 +    void SetSourceLLAddress (bool sourceLLAddress);
  15.233 +
  15.234 +    /**
  15.235 +     * \brief Is "home agent" flag enabled ?
  15.236 +     * \return "home agent" flag
  15.237 +     */
  15.238 +    bool IsHomeAgentFlag () const;
  15.239 +    
  15.240 +    /**
  15.241 +     * \brief Set "home agent" flag.
  15.242 +     * \param homeAgentFlag value
  15.243 +     */
  15.244 +    void SetHomeAgentFlag (bool homeAgentFlag);
  15.245 +
  15.246 +    /**
  15.247 +     * \brief Is Home Agent Information option should be included in RA ?
  15.248 +     * \return true if HA information option is added in RA, false otherwise
  15.249 +     */
  15.250 +    bool IsHomeAgentInfo () const;
  15.251 +    
  15.252 +    /**
  15.253 +     * \brief Set flag to add or not HA information option to RA.
  15.254 +     * \param homeAgentFlag value
  15.255 +     */
  15.256 +    void SetHomeAgentInfo (bool homeAgentFlag);
  15.257 +    
  15.258 +    /**
  15.259 +     * \brief Get home agent lifetime.
  15.260 +     * \return home agent lifetime
  15.261 +     */
  15.262 +    uint32_t GetHomeAgentLifeTime () const;
  15.263 +    
  15.264 +    /**
  15.265 +     * \brief Set home agent lifetime.
  15.266 +     * \param homeAgentLifeTime home agent lifetime
  15.267 +     */
  15.268 +    void SetHomeAgentLifeTime (uint32_t homeAgentLifeTime);
  15.269 +    
  15.270 +    /**
  15.271 +     * \brief Get home agent preference.
  15.272 +     * \return home agent preference
  15.273 +     */
  15.274 +    uint32_t GetHomeAgentPreference () const;
  15.275 +    
  15.276 +    /**
  15.277 +     * \brief Set home agent preference.
  15.278 +     * \param homeAgentPreference home agent preference
  15.279 +     */
  15.280 +    void SetHomeAgentPreference (uint32_t homeAgentPreference);
  15.281 +
  15.282 +    /**
  15.283 +     * \brief Is "mobile router support" flag enabled ?
  15.284 +     * \return "mobile router support" flag
  15.285 +     */
  15.286 +    bool IsMobRtrSupportFlag () const;
  15.287 +    
  15.288 +    /**
  15.289 +     * \brief Set "mobile router support" flag.
  15.290 +     * \param mobRtrSupportFlag value
  15.291 +     */
  15.292 +    void SetMobRtrSupportFlag (bool mobRtrSupportFlag);
  15.293 +    
  15.294 +    /**
  15.295 +     * \brief Is advertisement interval option should be included in RA ?
  15.296 +     * \return true if advertisement interval option is added in RA, false otherwise
  15.297 +     */
  15.298 +    bool IsIntervalOpt () const;
  15.299 +    
  15.300 +    /**
  15.301 +     * \brief Set flag to add or not advertisement interval to RA.
  15.302 +     * \param intervalOpt value
  15.303 +     */
  15.304 +    void SetIntervalOpt (bool intervalOpt);
  15.305 +
  15.306 +  private:
  15.307 +    typedef std::list<Ptr<RadvdPrefix> > RadvdPrefixList;
  15.308 +    typedef std::list<Ptr<RadvdPrefix> >::iterator RadvdPrefixListI;
  15.309 +
  15.310 +    /**
  15.311 +     * \brief Interface to advertise RA.
  15.312 +     */
  15.313 +    uint32_t m_interface;
  15.314 +
  15.315 +    /**
  15.316 +     * \brief List of prefixes to advertise.
  15.317 +     */
  15.318 +    RadvdPrefixList m_prefixes;
  15.319 +
  15.320 +    /**
  15.321 +     * \brief Flag whether or not router sends periodic RA and respond to RS.
  15.322 +     */
  15.323 +    bool m_sendAdvert;
  15.324 +
  15.325 +    /**
  15.326 +     * \brief Maximum RA interval in milliseconds.
  15.327 +     */
  15.328 +    uint32_t m_maxRtrAdvInterval;
  15.329 +
  15.330 +    /**
  15.331 +     * \brief Minimum RA interval in milliseconds.
  15.332 +     */
  15.333 +    uint32_t m_minRtrAdvInterval;
  15.334 +
  15.335 +    /**
  15.336 +     * \brief Minimum delay between RA in milliseconds.
  15.337 +     */
  15.338 +    uint32_t m_minDelayBetweenRAs;
  15.339 +
  15.340 +    /**
  15.341 +     * \brief Managed flag. If true host use the stateful protocol for address autoconfiguration.
  15.342 +     */
  15.343 +    bool m_managedFlag;
  15.344 +
  15.345 +    /**
  15.346 +     * \brief Other configuration flag. If true host use stateful protocol for other (non-address) information.
  15.347 +     */
  15.348 +    bool m_otherConfigFlag;
  15.349 +
  15.350 +    /**
  15.351 +     * \brief Link MTU to use.
  15.352 +     */
  15.353 +    uint32_t m_linkMtu;
  15.354 +
  15.355 +    /**
  15.356 +     * \brief Reachable time in milliseconds.
  15.357 +     */
  15.358 +    uint32_t m_reachableTime;
  15.359 +
  15.360 +    /**
  15.361 +     * \brief Retransmission timer in milliseconds.
  15.362 +     */
  15.363 +    uint32_t m_retransTimer;
  15.364 +
  15.365 +    /**
  15.366 +     * \brief Current hop limit (TTL).
  15.367 +     */
  15.368 +    uint32_t m_curHopLimit;
  15.369 +
  15.370 +    /**
  15.371 +     * \brief Default life time in seconds.
  15.372 +     */
  15.373 +    uint32_t m_defaultLifeTime;
  15.374 +
  15.375 +    /**
  15.376 +     * \brief Preference associated with default router.
  15.377 +     * 0 = low
  15.378 +     * 1 = medium
  15.379 +     * 2 = high
  15.380 +     */
  15.381 +    uint8_t m_defaultPreference;
  15.382 +
  15.383 +    /**
  15.384 +     * \brief Flag to add link-layer address in RA.
  15.385 +     */
  15.386 +    bool m_sourceLLAddress;
  15.387 +
  15.388 +    /**
  15.389 +     * \brief Flag to add HA (home agent) flag in RA.
  15.390 +     */
  15.391 +    bool m_homeAgentFlag;
  15.392 +
  15.393 +    /**
  15.394 +     * \brief Flag to add Home Agent Information option (Mobile IPv6).
  15.395 +     * Currently not implemented.
  15.396 +     */
  15.397 +    bool m_homeAgentInfo;
  15.398 +
  15.399 +    /**
  15.400 +     * \brief Home agent lifetime in seconds. Ignored if home agent info is not set.
  15.401 +     */
  15.402 +    uint32_t m_homeAgentLifeTime;
  15.403 +
  15.404 +    /**
  15.405 +     * \brief Home agent preference. Ignored if home agent info is not set.
  15.406 +     */
  15.407 +    uint32_t m_homeAgentPreference;
  15.408 +
  15.409 +    /**
  15.410 +     * \brief Flag for HA to signals it supports Mobile Router registrations (NEMO Basic).
  15.411 +     */
  15.412 +    bool m_mobRtrSupportFlag;
  15.413 +
  15.414 +    /**
  15.415 +     * \brief Flag to add Advertisement Interval option in RA.
  15.416 +     */
  15.417 +    bool m_intervalOpt;
  15.418 +};
  15.419 +
  15.420 +} /* namespace ns3 */
  15.421 +
  15.422 +#endif /* RADVD_INTERFACE_H */
  15.423 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/applications/radvd/radvd-prefix.cc	Sat Aug 22 14:36:55 2009 -0700
    16.3 @@ -0,0 +1,112 @@
    16.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    16.5 +/*
    16.6 + * Copyright (c) 2009 Strasbourg University
    16.7 + *
    16.8 + * This program is free software; you can redistribute it and/or modify
    16.9 + * it under the terms of the GNU General Public License version 2 as
   16.10 + * published by the Free Software Foundation;
   16.11 + *
   16.12 + * This program is distributed in the hope that it will be useful,
   16.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16.15 + * GNU General Public License for more details.
   16.16 + *
   16.17 + * You should have received a copy of the GNU General Public License
   16.18 + * along with this program; if not, write to the Free Software
   16.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   16.20 + *
   16.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   16.22 + */
   16.23 +
   16.24 +#include "radvd-prefix.h"
   16.25 +
   16.26 +namespace ns3
   16.27 +{
   16.28 +
   16.29 +RadvdPrefix::RadvdPrefix (Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime, uint32_t validLifeTime, bool onLinkFlag, bool autonomousFlag, bool routerAddrFlag)
   16.30 +  : m_network (network),
   16.31 +  m_prefixLength (prefixLength),
   16.32 +  m_preferredLifeTime (preferredLifeTime),
   16.33 +  m_validLifeTime (validLifeTime),
   16.34 +  m_onLinkFlag (onLinkFlag),
   16.35 +  m_autonomousFlag (autonomousFlag),
   16.36 +  m_routerAddrFlag (routerAddrFlag)
   16.37 +{
   16.38 +}
   16.39 +
   16.40 +RadvdPrefix::~RadvdPrefix ()
   16.41 +{
   16.42 +}
   16.43 +
   16.44 +Ipv6Address RadvdPrefix::GetNetwork () const
   16.45 +{
   16.46 +  return m_network;
   16.47 +}
   16.48 +
   16.49 +void RadvdPrefix::SetNetwork (Ipv6Address network)
   16.50 +{
   16.51 +  m_network = network;
   16.52 +}
   16.53 +
   16.54 +uint8_t RadvdPrefix::GetPrefixLength () const
   16.55 +{
   16.56 +  return m_prefixLength;
   16.57 +}
   16.58 +
   16.59 +void RadvdPrefix::SetPrefixLength (uint8_t prefixLength)
   16.60 +{
   16.61 +  m_prefixLength = prefixLength;
   16.62 +}
   16.63 +
   16.64 +uint32_t RadvdPrefix::GetValidLifeTime () const
   16.65 +{
   16.66 +  return m_validLifeTime;
   16.67 +}
   16.68 +
   16.69 +void RadvdPrefix::SetValidLifeTime (uint32_t validLifeTime)
   16.70 +{
   16.71 +  m_validLifeTime = validLifeTime;
   16.72 +}
   16.73 +
   16.74 +uint32_t RadvdPrefix::GetPreferredLifeTime () const
   16.75 +{
   16.76 +  return m_preferredLifeTime;
   16.77 +}
   16.78 +
   16.79 +void RadvdPrefix::SetPreferredLifeTime (uint32_t preferredLifeTime)
   16.80 +{
   16.81 +  m_preferredLifeTime = preferredLifeTime;
   16.82 +}
   16.83 +
   16.84 +bool RadvdPrefix::IsOnLinkFlag () const
   16.85 +{
   16.86 +  return m_onLinkFlag;
   16.87 +}
   16.88 +
   16.89 +void RadvdPrefix::SetOnLinkFlag (bool onLinkFlag)
   16.90 +{
   16.91 +  m_onLinkFlag = onLinkFlag;
   16.92 +}
   16.93 +
   16.94 +bool RadvdPrefix::IsAutonomousFlag () const
   16.95 +{
   16.96 +  return m_autonomousFlag; 
   16.97 +}
   16.98 +
   16.99 +void RadvdPrefix::SetAutonomousFlag (bool autonomousFlag)
  16.100 +{
  16.101 +  m_autonomousFlag = autonomousFlag;
  16.102 +}
  16.103 +
  16.104 +bool RadvdPrefix::IsRouterAddrFlag () const
  16.105 +{
  16.106 +  return m_routerAddrFlag;
  16.107 +}
  16.108 +
  16.109 +void RadvdPrefix::SetRouterAddrFlag (bool routerAddrFlag)
  16.110 +{
  16.111 +  m_routerAddrFlag = routerAddrFlag;
  16.112 +}
  16.113 +
  16.114 +} /* namespace ns3 */
  16.115 +
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/applications/radvd/radvd-prefix.h	Sat Aug 22 14:36:55 2009 -0700
    17.3 @@ -0,0 +1,180 @@
    17.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    17.5 +/*
    17.6 + * Copyright (c) 2009 Strasbourg University
    17.7 + *
    17.8 + * This program is free software; you can redistribute it and/or modify
    17.9 + * it under the terms of the GNU General Public License version 2 as
   17.10 + * published by the Free Software Foundation;
   17.11 + *
   17.12 + * This program is distributed in the hope that it will be useful,
   17.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17.15 + * GNU General Public License for more details.
   17.16 + *
   17.17 + * You should have received a copy of the GNU General Public License
   17.18 + * along with this program; if not, write to the Free Software
   17.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   17.20 + *
   17.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   17.22 + */
   17.23 +
   17.24 +#ifndef RADVD_PREFIX_H
   17.25 +#define RADVD_PREFIX_H 
   17.26 +
   17.27 +#include <stdint.h>
   17.28 +
   17.29 +#include "ns3/ipv6-address.h"
   17.30 +
   17.31 +namespace ns3
   17.32 +{
   17.33 +
   17.34 +/**
   17.35 + * \class RadvdPrefix
   17.36 + * \brief Router prefix for radvd application.
   17.37 + */
   17.38 +class RadvdPrefix : public RefCountBase
   17.39 +{
   17.40 +  public:
   17.41 +    /**
   17.42 +     * \brief Constructor.
   17.43 +     * \param network network prefix advertised
   17.44 +     * \param prefixLength prefix length ( 0 < x <= 128)
   17.45 +     * \param preferredLifeTime preferred life time in seconds (default 7 days)
   17.46 +     * \param validLifeTime valid life time in seconds (default 30 days)
   17.47 +     * \param onLinkFlag on link flag
   17.48 +     * \param autonomousFlag autonomous link flag
   17.49 +     * \param routerAddrFlag router address flag (for Mobile IPv6)
   17.50 +     */
   17.51 +    RadvdPrefix (Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime = 604800, uint32_t validLifeTime = 2592000, bool onLinkFlag = true, bool autonomousFlag = true, bool routerAddrFlag = false);
   17.52 +
   17.53 +    /**
   17.54 +     * \brief Destructor.
   17.55 +     */
   17.56 +    ~RadvdPrefix ();
   17.57 +
   17.58 +    /**
   17.59 +     * \brief Get network prefix.
   17.60 +     * \return network prefix
   17.61 +     */
   17.62 +    Ipv6Address GetNetwork () const;
   17.63 +
   17.64 +    /**
   17.65 +     * \brief Set network prefix.
   17.66 +     * \param network network prefix
   17.67 +     */
   17.68 +    void SetNetwork (Ipv6Address network);
   17.69 +
   17.70 +    /**
   17.71 +     * \brief Get prefix length.
   17.72 +     * \return prefix length
   17.73 +     */
   17.74 +    uint8_t GetPrefixLength () const;
   17.75 +
   17.76 +    /**
   17.77 +     * \brief Set prefix length.
   17.78 +     * \param prefixLength prefix length
   17.79 +     */
   17.80 +    void SetPrefixLength (uint8_t prefixLength);
   17.81 +
   17.82 +    /**
   17.83 +     * \brief Get preferred lifetime.
   17.84 +     * \return lifetime
   17.85 +     */
   17.86 +    uint32_t GetPreferredLifeTime () const;
   17.87 +
   17.88 +    /**
   17.89 +     * \brief Set preferred lifetime.
   17.90 +     * \param preferredLifeTime lifetime
   17.91 +     */
   17.92 +    void SetPreferredLifeTime (uint32_t preferredLifeTime);
   17.93 +
   17.94 +    /**
   17.95 +     * \brief Get valid lifetime.
   17.96 +     * \return lifetime
   17.97 +     */
   17.98 +    uint32_t GetValidLifeTime () const;
   17.99 +
  17.100 +    /**
  17.101 +     * \brief Set valid lifetime.
  17.102 +     * \param validLifeTime lifetime
  17.103 +     */
  17.104 +    void SetValidLifeTime (uint32_t validLifeTime);
  17.105 +
  17.106 +    /**
  17.107 +     * \brief Is on-link flag ?
  17.108 +     * \return true if on-link is activated, false otherwise
  17.109 +     */
  17.110 +    bool IsOnLinkFlag () const;
  17.111 +
  17.112 +    /**
  17.113 +     * \brief Set on-link flag.
  17.114 +     * \param onLinkFlag value
  17.115 +     */
  17.116 +    void SetOnLinkFlag (bool onLinkFlag);
  17.117 +
  17.118 +    /**
  17.119 +     * \brief Is autonomous flag ?
  17.120 +     * \return true if autonomous is activated, false otherwise
  17.121 +     */
  17.122 +    bool IsAutonomousFlag () const;
  17.123 +
  17.124 +    /**
  17.125 +     * \brief Set autonomous flag.
  17.126 +     * \param autonomousFlag value
  17.127 +     */
  17.128 +    void SetAutonomousFlag (bool autonomousFlag);
  17.129 +
  17.130 +    /**
  17.131 +     * \brief Is router address flag ?
  17.132 +     * \return true if router address is activated, false otherwise
  17.133 +     */
  17.134 +    bool IsRouterAddrFlag () const;
  17.135 +
  17.136 +    /**
  17.137 +     * \brief Set router address flag.
  17.138 +     * \param routerAddrFlag value
  17.139 +     */
  17.140 +    void SetRouterAddrFlag (bool routerAddrFlag);
  17.141 +
  17.142 +  private:
  17.143 +    /**
  17.144 +     * \brief Network prefix.
  17.145 +     */
  17.146 +    Ipv6Address m_network;
  17.147 +
  17.148 +    /**
  17.149 +     * \brief Prefix length.
  17.150 +     */
  17.151 +    uint8_t m_prefixLength;
  17.152 +
  17.153 +    /**
  17.154 +     * \brief Preferred time.
  17.155 +     */
  17.156 +    uint32_t m_preferredLifeTime;
  17.157 +
  17.158 +    /**
  17.159 +     * \brief Valid time.
  17.160 +     */
  17.161 +    uint32_t m_validLifeTime;
  17.162 +
  17.163 +    /**
  17.164 +     * \brief On link flag, indicates that this prefix can be used for on-link determination.
  17.165 +     */
  17.166 +    bool m_onLinkFlag;
  17.167 +
  17.168 +    /**
  17.169 +     * \brief Autonomous flag, it is used for autonomous address configuration (RFC 2462).
  17.170 +     */
  17.171 +    bool m_autonomousFlag;
  17.172 +
  17.173 +    /**
  17.174 +     * \brief Router address flag, indicates that router address is sent instead 
  17.175 +     * of network prefix as is required by Mobile IPv6.
  17.176 +     */
  17.177 +    bool m_routerAddrFlag;
  17.178 +};
  17.179 +
  17.180 +} /* namespace ns3 */
  17.181 +
  17.182 +#endif /* RADVD_PREFIX_H */
  17.183 +
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/applications/radvd/radvd.cc	Sat Aug 22 14:36:55 2009 -0700
    18.3 @@ -0,0 +1,273 @@
    18.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    18.5 +/*
    18.6 + * Copyright (c) 2008 Telecom Bretagne
    18.7 + * Copyright (c) 2009 Strasbourg University
    18.8 + *
    18.9 + * This program is free software; you can redistribute it and/or modify
   18.10 + * it under the terms of the GNU General Public License version 2 as
   18.11 + * published by the Free Software Foundation;
   18.12 + *
   18.13 + * This program is distributed in the hope that it will be useful,
   18.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18.16 + * GNU General Public License for more details.
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License
   18.19 + * along with this program; if not, write to the Free Software
   18.20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   18.21 + *
   18.22 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   18.23 + *         Mehdi Benamor <benamor.mehdi@ensi.rnu.tn>
   18.24 + */
   18.25 +
   18.26 +#include "ns3/log.h"
   18.27 +#include "ns3/ipv6-address.h"
   18.28 +#include "ns3/nstime.h"
   18.29 +#include "ns3/simulator.h"
   18.30 +#include "ns3/packet.h"
   18.31 +#include "ns3/net-device.h"
   18.32 +#include "ns3/uinteger.h"
   18.33 +#include "ns3/random-variable.h"
   18.34 +#include "ns3/inet6-socket-address.h"
   18.35 +#include "ns3/ipv6.h"
   18.36 +#include "ns3/ipv6-raw-socket-factory.h"
   18.37 +#include "ns3/ipv6-header.h"
   18.38 +#include "ns3/icmpv6-header.h"
   18.39 +
   18.40 +#include "radvd.h"
   18.41 +
   18.42 +namespace ns3
   18.43 +{
   18.44 +
   18.45 +NS_LOG_COMPONENT_DEFINE ("RadvdApplication");
   18.46 +
   18.47 +NS_OBJECT_ENSURE_REGISTERED (Radvd);
   18.48 +
   18.49 +TypeId Radvd::GetTypeId ()
   18.50 +{
   18.51 +  static TypeId tid = TypeId ("ns3::Radvd")
   18.52 +    .SetParent<Application> ()
   18.53 +    .AddConstructor<Radvd> ()
   18.54 +  ;
   18.55 +  return tid;
   18.56 +}
   18.57 + 
   18.58 +Radvd::Radvd ()
   18.59 +{
   18.60 +  NS_LOG_FUNCTION_NOARGS ();
   18.61 +}
   18.62 +
   18.63 +Radvd::~Radvd ()
   18.64 +{
   18.65 +  NS_LOG_FUNCTION_NOARGS ();
   18.66 +  for (RadvdInterfaceListI it = m_configurations.begin () ; it != m_configurations.end () ; ++it)
   18.67 +  {
   18.68 +    *it = 0;
   18.69 +  }
   18.70 +  m_configurations.clear ();
   18.71 +  m_socket = 0;
   18.72 +}
   18.73 +
   18.74 +void Radvd::DoDispose ()
   18.75 +{
   18.76 +  NS_LOG_FUNCTION_NOARGS ();
   18.77 +  Application::DoDispose ();
   18.78 +}
   18.79 +
   18.80 +void Radvd::StartApplication ()
   18.81 +{
   18.82 +  NS_LOG_FUNCTION_NOARGS ();
   18.83 +
   18.84 +  if (!m_socket)
   18.85 +  {
   18.86 +    TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory");
   18.87 +    m_socket = Socket::CreateSocket (GetNode (), tid);
   18.88 +
   18.89 +    NS_ASSERT (m_socket);
   18.90 +
   18.91 +/*    m_socket->Bind (Inet6SocketAddress (m_localAddress, 0)); */
   18.92 +/*    m_socket->Connect (Inet6SocketAddress (Ipv6Address::GetAllNodesMulticast (), 0)); */
   18.93 +    m_socket->SetAttribute ("Protocol", UintegerValue (58)); /* ICMPv6 */
   18.94 +    m_socket->SetRecvCallback (MakeCallback (&Radvd::HandleRead, this));
   18.95 +  }
   18.96 +
   18.97 +  for (RadvdInterfaceListCI it = m_configurations.begin () ; it != m_configurations.end () ; it++)
   18.98 +  {
   18.99 +    m_eventIds[(*it)->GetInterface ()] = EventId ();
  18.100 +    ScheduleTransmit (Seconds (0.), (*it), m_eventIds[(*it)->GetInterface ()]);
  18.101 +  }
  18.102 +}
  18.103 +
  18.104 +void Radvd::StopApplication ()
  18.105 +{
  18.106 +  NS_LOG_FUNCTION_NOARGS ();
  18.107 +
  18.108 +  if (m_socket)
  18.109 +  {
  18.110 +    m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
  18.111 +  }
  18.112 +
  18.113 +  for (EventIdMapI it = m_eventIds.begin () ; it != m_eventIds.end () ; ++it)
  18.114 +  {
  18.115 +    Simulator::Cancel ((*it).second);
  18.116 +  }
  18.117 +  m_eventIds.clear ();
  18.118 +}
  18.119 +
  18.120 +void Radvd::AddConfiguration (Ptr<RadvdInterface> routerInterface)
  18.121 +{
  18.122 +  m_configurations.push_back (routerInterface);
  18.123 +}
  18.124 +
  18.125 +void Radvd::ScheduleTransmit (Time dt, Ptr<RadvdInterface> config, EventId& eventId)
  18.126 +{
  18.127 +  NS_LOG_FUNCTION (this << dt);
  18.128 +  eventId = Simulator::Schedule (dt, &Radvd::Send, this, config, Ipv6Address::GetAllNodesMulticast ());
  18.129 +}
  18.130 +
  18.131 +void Radvd::Send (Ptr<RadvdInterface> config, Ipv6Address dst)
  18.132 +{
  18.133 +  NS_LOG_FUNCTION (this << dst);
  18.134 +  NS_ASSERT (m_eventIds[config->GetInterface ()].IsExpired ());
  18.135 +  Icmpv6RA raHdr;
  18.136 +  Icmpv6OptionLinkLayerAddress llaHdr;
  18.137 +  Icmpv6OptionMtu mtuHdr;
  18.138 +  Icmpv6OptionPrefixInformation prefixHdr;
  18.139 +
  18.140 +  if (m_eventIds.size () == 0)
  18.141 +  {
  18.142 +    return;
  18.143 +  }
  18.144 +
  18.145 +  std::list<Ptr<RadvdPrefix> > prefixes = config->GetPrefixes ();
  18.146 +  Ptr<Packet> p = Create<Packet> ();
  18.147 +  Ptr<Ipv6> ipv6 = GetNode ()->GetObject<Ipv6> ();
  18.148 +
  18.149 +  /* set RA header information */
  18.150 +  raHdr.SetFlagM (config->IsManagedFlag ());
  18.151 +  raHdr.SetFlagO (config->IsOtherConfigFlag ());
  18.152 +  raHdr.SetFlagH (config->IsHomeAgentFlag ());
  18.153 +  raHdr.SetCurHopLimit (config->GetCurHopLimit ());
  18.154 +  raHdr.SetLifeTime (config->GetDefaultLifeTime ());
  18.155 +  raHdr.SetReachableTime (config->GetReachableTime ());
  18.156 +  raHdr.SetRetransmissionTime (config->GetRetransTimer ());
  18.157 +    
  18.158 +  if (config->IsSourceLLAddress ())
  18.159 +  {
  18.160 +    /* Get L2 address from NetDevice */
  18.161 +    Address addr = ipv6->GetNetDevice (config->GetInterface ())->GetAddress ();
  18.162 +    llaHdr = Icmpv6OptionLinkLayerAddress (true, addr);
  18.163 +    p->AddHeader (llaHdr);
  18.164 +  }
  18.165 +
  18.166 +  if (config->GetLinkMtu ())
  18.167 +  {
  18.168 +    NS_ASSERT (config->GetLinkMtu () >= 1280);
  18.169 +    mtuHdr = Icmpv6OptionMtu (config->GetLinkMtu ());
  18.170 +    p->AddHeader (mtuHdr);
  18.171 +  }
  18.172 +
  18.173 +  /* add list of prefixes */
  18.174 +  for (std::list<Ptr<RadvdPrefix> >::const_iterator jt = prefixes.begin () ; jt != prefixes.end () ; jt++)
  18.175 +  {
  18.176 +    uint8_t flags = 0;
  18.177 +    prefixHdr = Icmpv6OptionPrefixInformation ();
  18.178 +    prefixHdr.SetPrefix ((*jt)->GetNetwork ());
  18.179 +    prefixHdr.SetPrefixLength ((*jt)->GetPrefixLength ());
  18.180 +    prefixHdr.SetValidTime ((*jt)->GetValidLifeTime ());
  18.181 +    prefixHdr.SetPreferredTime ((*jt)->GetPreferredLifeTime ());
  18.182 +
  18.183 +    if ((*jt)->IsOnLinkFlag ())
  18.184 +    {
  18.185 +       flags += 1 << 7;
  18.186 +    }
  18.187 +    
  18.188 +    if ((*jt)->IsAutonomousFlag ())
  18.189 +    {
  18.190 +      flags += 1 << 6;
  18.191 +    }
  18.192 +
  18.193 +    if ((*jt)->IsRouterAddrFlag ())
  18.194 +    {
  18.195 +      flags += 1 << 5;
  18.196 +    }
  18.197 +
  18.198 +    prefixHdr.SetFlags (flags);
  18.199 +
  18.200 +    p->AddHeader (prefixHdr);
  18.201 +  }
  18.202 +
  18.203 +  Ipv6Address src = ipv6->GetAddress (config->GetInterface (), 0).GetAddress ();
  18.204 +  m_socket->Bind (Inet6SocketAddress (src, 0));
  18.205 +  m_socket->Connect (Inet6SocketAddress (dst, 0));
  18.206 +
  18.207 +  /* as we know interface index that will be used to send RA and 
  18.208 +   * we always send RA with router's link-local address, we can 
  18.209 +   * calculate checksum here.
  18.210 +   */
  18.211 +  raHdr.CalculatePseudoHeaderChecksum (src, dst, p->GetSize () + raHdr.GetSerializedSize (), 58 /* ICMPv6 */);
  18.212 +  p->AddHeader (raHdr);
  18.213 +
  18.214 +  /* send RA */
  18.215 +  NS_LOG_LOGIC ("Send RA");
  18.216 +  m_socket->Send (p, 0);
  18.217 +
  18.218 +  UniformVariable rnd;
  18.219 +  uint32_t delay = rnd.GetValue (config->GetMinRtrAdvInterval (), config->GetMaxRtrAdvInterval ());
  18.220 +  Time t = MilliSeconds (delay);
  18.221 +  ScheduleTransmit (t, config, m_eventIds[config->GetInterface ()]);
  18.222 +}
  18.223 +
  18.224 +void Radvd::HandleRead (Ptr<Socket> socket)
  18.225 +{
  18.226 +  NS_LOG_FUNCTION (this << socket);
  18.227 +  Ptr<Packet> packet = 0;
  18.228 +  Address from;
  18.229 +
  18.230 +  while (packet = socket->RecvFrom (from))
  18.231 +  {
  18.232 +    if (Inet6SocketAddress::IsMatchingType (from))
  18.233 +    {
  18.234 +      Ipv6Header hdr;
  18.235 +      Icmpv6RS rsHdr;
  18.236 +      Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from);
  18.237 +      uint32_t delay = 0;
  18.238 +      UniformVariable rnd;
  18.239 +      Time t;
  18.240 +
  18.241 +      packet->RemoveHeader (hdr);
  18.242 +
  18.243 +      switch (*packet->PeekData ())
  18.244 +      {
  18.245 +        case Icmpv6Header::ICMPV6_ND_ROUTER_SOLICITATION:
  18.246 +          /* send RA in response of a RS */
  18.247 +          packet->RemoveHeader (rsHdr);
  18.248 +          NS_LOG_INFO ("Received ICMPv6 Router Solicitation from " << hdr.GetSourceAddress () << " code = " << (uint32_t)rsHdr.GetCode ());
  18.249 +
  18.250 +          delay = rnd.GetValue (0, 500); /* default value for MAX_RA_DELAY_TIME */
  18.251 +          t = Simulator::Now () + MilliSeconds (delay);
  18.252 +
  18.253 +#if 0
  18.254 +          NS_LOG_INFO ("schedule new RA : " << t.GetTimeStep () << " next scheduled RA" << (int64_t)m_sendEvent.GetTs ());
  18.255 +
  18.256 +          if (t.GetTimeStep () < (int64_t)m_sendEvent.GetTs ())
  18.257 +          {
  18.258 +            /* send multicast RA */
  18.259 +            /* maybe replace this by a unicast RA (it is a SHOULD in the RFC) */
  18.260 +            NS_LOG_INFO ("Respond to RS");
  18.261 +            /* XXX advertise just the prefix for the interface not all */
  18.262 +            t = MilliSeconds (delay);
  18.263 +            /* XXX schedule packet send */
  18.264 +            /* ScheduleTransmit (t); */
  18.265 +          }
  18.266 +#endif
  18.267 +          break;
  18.268 +        default:
  18.269 +          break;
  18.270 +      }
  18.271 +    }
  18.272 +  }
  18.273 +}
  18.274 +
  18.275 +} /* namespace ns3 */
  18.276 +
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/applications/radvd/radvd.h	Sat Aug 22 14:36:55 2009 -0700
    19.3 @@ -0,0 +1,130 @@
    19.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    19.5 +/*
    19.6 + * Copyright (c) 2008 Telecom Bretagne
    19.7 + * Copyright (c) 2009 Strasbourg University
    19.8 + *
    19.9 + * This program is free software; you can redistribute it and/or modify
   19.10 + * it under the terms of the GNU General Public License version 2 as
   19.11 + * published by the Free Software Foundation;
   19.12 + *
   19.13 + * This program is distributed in the hope that it will be useful,
   19.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19.16 + * GNU General Public License for more details.
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License
   19.19 + * along with this program; if not, write to the Free Software
   19.20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19.21 + *
   19.22 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   19.23 + *         Mehdi Benamor <benamor.mehdi@ensi.rnu.tn>
   19.24 + */
   19.25 +
   19.26 +#ifndef RADVD_H
   19.27 +#define RADVD_H
   19.28 +
   19.29 +#include <map>
   19.30 +
   19.31 +#include "ns3/application.h"
   19.32 +#include "ns3/socket.h"
   19.33 +
   19.34 +#include "radvd-interface.h"
   19.35 +
   19.36 +namespace ns3
   19.37 +{
   19.38 +
   19.39 +/**
   19.40 + * \class Radvd
   19.41 + * \brief Router advertisement daemon.
   19.42 + */
   19.43 +class Radvd : public Application
   19.44 +{
   19.45 +  public:
   19.46 +     /**
   19.47 +      * \brief Get the type ID.
   19.48 +      * \return type ID
   19.49 +      */
   19.50 +     static TypeId GetTypeId (void);
   19.51 +
   19.52 +     /**
   19.53 +      * \brief Constructor.
   19.54 +      */
   19.55 +     Radvd ();
   19.56 +
   19.57 +    /**
   19.58 +     * \brief Destructor.
   19.59 +     */
   19.60 +    virtual ~Radvd ();
   19.61 +
   19.62 +    /**
   19.63 +     * \brief Add configuration for an interface;
   19.64 +     * \param routerInterface configuration
   19.65 +     */
   19.66 +    void AddConfiguration (Ptr<RadvdInterface> routerInterface);
   19.67 +
   19.68 +  protected:
   19.69 +    /**
   19.70 +     * \brief Dispose the instance.
   19.71 +     */
   19.72 +    virtual void DoDispose ();
   19.73 +  
   19.74 +  private:
   19.75 +    typedef std::list<Ptr<RadvdInterface> > RadvdInterfaceList;
   19.76 +    typedef std::list<Ptr<RadvdInterface> >::iterator RadvdInterfaceListI;
   19.77 +    typedef std::list<Ptr<RadvdInterface> >::const_iterator RadvdInterfaceListCI;
   19.78 +
   19.79 +    typedef std::map<uint32_t, EventId> EventIdMap;
   19.80 +    typedef std::map<uint32_t, EventId>::iterator EventIdMapI;
   19.81 +    typedef std::map<uint32_t, EventId>::const_iterator EventIdMapCI;
   19.82 +
   19.83 +    /**
   19.84 +     * \brief Start the application.
   19.85 +     */
   19.86 +    virtual void StartApplication ();
   19.87 +
   19.88 +    /**
   19.89 +     * \brief Stop the application.
   19.90 +     */
   19.91 +    virtual void StopApplication ();
   19.92 +
   19.93 +    /**
   19.94 +     * \brief Schedule sending a packet.
   19.95 +     * \param dt interval between packet
   19.96 +     * \param config interface configuration
   19.97 +     * \param eventId event ID associated
   19.98 +     */
   19.99 +    void ScheduleTransmit (Time dt, Ptr<RadvdInterface> config, EventId& eventId);
  19.100 +
  19.101 +    /**
  19.102 +     * \brief Send a packet.
  19.103 +     * \param config interface configuration
  19.104 +     * \param dst destination address (default ff02::1)
  19.105 +     */
  19.106 +    void Send (Ptr<RadvdInterface> config, Ipv6Address dst = Ipv6Address::GetAllNodesMulticast ());
  19.107 +
  19.108 +    /**
  19.109 +     * \brief Handle received packet, especially router solicitation
  19.110 +     * \param socket socket to read data from
  19.111 +     */
  19.112 +    void HandleRead (Ptr<Socket> socket);
  19.113 +
  19.114 +    /**
  19.115 +     * \brief Raw socket to send RA.
  19.116 +     */
  19.117 +    Ptr<Socket> m_socket;
  19.118 +
  19.119 +    /**
  19.120 +     * \brief List of configuration for interface.
  19.121 +     */
  19.122 +    RadvdInterfaceList m_configurations;
  19.123 +
  19.124 +    /**
  19.125 +     * \brief Event ID map.
  19.126 +     */
  19.127 +    EventIdMap m_eventIds;
  19.128 +};
  19.129 +
  19.130 +} /* namespace ns3 */
  19.131 +
  19.132 +#endif /* RADVD_H */
  19.133 +
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/applications/radvd/wscript	Sat Aug 22 14:36:55 2009 -0700
    20.3 @@ -0,0 +1,17 @@
    20.4 +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
    20.5 +
    20.6 +def build(bld):
    20.7 +    module = bld.create_ns3_module('radvd', ['internet-stack'])
    20.8 +    module.source = [
    20.9 +        'radvd.cc',
   20.10 +        'radvd-interface.cc',
   20.11 +        'radvd-prefix.cc',
   20.12 +        ]
   20.13 +    headers = bld.new_task_gen('ns3header')
   20.14 +    headers.module = 'radvd'
   20.15 +    headers.source = [
   20.16 +        'radvd.h',
   20.17 +        'radvd-interface.h',
   20.18 +        'radvd-prefix.h',
   20.19 +        ]
   20.20 +
    21.1 --- a/src/helper/internet-stack-helper.cc	Sun Aug 23 14:00:50 2009 -0700
    21.2 +++ b/src/helper/internet-stack-helper.cc	Sat Aug 22 14:36:55 2009 -0700
    21.3 @@ -153,6 +153,7 @@
    21.4  #include "ns3/object.h"
    21.5  #include "ns3/names.h"
    21.6  #include "ns3/ipv4.h"
    21.7 +#include "ns3/ipv6.h"
    21.8  #include "ns3/packet-socket-factory.h"
    21.9  #include "ns3/config.h"
   21.10  #include "ns3/simulator.h"
   21.11 @@ -167,6 +168,8 @@
   21.12  #include "ipv4-list-routing-helper.h"
   21.13  #include "ipv4-static-routing-helper.h"
   21.14  #include "ipv4-global-routing-helper.h"
   21.15 +#include "ipv6-list-routing-helper.h"
   21.16 +#include "ipv6-static-routing-helper.h"
   21.17  #include <limits>
   21.18  
   21.19  namespace ns3 {
   21.20 @@ -176,19 +179,28 @@
   21.21  bool InternetStackHelper::m_isInitialized = false;
   21.22  
   21.23  InternetStackHelper::InternetStackHelper ()
   21.24 +  : m_ipv4Enabled (true),
   21.25 +  m_ipv6Enabled (true)
   21.26  {
   21.27    SetTcp ("ns3::TcpL4Protocol");
   21.28    static Ipv4StaticRoutingHelper staticRouting;
   21.29    static Ipv4GlobalRoutingHelper globalRouting;
   21.30    static Ipv4ListRoutingHelper listRouting;
   21.31 +  static Ipv6ListRoutingHelper listRoutingv6;
   21.32 +  static Ipv6StaticRoutingHelper staticRoutingv6;
   21.33    if (m_isInitialized == false)
   21.34      {
   21.35        // Only add these once
   21.36        listRouting.Add (staticRouting, 0);
   21.37        listRouting.Add (globalRouting, -10);
   21.38 +
   21.39 +      /* IPv6 */
   21.40 +      listRoutingv6.Add (staticRoutingv6, 0);
   21.41 +      /* TODO add IPv6 global routing */
   21.42        m_isInitialized = true;
   21.43      }
   21.44    SetRoutingHelper (listRouting);
   21.45 +  SetRoutingHelper (listRoutingv6);
   21.46  }
   21.47  
   21.48  void 
   21.49 @@ -198,9 +210,26 @@
   21.50  }
   21.51  
   21.52  void
   21.53 +InternetStackHelper::SetRoutingHelper (const Ipv6RoutingHelper &routing)
   21.54 +{
   21.55 +  m_routingv6 = &routing;
   21.56 +}
   21.57 +
   21.58 +void
   21.59 +InternetStackHelper::SetIpv4StackInstall (bool enable)
   21.60 +{
   21.61 +  m_ipv4Enabled = enable;
   21.62 +}
   21.63 +
   21.64 +void InternetStackHelper::SetIpv6StackInstall (bool enable)
   21.65 +{
   21.66 +  m_ipv6Enabled = enable;
   21.67 +}
   21.68 +
   21.69 +void
   21.70  InternetStackHelper::Cleanup (void)
   21.71  {
   21.72 -  uint32_t illegal = std::numeric_limits<uint32_t>::max();
   21.73 +  uint32_t illegal = std::numeric_limits<uint32_t>::max ();
   21.74  
   21.75    for (std::vector<Trace>::iterator i = m_traces.begin ();
   21.76         i != m_traces.end (); i++)
   21.77 @@ -244,7 +273,7 @@
   21.78  InternetStackHelper::CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::string typeId)
   21.79  {
   21.80    ObjectFactory factory;
   21.81 -  factory.SetTypeId(typeId);
   21.82 +  factory.SetTypeId (typeId);
   21.83    Ptr<Object> protocol = factory.Create <Object> ();
   21.84    node->AggregateObject (protocol);
   21.85  }
   21.86 @@ -252,24 +281,45 @@
   21.87  void
   21.88  InternetStackHelper::Install (Ptr<Node> node) const
   21.89  {
   21.90 -  if (node->GetObject<Ipv4> () != 0)
   21.91 +  if (m_ipv4Enabled)
   21.92      {
   21.93 -      NS_FATAL_ERROR ("InternetStackHelper::Install(): Aggregating " 
   21.94 -                      "an InternetStack to a node with an existing Ipv4 object");
   21.95 -      return;
   21.96 +      if (node->GetObject<Ipv4> () != 0)
   21.97 +        {
   21.98 +          NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating " 
   21.99 +                          "an InternetStack to a node with an existing Ipv4 object");
  21.100 +          return;
  21.101 +        }
  21.102 +
  21.103 +      CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol");
  21.104 +      CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol");
  21.105 +      CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
  21.106 +      CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
  21.107 +      node->AggregateObject (m_tcpFactory.Create<Object> ());
  21.108 +      Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
  21.109 +      node->AggregateObject (factory);
  21.110 +      // Set routing
  21.111 +      Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
  21.112 +      Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
  21.113 +      ipv4->SetRoutingProtocol (ipv4Routing);
  21.114      }
  21.115  
  21.116 -  CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol");
  21.117 -  CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol");
  21.118 -  CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
  21.119 -  CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
  21.120 -  node->AggregateObject (m_tcpFactory.Create<Object> ());
  21.121 -  Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
  21.122 -  node->AggregateObject (factory);
  21.123 -  // Set routing
  21.124 -  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
  21.125 -  Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
  21.126 -  ipv4->SetRoutingProtocol (ipv4Routing);
  21.127 +  if (m_ipv6Enabled)
  21.128 +    {
  21.129 +      /* IPv6 stack */
  21.130 +      if (node->GetObject<Ipv6> () != 0)
  21.131 +        {
  21.132 +          NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating " 
  21.133 +                          "an InternetStack to a node with an existing Ipv6 object");
  21.134 +          return;
  21.135 +        }
  21.136 +    
  21.137 +      CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv6L3Protocol");
  21.138 +      CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol");
  21.139 +      /* TODO add UdpL4Protocol / TcpL4Protocol for IPv6 */
  21.140 +      Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
  21.141 +      Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create (node);
  21.142 +      ipv6->SetRoutingProtocol (ipv6Routing);
  21.143 +    }
  21.144  }
  21.145  
  21.146  void
  21.147 @@ -293,6 +343,9 @@
  21.148        oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop";
  21.149        Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, writer));
  21.150        oss.str ("");
  21.151 +      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop";
  21.152 +      Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, writer));
  21.153 +      oss.str ("");
  21.154      }
  21.155  }
  21.156  
  21.157 @@ -312,6 +365,12 @@
  21.158                     MakeCallback (&InternetStackHelper::LogTxIp));
  21.159    Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Rx",
  21.160                     MakeCallback (&InternetStackHelper::LogRxIp));
  21.161 +
  21.162 +  /* IPv6 */
  21.163 +  Config::Connect ("/NodeList/*/$ns3::Ipv6L3Protocol/Tx",
  21.164 +                   MakeCallback (&InternetStackHelper::LogTxIp));
  21.165 +  Config::Connect ("/NodeList/*/$ns3::Ipv6L3Protocol/Rx",
  21.166 +                   MakeCallback (&InternetStackHelper::LogRxIp));
  21.167  }
  21.168  
  21.169  uint32_t
    22.1 --- a/src/helper/internet-stack-helper.h	Sun Aug 23 14:00:50 2009 -0700
    22.2 +++ b/src/helper/internet-stack-helper.h	Sat Aug 22 14:36:55 2009 -0700
    22.3 @@ -31,6 +31,7 @@
    22.4  
    22.5  class Node;
    22.6  class Ipv4RoutingHelper;
    22.7 +class Ipv6RoutingHelper;
    22.8  
    22.9  /**
   22.10   * \brief aggregate IP/TCP/UDP functionality to existing Nodes.
   22.11 @@ -59,9 +60,15 @@
   22.12     * ns3::Ipv4::SetRoutingProtocol.
   22.13     */
   22.14    void SetRoutingHelper (const Ipv4RoutingHelper &routing);
   22.15 +  
   22.16 +  /**
   22.17 +   * \brief Set IPv6 routing helper.
   22.18 +   * \param routing IPv6 routing helper
   22.19 +   */
   22.20 +  void SetRoutingHelper (const Ipv6RoutingHelper &routing);
   22.21  
   22.22    /**
   22.23 -   * Aggregate implementations of the ns3::Ipv4, ns3::Udp, and ns3::Tcp classes
   22.24 +   * Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes
   22.25     * onto the provided node.  This method will assert if called on a node that 
   22.26     * already has an Ipv4 object aggregated to it.
   22.27     * 
   22.28 @@ -70,7 +77,7 @@
   22.29    void Install (std::string nodeName) const;
   22.30  
   22.31    /**
   22.32 -   * Aggregate implementations of the ns3::Ipv4, ns3::Udp, and ns3::Tcp classes
   22.33 +   * Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes
   22.34     * onto the provided node.  This method will assert if called on a node that 
   22.35     * already has an Ipv4 object aggregated to it.
   22.36     * 
   22.37 @@ -80,7 +87,7 @@
   22.38  
   22.39    /**
   22.40     * For each node in the input container, aggregate implementations of the 
   22.41 -   * ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes.  The program will assert 
   22.42 +   * ns3::Ipv4, ns3::Ipv6, ns3::Udp, and, ns3::Tcp classes.  The program will assert 
   22.43     * if this method is called on a container with a node that already has
   22.44     * an Ipv4 object aggregated to it.
   22.45     * 
   22.46 @@ -90,11 +97,11 @@
   22.47    void Install (NodeContainer c) const;
   22.48  
   22.49    /**
   22.50 -   * Aggregate ip, udp, and tcp stacks to all nodes in the simulation
   22.51 +   * Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation
   22.52     */
   22.53    void InstallAll (void) const;
   22.54  
   22.55 - /**
   22.56 +  /**
   22.57     * \brief set the Tcp stack which will not need any other parameter.  
   22.58     *
   22.59     * This function sets up the tcp stack to the given TypeId. It should not be 
   22.60 @@ -128,6 +135,7 @@
   22.61     * Enable ascii output on these drop traces, for each node in the NodeContainer..
   22.62     * /NodeList/[i]/$ns3ArpL3Protocol/Drop 
   22.63     * /NodeList/[i]/$ns3Ipv4L3Protocol/Drop 
   22.64 +   * /NodeList/[i]/$ns3Ipv6L3Protocol/Drop 
   22.65     */
   22.66    static void EnableAscii (std::ostream &os, NodeContainer n);
   22.67  
   22.68 @@ -137,12 +145,14 @@
   22.69     * Enable ascii output on these drop traces, for all nodes.
   22.70     * /NodeList/[i]/$ns3ArpL3Protocol/Drop 
   22.71     * /NodeList/[i]/$ns3Ipv4L3Protocol/Drop 
   22.72 +   * /NodeList/[i]/$ns3Ipv6L3Protocol/Drop 
   22.73     */
   22.74    static void EnableAsciiAll (std::ostream &os);
   22.75  
   22.76    /**
   22.77     * Enable pcap output on each protocol instance which is of the
   22.78 -   * ns3::Ipv4L3Protocol type.  Both Tx and Rx events will be logged.
   22.79 +   * ns3::Ipv4L3Protocol or ns3::Ipv6L3Protocol type.  Both Tx and 
   22.80 +   * Rx events will be logged.
   22.81     *
   22.82     * \param filename filename prefix to use for pcap files.
   22.83     *
   22.84 @@ -155,9 +165,27 @@
   22.85     */
   22.86    static void EnablePcapAll (std::string filename);
   22.87  
   22.88 +  /**
   22.89 +   * \brief Enable/disable IPv4 stack install.
   22.90 +   * \param enable enable state
   22.91 +   */
   22.92 +  void SetIpv4StackInstall (bool enable);
   22.93 +
   22.94 +  /**
   22.95 +   * \brief Enable/disable IPv6 stack install.
   22.96 +   * \param enable enable state
   22.97 +   */
   22.98 +  void SetIpv6StackInstall (bool enable);
   22.99 +
  22.100  private:
  22.101    ObjectFactory m_tcpFactory;
  22.102    const Ipv4RoutingHelper *m_routing;
  22.103 +  
  22.104 +  /**
  22.105 +   * \brief IPv6 routing helper.
  22.106 +   */
  22.107 +  const Ipv6RoutingHelper *m_routingv6;
  22.108 +
  22.109    static void CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::string typeId);
  22.110    static void Cleanup (void);
  22.111    static void LogRxIp (std::string context, Ptr<const Packet> packet, uint32_t deviceId);
  22.112 @@ -173,6 +201,16 @@
  22.113    static uint32_t GetNodeIndex (std::string context);
  22.114    static std::vector<Trace> m_traces;
  22.115    static bool m_isInitialized;
  22.116 +
  22.117 +  /**
  22.118 +   * \brief IPv4 install state (enabled/disabled) ?
  22.119 +   */
  22.120 +  bool m_ipv4Enabled;
  22.121 +
  22.122 +  /**
  22.123 +   * \brief IPv6 install state (enabled/disabled) ?
  22.124 +   */
  22.125 +  bool m_ipv6Enabled;
  22.126  };
  22.127  
  22.128  } // namespace ns3
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/src/helper/ipv6-address-helper.cc	Sat Aug 22 14:36:55 2009 -0700
    23.3 @@ -0,0 +1,167 @@
    23.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    23.5 +/*
    23.6 + * Copyright (c) 2008-2009 Strasbourg University
    23.7 + *
    23.8 + * This program is free software; you can redistribute it and/or modify
    23.9 + * it under the terms of the GNU General Public License version 2 as
   23.10 + * published by the Free Software Foundation;
   23.11 + *
   23.12 + * This program is distributed in the hope that it will be useful,
   23.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   23.15 + * GNU General Public License for more details.
   23.16 + *
   23.17 + * You should have received a copy of the GNU General Public License
   23.18 + * along with this program; if not, write to the Free Software
   23.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23.20 + *
   23.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   23.22 + */
   23.23 +
   23.24 +#include "ns3/assert.h"
   23.25 +#include "ns3/log.h"
   23.26 +#include "ns3/ptr.h"
   23.27 +#include "ns3/node.h"
   23.28 +#include "ns3/net-device.h"
   23.29 +#include "ns3/mac48-address.h"
   23.30 +#include "ns3/ipv6.h"
   23.31 +
   23.32 +#include "ipv6-address-helper.h"
   23.33 +
   23.34 +namespace ns3 
   23.35 +{
   23.36 +
   23.37 +NS_LOG_COMPONENT_DEFINE ("Ipv6AddressHelper");
   23.38 +
   23.39 +Ipv6AddressHelper::Ipv6AddressHelper ()
   23.40 +{
   23.41 +  NS_LOG_FUNCTION_NOARGS ();
   23.42 +  m_network = Ipv6Address ("2001::");
   23.43 +  m_prefix = Ipv6Prefix (64);
   23.44 +}
   23.45 +
   23.46 +Ipv6Address Ipv6AddressHelper::NewAddress (Address addr)
   23.47 +{
   23.48 +  NS_LOG_FUNCTION (this << addr);
   23.49 +
   23.50 +  switch (addr.GetLength ())
   23.51 +  {
   23.52 +    case 6:
   23.53 +      return Ipv6Address::MakeAutoconfiguredAddress (Mac48Address::ConvertFrom (addr), m_network);
   23.54 +    default:
   23.55 +      return Ipv6Address ("::");
   23.56 +  }
   23.57 +  /* never reached */
   23.58 +  return Ipv6Address ("::");
   23.59 +}
   23.60 +
   23.61 +void Ipv6AddressHelper::NewNetwork (Ipv6Address network, Ipv6Prefix prefix)
   23.62 +{
   23.63 +  NS_LOG_FUNCTION (this << network << prefix);
   23.64 +
   23.65 +  m_network = network;
   23.66 +  m_prefix = prefix;
   23.67 +}
   23.68 +
   23.69 +Ipv6InterfaceContainer Ipv6AddressHelper::Assign (const NetDeviceContainer &c)
   23.70 +{
   23.71 +  NS_LOG_FUNCTION_NOARGS ();
   23.72 +  Ipv6InterfaceContainer retval;
   23.73 +
   23.74 +  for (uint32_t i = 0; i < c.GetN (); ++i) 
   23.75 +  {
   23.76 +    Ptr<NetDevice> device = c.Get (i);
   23.77 +
   23.78 +    Ptr<Node> node = device->GetNode ();
   23.79 +    NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node");
   23.80 +
   23.81 +    Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
   23.82 +    NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6");
   23.83 +    int32_t ifIndex = 0;
   23.84 +
   23.85 +    ifIndex = ipv6->GetInterfaceForDevice (device);
   23.86 +    if (ifIndex == -1)
   23.87 +    {
   23.88 +      ifIndex = ipv6->AddInterface (device);
   23.89 +    }
   23.90 +    NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): "
   23.91 +        "Interface index not found");
   23.92 +
   23.93 +    Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (NewAddress (device->GetAddress ()), m_prefix);
   23.94 +    ipv6->SetMetric (ifIndex, 1);
   23.95 +    ipv6->SetUp (ifIndex);
   23.96 +    ipv6->AddAddress (ifIndex, ipv6Addr);
   23.97 +
   23.98 +    retval.Add (ipv6, ifIndex);
   23.99 +  }
  23.100 +  return retval;
  23.101 +}
  23.102 +
  23.103 +Ipv6InterfaceContainer Ipv6AddressHelper::Assign (const NetDeviceContainer &c, std::vector<bool> withConfiguration)
  23.104 +{
  23.105 +  NS_LOG_FUNCTION_NOARGS ();
  23.106 +  Ipv6InterfaceContainer retval;
  23.107 +  for (uint32_t i = 0; i < c.GetN (); ++i) 
  23.108 +  {
  23.109 +    Ptr<NetDevice> device = c.Get (i);
  23.110 +
  23.111 +    Ptr<Node> node = device->GetNode ();
  23.112 +    NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node");
  23.113 +
  23.114 +    Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
  23.115 +    NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6");
  23.116 +
  23.117 +    int32_t ifIndex = ipv6->GetInterfaceForDevice (device);
  23.118 +    if (ifIndex == -1)
  23.119 +    {
  23.120 +      ifIndex = ipv6->AddInterface (device);
  23.121 +    }
  23.122 +    NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): "
  23.123 +        "Interface index not found");
  23.124 +
  23.125 +    ipv6->SetMetric (ifIndex, 1);
  23.126 +    ipv6->SetUp (ifIndex);
  23.127 +
  23.128 +    if (withConfiguration.at (i))
  23.129 +    {
  23.130 +      Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (NewAddress (device->GetAddress ()), m_prefix);
  23.131 +      ipv6->AddAddress (ifIndex, ipv6Addr);
  23.132 +    }
  23.133 +
  23.134 +    retval.Add (ipv6, ifIndex);
  23.135 +  }
  23.136 +  return retval;
  23.137 +}
  23.138 +
  23.139 +Ipv6InterfaceContainer Ipv6AddressHelper::AssignWithoutAddress (const NetDeviceContainer &c)
  23.140 +{
  23.141 +  NS_LOG_FUNCTION_NOARGS ();
  23.142 +  Ipv6InterfaceContainer retval;
  23.143 +  for (uint32_t i = 0; i < c.GetN (); ++i) 
  23.144 +  {
  23.145 +    Ptr<NetDevice> device = c.Get (i);
  23.146 +
  23.147 +    Ptr<Node> node = device->GetNode ();
  23.148 +    NS_ASSERT_MSG (node, "Ipv6AddressHelper::Allocate (): Bad node");
  23.149 +
  23.150 +    Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
  23.151 +    NS_ASSERT_MSG (ipv6, "Ipv6AddressHelper::Allocate (): Bad ipv6");
  23.152 +
  23.153 +    int32_t ifIndex = ipv6->GetInterfaceForDevice (device);
  23.154 +    if (ifIndex == -1)
  23.155 +    {
  23.156 +      ifIndex = ipv6->AddInterface (device);
  23.157 +    }
  23.158 +    NS_ASSERT_MSG (ifIndex >= 0, "Ipv6AddressHelper::Allocate (): "
  23.159 +        "Interface index not found");
  23.160 +
  23.161 +    ipv6->SetMetric (ifIndex, 1);
  23.162 +    ipv6->SetUp (ifIndex);
  23.163 +
  23.164 +    retval.Add (ipv6, ifIndex);
  23.165 +  }
  23.166 +  return retval;
  23.167 +}
  23.168 +
  23.169 +} /* namespace ns3 */
  23.170 +
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/src/helper/ipv6-address-helper.h	Sat Aug 22 14:36:55 2009 -0700
    24.3 @@ -0,0 +1,96 @@
    24.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    24.5 +/*
    24.6 + * Copyright (c) 2008-2009 Strasbourg University
    24.7 + *
    24.8 + * This program is free software; you can redistribute it and/or modify
    24.9 + * it under the terms of the GNU General Public License version 2 as
   24.10 + * published by the Free Software Foundation;
   24.11 + *
   24.12 + * This program is distributed in the hope that it will be useful,
   24.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   24.15 + * GNU General Public License for more details.
   24.16 + *
   24.17 + * You should have received a copy of the GNU General Public License
   24.18 + * along with this program; if not, write to the Free Software
   24.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24.20 + *
   24.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   24.22 + */
   24.23 +
   24.24 +#ifndef IPV6_ADDRESS_STATIC_HELPER_H
   24.25 +#define IPV6_ADDRESS_STATIC_HELPER_H
   24.26 +
   24.27 +#include <vector>
   24.28 +
   24.29 +#include "ns3/ipv6-address.h"
   24.30 +#include "net-device-container.h"
   24.31 +#include "ipv6-interface-container.h"
   24.32 +
   24.33 +namespace ns3
   24.34 +{
   24.35 +
   24.36 +/**
   24.37 + * \class Ipv6AddressHelper
   24.38 + * \brief Helper class to assign IPv6 address statically.
   24.39 + */
   24.40 +class Ipv6AddressHelper
   24.41 +{
   24.42 +  public:
   24.43 +    /**
   24.44 +     * \brief Constructor.
   24.45 +     */
   24.46 +    Ipv6AddressHelper ();
   24.47 +
   24.48 +    /**
   24.49 +     * \brief Allocate a new network.
   24.50 +     * \param network The IPv6 network
   24.51 +     * \param prefix The prefix
   24.52 +     */
   24.53 +    void NewNetwork (Ipv6Address network, Ipv6Prefix prefix);
   24.54 +
   24.55 +    /**
   24.56 +     * \brief Allocate a new address.
   24.57 +     * \param addr L2 address (currenty only ethernet address is supported)
   24.58 +     * \return newly created Ipv6Address
   24.59 +     */
   24.60 +    Ipv6Address NewAddress (Address addr);
   24.61 +
   24.62 +    /**
   24.63 +     * \brief Allocate an Ipv6InterfaceContainer.
   24.64 +     * \param c netdevice container
   24.65 +     * \return newly created Ipv6InterfaceContainer
   24.66 +     */
   24.67 +    Ipv6InterfaceContainer Assign (const NetDeviceContainer &c);
   24.68 +
   24.69 +    /**
   24.70 +     * \brief Allocate an Ipv6InterfaceContainer.
   24.71 +     * \param c netdevice container
   24.72 +     * \param withConfiguration true : interface statically configured, false : no static configuration
   24.73 +     * \return newly created Ipv6InterfaceContainer
   24.74 +     */
   24.75 +    Ipv6InterfaceContainer Assign (const NetDeviceContainer &c, std::vector<bool> withConfiguration);
   24.76 +
   24.77 +    /**
   24.78 +     * \brief Allocate an Ipv6InterfaceContainer without static IPv6 configuration.
   24.79 +     * \param c netdevice container
   24.80 +     * \return newly created Ipv6InterfaceContainer
   24.81 +     */
   24.82 +    Ipv6InterfaceContainer AssignWithoutAddress (const NetDeviceContainer &c);
   24.83 +
   24.84 +  private:
   24.85 +    /**
   24.86 +     * \brief The IPv6 network.
   24.87 +     */
   24.88 +    Ipv6Address m_network;
   24.89 +
   24.90 +    /**
   24.91 +     * \brief IPv6 The prefix (mask).
   24.92 +     */
   24.93 +    Ipv6Prefix m_prefix;
   24.94 +};
   24.95 +
   24.96 +} /* namespace ns3 */
   24.97 +
   24.98 +#endif /* IPV6_ADDRESS_STATIC_HELPER_H */
   24.99 +
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/src/helper/ipv6-interface-container.cc	Sat Aug 22 14:36:55 2009 -0700
    25.3 @@ -0,0 +1,109 @@
    25.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    25.5 +/*
    25.6 + * Copyright (c) 2008-2009 Strasbourg University
    25.7 + *
    25.8 + * This program is free software; you can redistribute it and/or modify
    25.9 + * it under the terms of the GNU General Public License version 2 as
   25.10 + * published by the Free Software Foundation;
   25.11 + *
   25.12 + * This program is distributed in the hope that it will be useful,
   25.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   25.15 + * GNU General Public License for more details.
   25.16 + *
   25.17 + * You should have received a copy of the GNU General Public License
   25.18 + * along with this program; if not, write to the Free Software
   25.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25.20 + *
   25.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   25.22 + */
   25.23 +
   25.24 +#include "ns3/node-list.h"
   25.25 +#include "ns3/names.h"
   25.26 +
   25.27 +#include "ipv6-interface-container.h"
   25.28 +#include "ipv6-static-routing-helper.h"
   25.29 +
   25.30 +namespace ns3 
   25.31 +{
   25.32 +
   25.33 +Ipv6InterfaceContainer::Ipv6InterfaceContainer ()
   25.34 +{
   25.35 +}
   25.36 +
   25.37 +uint32_t Ipv6InterfaceContainer::GetN () const
   25.38 +{
   25.39 +  return m_interfaces.size ();
   25.40 +}
   25.41 +
   25.42 +uint32_t Ipv6InterfaceContainer::GetInterfaceIndex (uint32_t i) const
   25.43 +{
   25.44 +  return m_interfaces[i].second;
   25.45 +}
   25.46 +
   25.47 +Ipv6Address Ipv6InterfaceContainer::GetAddress (uint32_t i, uint32_t j) const
   25.48 +{
   25.49 +  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
   25.50 +  uint32_t interface = m_interfaces[i].second;
   25.51 +  return ipv6->GetAddress (interface, j).GetAddress ();
   25.52 +}
   25.53 +
   25.54 +void Ipv6InterfaceContainer::Add (Ptr<Ipv6> ipv6, uint32_t interface)
   25.55 +{
   25.56 +  m_interfaces.push_back (std::make_pair (ipv6, interface));
   25.57 +}
   25.58 +
   25.59 +void Ipv6InterfaceContainer::Add (std::string ipv6Name, uint32_t interface)
   25.60 +{
   25.61 +  Ptr<Ipv6> ipv6 = Names::Find<Ipv6> (ipv6Name);
   25.62 +  m_interfaces.push_back (std::make_pair (ipv6, interface));
   25.63 +}
   25.64 +
   25.65 +void Ipv6InterfaceContainer::Add (Ipv6InterfaceContainer& c)
   25.66 +{
   25.67 +  for (InterfaceVector::const_iterator it = c.m_interfaces.begin () ; it != c.m_interfaces.end () ; it++)
   25.68 +  {
   25.69 +    m_interfaces.push_back (*it);
   25.70 +  }
   25.71 +}
   25.72 +
   25.73 +void Ipv6InterfaceContainer::SetRouter (uint32_t i, bool router)
   25.74 +{
   25.75 +  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
   25.76 +  ipv6->SetForwarding (m_interfaces[i].second, router);
   25.77 +
   25.78 +  if (router)
   25.79 +  {
   25.80 +    uint32_t other;
   25.81 +    /* assume first global address is index 1 (0 is link-local) */
   25.82 +    Ipv6Address routerAddress = ipv6->GetAddress (m_interfaces[i].second, 1).GetAddress ();
   25.83 +
   25.84 +    for (other = 0 ; other < m_interfaces.size () ; other++)
   25.85 +    {
   25.86 +      if (other != i)
   25.87 +      {
   25.88 +        Ptr<Ipv6StaticRouting> routing = 0;
   25.89 +        Ipv6StaticRoutingHelper routingHelper;
   25.90 +
   25.91 +        ipv6 = m_interfaces[other].first;
   25.92 +        routing = routingHelper.GetStaticRouting (ipv6);
   25.93 +        routing->SetDefaultRoute (routerAddress, m_interfaces[other].second);
   25.94 +      }
   25.95 +    }
   25.96 +  }
   25.97 +}
   25.98 +
   25.99 +void Ipv6InterfaceContainer::SetDefaultRoute (uint32_t i, uint32_t router)
  25.100 +{
  25.101 +  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
  25.102 +  Ptr<Ipv6> ipv6Router = m_interfaces[router].first;
  25.103 +  Ipv6Address routerAddress = ipv6Router->GetAddress (m_interfaces[router].second, 1).GetAddress ();
  25.104 +  Ptr<Ipv6StaticRouting> routing = 0;
  25.105 +  Ipv6StaticRoutingHelper routingHelper;
  25.106 +
  25.107 +  routing = routingHelper.GetStaticRouting (ipv6);
  25.108 +  routing->SetDefaultRoute (routerAddress, m_interfaces[i].second);
  25.109 +}
  25.110 +
  25.111 +} /* namespace ns3 */
  25.112 +
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/src/helper/ipv6-interface-container.h	Sat Aug 22 14:36:55 2009 -0700
    26.3 @@ -0,0 +1,111 @@
    26.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    26.5 +/*
    26.6 + * Copyright (c) 2008-2009 Strasbourg University
    26.7 + *
    26.8 + * This program is free software; you can redistribute it and/or modify
    26.9 + * it under the terms of the GNU General Public License version 2 as
   26.10 + * published by the Free Software Foundation;
   26.11 + *
   26.12 + * This program is distributed in the hope that it will be useful,
   26.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26.15 + * GNU General Public License for more details.
   26.16 + *
   26.17 + * You should have received a copy of the GNU General Public License
   26.18 + * along with this program; if not, write to the Free Software
   26.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   26.20 + *
   26.21 + * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
   26.22 + */
   26.23 +
   26.24 +#ifndef IPV6_INTERFACE_CONTAINER_H
   26.25 +#define IPV6_INTERFACE_CONTAINER_H
   26.26 +
   26.27 +#include <stdint.h>
   26.28 +#include <vector>
   26.29 +#include "ns3/ipv6.h"
   26.30 +#include "ns3/ipv6-address.h"
   26.31 +
   26.32 +namespace ns3
   26.33 +{
   26.34 +
   26.35 +/**
   26.36 + * \class Ipv6InterfaceContainer
   26.37 + * \brief keep track of a set of IPv6 interfaces.
   26.38 + */
   26.39 +class Ipv6InterfaceContainer
   26.40 +{
   26.41 +  public:
   26.42 +    /**
   26.43 +     * \brief Constructor.
   26.44 +     */
   26.45 +    Ipv6InterfaceContainer ();
   26.46 +
   26.47 +    /**
   26.48 +     * \brief Get the number of interfaces.
   26.49 +     * \return the number of interfaces stored in this Ipv6InterfaceContainer.
   26.50 +     */
   26.51 +    uint32_t GetN (void) const;
   26.52 +
   26.53 +    /**
   26.54 +     * \brief Get the interface index for the specified node index.
   26.55 +     * \param i index of the node
   26.56 +     * \return interface index
   26.57 +     */
   26.58 +    uint32_t GetInterfaceIndex (uint32_t i) const;
   26.59 +
   26.60 +    /**
   26.61 +     * \brief Get the address for the specified index.
   26.62 +     * \param i interface index
   26.63 +     * \param j address index, generally index 0 is the link-local address
   26.64 +     * \return IPv6 address
   26.65 +     */
   26.66 +    Ipv6Address GetAddress (uint32_t i, uint32_t j) const;
   26.67 +
   26.68 +    /**
   26.69 +     * \brief Add a couple IPv6/interface.
   26.70 +     * \param ipv6 IPv6 address
   26.71 +     * \param interface interface index
   26.72 +     */
   26.73 +    void Add (Ptr<Ipv6> ipv6, uint32_t interface);
   26.74 +
   26.75 +    /**
   26.76 +     * \brief Fusion with another Ipv6InterfaceContainer.
   26.77 +     * \param c container
   26.78 +     */
   26.79 +    void Add (Ipv6InterfaceContainer& c);
   26.80 +
   26.81 +    /**
   26.82 +     * \brief Add a couple of name/interface.
   26.83 +     * \param ipv6Name name of a node
   26.84 +     * \param interface interface index to add
   26.85 +     */
   26.86 +    void Add (std::string ipv6Name, uint32_t interface);
   26.87 +
   26.88 +    /**
   26.89 +     * \brief Set the state of the stack (act as a router or not) for the specified index.
   26.90 +     * \param i index
   26.91 +     * \param router true : is a router, false : is an host
   26.92 +     */
   26.93 +    void SetRouter (uint32_t i, bool router);
   26.94 +
   26.95 +    /**
   26.96 +     * \brief Set the default route for the specified index.
   26.97 +     * \param i index
   26.98 +     * \param router the default router
   26.99 +     */
  26.100 +    void SetDefaultRoute (uint32_t i, uint32_t router);
  26.101 +
  26.102 +  private:
  26.103 +    typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> > InterfaceVector;
  26.104 +
  26.105 +    /**
  26.106 +     * \brief List of IPv6 stack and interfaces index.
  26.107 +     */
  26.108 +    InterfaceVector m_interfaces;
  26.109 +};
  26.110 +
  26.111 +} /* namespace ns3 */
  26.112 +
  26.113 +#endif /* IPV6_INTERFACE_CONTAINER_H */
  26.114 +
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/src/helper/ipv6-list-routing-helper.cc	Sat Aug 22 14:36:55 2009 -0700
    27.3 @@ -0,0 +1,46 @@
    27.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    27.5 +/*
    27.6 + * Copyright (c) 2008 INRIA
    27.7 + *
    27.8 + * This program is free software; you can redistribute it and/or modify
    27.9 + * it under the terms of the GNU General Public License version 2 as
   27.10 + * published by the Free Software Foundation;
   27.11 + *
   27.12 + * This program is distributed in the hope that it will be useful,
   27.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   27.15 + * GNU General Public License for more details.
   27.16 + *
   27.17 + * You should have received a copy of the GNU General Public License
   27.18 + * along with this program; if not, write to the Free Software
   27.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   27.20 + *
   27.21 + * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   27.22 + */
   27.23 +#include "ipv6-list-routing-helper.h"
   27.24 +#include "ns3/ipv6-list-routing.h"
   27.25 +#include "ns3/node.h"
   27.26 +
   27.27 +namespace ns3 {
   27.28 +
   27.29 +Ipv6ListRoutingHelper::Ipv6ListRoutingHelper ()
   27.30 +{}
   27.31 +void 
   27.32 +Ipv6ListRoutingHelper::Add (const Ipv6RoutingHelper &routing, int16_t priority)
   27.33 +{
   27.34 +  m_list.push_back (std::make_pair (&routing,priority));
   27.35 +}
   27.36 +Ptr<Ipv6RoutingProtocol> 
   27.37 +Ipv6ListRoutingHelper::Create (Ptr<Node> node) const
   27.38 +{
   27.39 +  Ptr<Ipv6ListRouting> list = CreateObject<Ipv6ListRouting> ();
   27.40 +  for (std::list<std::pair<const Ipv6RoutingHelper *,int16_t> >::const_iterator i = m_list.begin ();
   27.41 +       i != m_list.end (); ++i)
   27.42 +    {
   27.43 +      Ptr<Ipv6RoutingProtocol> prot = i->first->Create (node);
   27.44 +      list->AddRoutingProtocol (prot,i->second);
   27.45 +    }
   27.46 +  return list;
   27.47 +}
   27.48 +
   27.49 +} // namespace ns3
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/src/helper/ipv6-list-routing-helper.h	Sat Aug 22 14:36:55 2009 -0700
    28.3 @@ -0,0 +1,64 @@
    28.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    28.5 +/*
    28.6 + * Copyright (c) 2008 INRIA
    28.7 + *
    28.8 + * This program is free software; you can redistribute it and/or modify
    28.9 + * it under the terms of the GNU General Public License version 2 as
   28.10 + * published by the Free Software Foundation;
   28.11 + *
   28.12 + * This program is distributed in the hope that it will be useful,
   28.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   28.15 + * GNU General Public License for more details.
   28.16 + *
   28.17 + * You should have received a copy of the GNU General Public License
   28.18 + * along with this program; if not, write to the Free Software
   28.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   28.20 + *
   28.21 + * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   28.22 + */
   28.23 +#ifndef IPV6_LIST_ROUTING_HELPER_H
   28.24 +#define IPV6_LIST_ROUTING_HELPER_H
   28.25 +
   28.26 +#include "ipv6-routing-helper.h"
   28.27 +#include <stdint.h>
   28.28 +#include <list>
   28.29 +
   28.30 +namespace ns3 {
   28.31 +
   28.32 +/**
   28.33 + * \brief Helper class that adds ns3::Ipv6ListRouting objects
   28.34 + *
   28.35 + * This class is expected to be used in conjunction with 
   28.36 + * ns3::InternetStackHelper::SetRoutingHelper
   28.37 + */
   28.38 +class Ipv6ListRoutingHelper : public Ipv6RoutingHelper
   28.39 +{
   28.40 +public:
   28.41 +  Ipv6ListRoutingHelper ();
   28.42 +  /**
   28.43 +   * \param routing a routing helper
   28.44 +   * \param priority the priority of the associated helper
   28.45 +   *
   28.46 +   * Store in the internal list a reference to the input routing helper
   28.47 +   * and associated priority. These helpers will be used later by
   28.48 +   * the ns3::Ipv6ListRoutingHelper::Create method to create
   28.49 +   * an ns3::Ipv6ListRouting object and add in it routing protocols
   28.50 +   * created with the helpers.
   28.51 +   */
   28.52 +  void Add (const Ipv6RoutingHelper &routing, int16_t priority);
   28.53 +  /**
   28.54 +   * \param node the node on which the routing protocol will run
   28.55 +   * \returns a newly-created routing protocol
   28.56 +   *
   28.57 +   * This method will be called by ns3::InternetStackHelper::Install
   28.58 +   */
   28.59 +  virtual Ptr<Ipv6RoutingProtocol> Create (Ptr<Node> node) const;
   28.60 +private:
   28.61 +  std::list<std::pair<const Ipv6RoutingHelper *,int16_t> > m_list;
   28.62 +};
   28.63 +
   28.64 +} // namespace ns3
   28.65 +
   28.66 +#endif /* IPV6_LIST_ROUTING_HELPER_H */
   28.67 +
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/src/helper/ipv6-routing-helper.cc	Sat Aug 22 14:36:55 2009 -0700
    29.3 @@ -0,0 +1,28 @@
    29.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    29.5 +/*
    29.6 + * Copyright (c) 2008 INRIA
    29.7 + *
    29.8 + * This program is free software; you can redistribute it and/or modify
    29.9 + * it under the terms of the GNU General Public License version 2 as
   29.10 + * published by the Free Software Foundation;
   29.11 + *
   29.12 + * This program is distributed in the hope that it will be useful,
   29.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   29.15 + * GNU General Public License for more details.
   29.16 + *
   29.17 + * You should have received a copy of the GNU General Public License
   29.18 + * along with this program; if not, write to the Free Software
   29.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   29.20 + *
   29.21 + * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   29.22 + */
   29.23 +
   29.24 +#include "ipv6-routing-helper.h"
   29.25 +
   29.26 +namespace ns3 {
   29.27 +
   29.28 +Ipv6RoutingHelper::~Ipv6RoutingHelper ()
   29.29 +{}
   29.30 +
   29.31 +} // namespace ns3
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/src/helper/ipv6-routing-helper.h	Sat Aug 22 14:36:55 2009 -0700
    30.3 @@ -0,0 +1,54 @@
    30.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    30.5 +/*
    30.6 + * Copyright (c) 2008 INRIA
    30.7 + *
    30.8 + * This program is free software; you can redistribute it and/or modify
    30.9 + * it under the terms of the GNU General Public License version 2 as
   30.10 + * published by the Free Software Foundation;
   30.11 + *
   30.12 + * This program is distributed in the hope that it will be useful,
   30.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   30.15 + * GNU General Public License for more details.
   30.16 + *
   30.17 + * You should have received a copy of the GNU General Public License
   30.18 + * along with this program; if not, write to the Free Software
   30.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   30.20 + *
   30.21 + * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   30.22 + */
   30.23 +#ifndef IPV6_ROUTING_HELPER_H
   30.24 +#define IPV6_ROUTING_HELPER_H
   30.25 +
   30.26 +#include "ns3/ptr.h"
   30.27 +
   30.28 +namespace ns3 {
   30.29 +
   30.30 +class Ipv6RoutingProtocol;
   30.31 +class Node;
   30.32 +
   30.33 +/**
   30.34 + * \brief a factory to create ns3::Ipv6RoutingProtocol objects
   30.35 + *
   30.36 + * For each new routing protocol created as a subclass of 
   30.37 + * ns3::Ipv6RoutingProtocol, you need to create a subclass of 
   30.38 + * ns3::Ipv6RoutingHelper which can be used by 
   30.39 + * ns3::InternetStackHelper::SetRoutingHelper and 
   30.40 + * ns3::InternetStackHelper::Install.
   30.41 + */
   30.42 +class Ipv6RoutingHelper
   30.43 +{
   30.44 +public:
   30.45 +  virtual ~Ipv6RoutingHelper ();
   30.46 +  /**
   30.47 +   * \param node the node within which the new routing protocol will run
   30.48 +   * \returns a newly-created routing protocol
   30.49 +   */
   30.50 +  virtual Ptr<Ipv6RoutingProtocol> Create (Ptr<Node> node) const = 0;
   30.51 +};
   30.52 +
   30.53 +} // namespace ns3
   30.54 +
   30.55 +
   30.56 +#endif /* IPV6_ROUTING_HELPER_H */
   30.57 +
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/src/helper/ipv6-static-routing-helper.cc	Sat Aug 22 14:36:55 2009 -0700
    31.3 @@ -0,0 +1,200 @@
    31.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
    31.5 +/*
    31.6 + * Copyright (c) 2009 University of Washington
    31.7 + *
    31.8 + * This program is free software; you can redistribute it and/or modify
    31.9 + * it under the terms of the GNU General Public License version 2 as
   31.10 + * published by the Free Software Foundation;
   31.11 + *
   31.12 + * This program is distributed in the hope that it will be useful,
   31.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   31.15 + * GNU General Public License for more details.
   31.16 + *
   31.17 + * You should have received a copy of the GNU General Public License
   31.18 + * along with this program; if not, write to the Free Software
   31.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   31.20 + */
   31.21 +
   31.22 +#include <vector>
   31.23 +#include "ns3/log.h"
   31.24 +#include "ns3/ptr.h"
   31.25 +#include "ns3/names.h"
   31.26 +#include "ns3/node.h"