author | Tom Henderson <tomh@tomh.org> |
Mon, 28 Sep 2015 20:27:25 -0700 | |
changeset 11676 | 05ea1489e509 |
parent 10131 | 0dc090fc749d |
permissions | -rw-r--r-- |
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) 2008-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 |
* Sebastien Vincent <vincent@clarinet.u-strasbg.fr> |
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 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
22 |
// Network topology |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
23 |
// // |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
24 |
// // n0 r n1 |
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 |
// // ====|_|==== |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
27 |
// // router |
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 |
// // - Tracing of queues and packet receptions to file "simple-routing-ping6.tr" |
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 |
#include <fstream> |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
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" |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
37 |
|
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
38 |
#include "ns3/ipv6-routing-table-entry.h" |
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
39 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
40 |
using namespace ns3; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
41 |
|
4753
81146e4a3993
Add IPv6 python example.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4731
diff
changeset
|
42 |
NS_LOG_COMPONENT_DEFINE ("SimpleRoutingPing6Example"); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
43 |
|
4768
f05ccb34aabc
Schedule unicast RA in response to RS.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4761
diff
changeset
|
44 |
/** |
f05ccb34aabc
Schedule unicast RA in response to RS.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4761
diff
changeset
|
45 |
* \class StackHelper |
f05ccb34aabc
Schedule unicast RA in response to RS.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4761
diff
changeset
|
46 |
* \brief Helper to set or get some IPv6 information about nodes. |
f05ccb34aabc
Schedule unicast RA in response to RS.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4761
diff
changeset
|
47 |
*/ |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
48 |
class StackHelper |
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
49 |
{ |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
50 |
public: |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
51 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
52 |
/** |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
53 |
* \brief Add an address to a IPv6 node. |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
54 |
* \param n node |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
55 |
* \param interface interface index |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
56 |
* \param address IPv6 address to add |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
57 |
*/ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
58 |
inline void AddAddress (Ptr<Node>& n, uint32_t interface, Ipv6Address address) |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
59 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
60 |
Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
61 |
ipv6->AddAddress (interface, address); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
62 |
} |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
63 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
64 |
/** |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
65 |
* \brief Print the routing table. |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
66 |
* \param n the node |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
67 |
*/ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
68 |
inline void PrintRoutingTable (Ptr<Node>& n) |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
69 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
70 |
Ptr<Ipv6StaticRouting> routing = 0; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
71 |
Ipv6StaticRoutingHelper routingHelper; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
72 |
Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
73 |
uint32_t nbRoutes = 0; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
74 |
Ipv6RoutingTableEntry route; |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
75 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
76 |
routing = routingHelper.GetStaticRouting (ipv6); |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
77 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
78 |
std::cout << "Routing table of " << n << " : " << std::endl; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
79 |
std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
80 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
81 |
nbRoutes = routing->GetNRoutes (); |
7252
c8200621e252
rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents:
7196
diff
changeset
|
82 |
for (uint32_t i = 0; i < nbRoutes; i++) |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
83 |
{ |
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
84 |
route = routing->GetRoute (i); |
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
85 |
std::cout << route.GetDest () << "\t" |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6865
diff
changeset
|
86 |
<< route.GetGateway () << "\t" |
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6865
diff
changeset
|
87 |
<< route.GetInterface () << "\t" |
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6865
diff
changeset
|
88 |
<< route.GetPrefixToUse () << "\t" |
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6865
diff
changeset
|
89 |
<< std::endl; |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
90 |
} |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
91 |
} |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
92 |
}; |
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
93 |
|
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
94 |
int main (int argc, char** argv) |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
95 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
96 |
#if 0 |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
97 |
LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
98 |
LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
99 |
LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
100 |
LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
101 |
LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
102 |
#endif |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
103 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
104 |
CommandLine cmd; |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
105 |
cmd.Parse (argc, argv); |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
106 |
|
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
107 |
StackHelper stackHelper; |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
108 |
|
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
109 |
NS_LOG_INFO ("Create nodes."); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
110 |
Ptr<Node> n0 = CreateObject<Node> (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
111 |
Ptr<Node> r = CreateObject<Node> (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
112 |
Ptr<Node> n1 = CreateObject<Node> (); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
113 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
114 |
NodeContainer net1 (n0, r); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
115 |
NodeContainer net2 (r, n1); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
116 |
NodeContainer all (n0, r, n1); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
117 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
118 |
NS_LOG_INFO ("Create IPv6 Internet Stack"); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
119 |
InternetStackHelper internetv6; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
120 |
internetv6.Install (all); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
121 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
122 |
NS_LOG_INFO ("Create channels."); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
123 |
CsmaHelper csma; |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
124 |
csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
125 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
126 |
NetDeviceContainer d1 = csma.Install (net1); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
127 |
NetDeviceContainer d2 = csma.Install (net2); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
128 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
129 |
NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
130 |
Ipv6AddressHelper ipv6; |
8798
5d8dfd7c6609
bug 1432: Align Ipv6AddressHelper API with Ipv4AddressHelper API
Tom Henderson <tomh@tomh.org>
parents:
7256
diff
changeset
|
131 |
ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64)); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
132 |
Ipv6InterfaceContainer i1 = ipv6.Assign (d1); |
10131
0dc090fc749d
Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8798
diff
changeset
|
133 |
i1.SetForwarding (1, true); |
0dc090fc749d
Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8798
diff
changeset
|
134 |
i1.SetDefaultRouteInAllNodes (1); |
8798
5d8dfd7c6609
bug 1432: Align Ipv6AddressHelper API with Ipv4AddressHelper API
Tom Henderson <tomh@tomh.org>
parents:
7256
diff
changeset
|
135 |
ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64)); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5788
diff
changeset
|
136 |
Ipv6InterfaceContainer i2 = ipv6.Assign (d2); |
10131
0dc090fc749d
Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8798
diff
changeset
|
137 |
i2.SetForwarding (0, true); |
0dc090fc749d
Bug 1702 - A router should't aways add itself as the default router
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8798
diff
changeset
|
138 |
i2.SetDefaultRouteInAllNodes (0); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
139 |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
140 |
stackHelper.PrintRoutingTable (n0); |
4761
8c0b3a413f4b
Add metric and longest prefix match support for IPv6.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4753
diff
changeset
|
141 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
142 |
/* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
Ping6Helper ping6; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
147 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
148 |
ping6.SetLocal (i1.GetAddress (0, 1)); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
149 |
ping6.SetRemote (i2.GetAddress (1, 1)); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
150 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
151 |
ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount)); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
152 |
ping6.SetAttribute ("Interval", TimeValue (interPacketInterval)); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
153 |
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
|
154 |
ApplicationContainer apps = ping6.Install (net1.Get (0)); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
155 |
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
|
156 |
apps.Stop (Seconds (20.0)); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
157 |
|
6014 | 158 |
AsciiTraceHelper ascii; |
159 |
csma.EnableAsciiAll (ascii.CreateFileStream ("simple-routing-ping6.tr")); |
|
160 |
csma.EnablePcapAll ("simple-routing-ping6", true); |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
161 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
162 |
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
|
163 |
Simulator::Run (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
164 |
Simulator::Destroy (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
165 |
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
|
166 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
167 |