examples/ipv6/icmpv6-redirect.cc
author Tom Henderson <tomh@tomh.org>
Mon, 28 Sep 2015 20:27:25 -0700
changeset 11676 05ea1489e509
parent 10136 71b625bfe8c7
permissions -rw-r--r--
bug 2184: Integer overflow in MacLow
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     2
/*
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     3
 * Copyright (c) 2009 Strasbourg University
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     4
 *
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     8
 *
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    13
 *
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    17
 *
5788
b0ffdd417829 Update e-mail address of David.
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents: 5369
diff changeset
    18
 * Author: David Gross <gdavid.devel@gmail.com>
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    19
 */
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    20
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    21
// Network topology
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    22
//
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    23
//             STA2
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    24
//              |
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    25
//              |
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    26
//   R1         R2
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    27
//   |          |
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    28
//   |          |
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    29
//   ------------
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    30
//           |
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    31
//           |
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    32
//          STA 1
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    33
//
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    34
// - Initial configuration :
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    35
//         - STA1 default route : R1
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    36
//         - R1 static route to STA2 : R2
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    37
//         - STA2 default route : R2
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    38
// - STA1 send Echo Request to STA2 using its default route to R1
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    39
// - R1 receive Echo Request from STA1, and forward it to R2
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    40
// - R1 send an ICMPv6 Redirection to STA1 with Target STA2 and Destination R2
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    41
// - Next Echo Request from STA1 to STA2 are directly sent to R2
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    42
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    43
#include <fstream>
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    44
#include "ns3/core-module.h"
6834
036f9a0b9899 Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
    45
#include "ns3/internet-module.h"
6848
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    46
#include "ns3/csma-module.h"
6847
138f00c56381 Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
    47
#include "ns3/applications-module.h"
6648
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6014
diff changeset
    48
#include "ns3/ipv6-static-routing-helper.h"
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    49
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    50
#include "ns3/ipv6-routing-table-entry.h"
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    51
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    52
using namespace ns3;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    53
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    54
NS_LOG_COMPONENT_DEFINE ("Icmpv6RedirectExample");
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    55
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    56
int main (int argc, char **argv)
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    57
{
10136
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    58
  bool verbose = false;
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    59
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    60
  CommandLine cmd;
10136
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    61
  cmd.AddValue ("verbose", "turn on log components", verbose);
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    62
  cmd.Parse (argc, argv);
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    63
10136
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    64
  if (verbose)
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    65
    {
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    66
      LogComponentEnable ("Icmpv6RedirectExample", LOG_LEVEL_INFO);
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    67
      LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_INFO);
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    68
      LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    69
      LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    70
      LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    71
      LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    72
      LogComponentEnable ("NdiscCache", LOG_LEVEL_ALL);
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    73
    }
71b625bfe8c7 Add "verbose" command line to IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10135
diff changeset
    74
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    75
  NS_LOG_INFO ("Create nodes.");
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    76
  Ptr<Node> sta1 = CreateObject<Node> ();
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    77
  Ptr<Node> r1 = CreateObject<Node> ();
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    78
  Ptr<Node> r2 = CreateObject<Node> ();
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    79
  Ptr<Node> sta2 = CreateObject<Node> ();
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
    80
  NodeContainer net1 (sta1, r1, r2);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
    81
  NodeContainer net2 (r2, sta2);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
    82
  NodeContainer all (sta1, r1, r2, sta2);
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    83
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    84
  InternetStackHelper internetv6;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    85
  internetv6.Install (all);
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    86
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    87
  NS_LOG_INFO ("Create channels.");
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    88
  CsmaHelper csma;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
    89
  csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
    90
  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    91
  NetDeviceContainer ndc1 = csma.Install (net1); 
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    92
  NetDeviceContainer ndc2 = csma.Install (net2);
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    93
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    94
  NS_LOG_INFO ("Assign IPv6 Addresses.");
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    95
  Ipv6AddressHelper ipv6;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    96
8798
5d8dfd7c6609 bug 1432: Align Ipv6AddressHelper API with Ipv4AddressHelper API
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    97
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    98
  Ipv6InterfaceContainer iic1 = ipv6.Assign (ndc1);
10131
0dc090fc749d Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9848
diff changeset
    99
  iic1.SetForwarding (2, true);
0dc090fc749d Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9848
diff changeset
   100
  iic1.SetForwarding (1, true);
0dc090fc749d Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9848
diff changeset
   101
  iic1.SetDefaultRouteInAllNodes (1);
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   102
8798
5d8dfd7c6609 bug 1432: Align Ipv6AddressHelper API with Ipv4AddressHelper API
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
   103
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   104
  Ipv6InterfaceContainer iic2 = ipv6.Assign (ndc2);
10131
0dc090fc749d Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9848
diff changeset
   105
  iic2.SetForwarding (0, true);
0dc090fc749d Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9848
diff changeset
   106
  iic2.SetDefaultRouteInAllNodes (0);
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   107
10135
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   108
  Ipv6StaticRoutingHelper routingHelper;
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   109
10135
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   110
  // manually inject a static route to the second router.
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   111
  Ptr<Ipv6StaticRouting> routing = routingHelper.GetStaticRouting (r1->GetObject<Ipv6> ());
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   112
  routing->AddHostRouteTo (iic2.GetAddress (1, 1), iic1.GetAddress (2, 0), iic1.GetInterfaceIndex (1));
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   113
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   114
  Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> (&std::cout);
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   115
  routingHelper.PrintRoutingTableAt (Seconds (0.0), r1, routingStream);
21bdad9520b8 Remove obsolete StackHelper from IPv6 examples
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10131
diff changeset
   116
  routingHelper.PrintRoutingTableAt (Seconds (3.0), sta1, routingStream);
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   117
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   118
  NS_LOG_INFO ("Create Applications.");
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   119
  uint32_t packetSize = 1024;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   120
  uint32_t maxPacketCount = 5;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   121
  Time interPacketInterval = Seconds (1.);
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   122
  Ping6Helper ping6;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   123
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   124
  ping6.SetLocal (iic1.GetAddress (0, 1));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   125
  ping6.SetRemote (iic2.GetAddress (1, 1));
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   126
  ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   127
  ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   128
  ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   129
  ApplicationContainer apps = ping6.Install (sta1);
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   130
  apps.Start (Seconds (2.0));
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   131
  apps.Stop (Seconds (10.0));
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   132
6014
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   133
  AsciiTraceHelper ascii;
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   134
  csma.EnableAsciiAll (ascii.CreateFileStream ("icmpv6-redirect.tr"));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5891
diff changeset
   135
  csma.EnablePcapAll ("icmpv6-redirect", true);
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   136
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   137
  /* Now, do the actual simulation. */
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   138
  NS_LOG_INFO ("Run Simulation.");
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   139
  Simulator::Run ();
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   140
  Simulator::Destroy ();
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   141
  NS_LOG_INFO ("Done.");
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   142
}
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
   143