examples/ipv6/fragmentation-ipv6.cc
author Tom Henderson <tomh@tomh.org>
Sun, 20 May 2012 15:19:52 -0700
changeset 8798 5d8dfd7c6609
parent 7256 b04ba6772f8c
child 10131 0dc090fc749d
permissions -rw-r--r--
bug 1432: Align Ipv6AddressHelper API with Ipv4AddressHelper API
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     2
/*
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     3
 * Copyright (c) 2008-2009 Strasbourg University
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     4
 *
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     8
 *
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    12
 * GNU General Public License for more details.
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    13
 *
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    17
 *
5788
b0ffdd417829 Update e-mail address of David.
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents: 5787
diff changeset
    18
 * Author: David Gross <gdavid.devel@gmail.com>
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    19
 *         Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    20
 */
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    21
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    22
// Network topology
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    23
// //
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    24
// //             n0   r    n1
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    25
// //             |    _    |
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    26
// //             ====|_|====
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    27
// //                router
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    28
// //
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    29
// // - Tracing of queues and packet receptions to file "fragmentation-ipv6.tr"
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    30
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    31
#include <fstream>
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    32
#include "ns3/core-module.h"
6834
036f9a0b9899 Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
    33
#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
    34
#include "ns3/csma-module.h"
6847
138f00c56381 Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
    35
#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
    36
#include "ns3/ipv6-static-routing-helper.h"
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    37
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    38
#include "ns3/ipv6-routing-table-entry.h"
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    39
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    40
using namespace ns3;
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    41
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    42
NS_LOG_COMPONENT_DEFINE ("FragmentationIpv6Example");
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    43
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    44
/**
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    45
 * \class StackHelper
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    46
 * \brief Helper to set or get some IPv6 information about nodes.
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    47
 */
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    48
class StackHelper
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    49
{
5809
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    50
public:
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    51
  /**
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    52
   * \brief Add an address to a IPv6 node.
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    53
   * \param n node
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    54
   * \param interface interface index
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    55
   * \param address IPv6 address to add
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    56
   */
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    57
  inline void AddAddress (Ptr<Node>& n, uint32_t interface, Ipv6Address address)
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    58
  {
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    59
    Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    60
    ipv6->AddAddress (interface, address);
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    61
  }
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    62
5809
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    63
  /**
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    64
   * \brief Print the routing table.
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    65
   * \param n the node
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    66
   */
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    67
  inline void PrintRoutingTable (Ptr<Node>& n)
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    68
  {
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    69
    Ptr<Ipv6StaticRouting> routing = 0;
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    70
    Ipv6StaticRoutingHelper routingHelper;
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    71
    Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    72
    uint32_t nbRoutes = 0;
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    73
    Ipv6RoutingTableEntry route;
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    74
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    75
    routing = routingHelper.GetStaticRouting (ipv6);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    76
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    77
    std::cout << "Routing table of " << n << " : " << std::endl;
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    78
    std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" <<  "Prefix to use" << std::endl;
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    79
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    80
    nbRoutes = routing->GetNRoutes ();
7252
c8200621e252 rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    81
    for (uint32_t i = 0; i < nbRoutes; i++)
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    82
      {
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    83
        route = routing->GetRoute (i);
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    84
        std::cout << route.GetDest () << "\t"
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
    85
                  << route.GetGateway () << "\t"
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
    86
                  << route.GetInterface () << "\t"
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
    87
                  << route.GetPrefixToUse () << "\t"
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
    88
                  << std::endl;
5891
09a575cdf8db Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5809
diff changeset
    89
      }
5809
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5796
diff changeset
    90
  } 
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    91
};
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    92
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    93
int main (int argc, char** argv)
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    94
{
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    95
#if 0 
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    96
  LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    97
  LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    98
  LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
    99
  LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   100
  LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   101
#endif
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   102
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   103
  CommandLine cmd;
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   104
  cmd.Parse (argc, argv);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   105
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   106
  StackHelper stackHelper;
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   107
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   108
  NS_LOG_INFO ("Create nodes.");
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   109
  Ptr<Node> n0 = CreateObject<Node> ();
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   110
  Ptr<Node> r = CreateObject<Node> ();
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   111
  Ptr<Node> n1 = CreateObject<Node> ();
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   112
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   113
  NodeContainer net1 (n0, r);
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   114
  NodeContainer net2 (r, n1);
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   115
  NodeContainer all (n0, r, n1);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   116
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   117
  NS_LOG_INFO ("Create IPv6 Internet Stack");
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   118
  InternetStackHelper internetv6;
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   119
  internetv6.Install (all);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   120
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   121
  NS_LOG_INFO ("Create channels.");
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   122
  CsmaHelper csma;
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   123
  csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   124
  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   125
  NetDeviceContainer d1 = csma.Install (net1);
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   126
  NetDeviceContainer d2 = csma.Install (net2);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   127
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   128
  NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   129
  Ipv6AddressHelper ipv6;
8798
5d8dfd7c6609 bug 1432: Align Ipv6AddressHelper API with Ipv4AddressHelper API
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
   130
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   131
  Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   132
  i1.SetRouter (1, true);
8798
5d8dfd7c6609 bug 1432: Align Ipv6AddressHelper API with Ipv4AddressHelper API
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
   133
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   134
  Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   135
  i2.SetRouter (0, true);
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   136
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   137
  stackHelper.PrintRoutingTable (n0);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   138
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   139
  /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   140
  uint32_t packetSize = 4096;
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   141
  uint32_t maxPacketCount = 5;
5796
cd4576c14476 Update.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5788
diff changeset
   142
  Time interPacketInterval = Seconds (1.0);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   143
  Ping6Helper ping6;
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   144
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   145
  ping6.SetLocal (i1.GetAddress (0, 1));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   146
  ping6.SetRemote (i2.GetAddress (1, 1)); 
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   147
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   148
  ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   149
  ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   150
  ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   151
  ApplicationContainer apps = ping6.Install (net1.Get (0));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   152
  apps.Start (Seconds (2.0));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   153
  apps.Stop (Seconds (20.0));
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   154
6014
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   155
  AsciiTraceHelper ascii;
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   156
  csma.EnableAsciiAll (ascii.CreateFileStream ("fragmentation-ipv6.tr"));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5891
diff changeset
   157
  csma.EnablePcapAll (std::string ("fragmentation-ipv6"), true);
5787
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   158
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   159
  NS_LOG_INFO ("Run Simulation.");
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   160
  Simulator::Run ();
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   161
  Simulator::Destroy ();
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   162
  NS_LOG_INFO ("Done.");
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   163
}
f7ab103c85d2 Add examples (loose-routing-ipv6 not working yet).
Sebastien Vincent <sebastien.vincent@turnserver.org>
parents:
diff changeset
   164