author | Tom Henderson <tomh@tomh.org> |
Fri, 13 Jul 2007 13:33:56 -0700 | |
changeset 1086 | 43ea23238ce8 |
parent 1056 | dc7924932154 |
child 1090 | 66619752cb2e |
permissions | -rw-r--r-- |
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
/* |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
* |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
* ns-2 simple.tcl script (ported from ns-2) |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
* Originally authored by Steve McCanne, 12/19/1996 |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
*/ |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
// Port of ns-2/tcl/ex/simple.tcl to ns-3 |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
// |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
// Network topology |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
// |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
// n0 |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
// \ 5 Mb/s, 2ms |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
// \ 1.5Mb/s, 10ms |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
// n2 -------------------------n3 |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
28 |
// / |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
// / 5 Mb/s, 2ms |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
// n1 |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
// |
1032
d32bc00b565f
remove p2p strings in simple-static-routing example
Tom Henderson <tomh@tomh.org>
parents:
1029
diff
changeset
|
32 |
// - all links are point-to-point links with indicated one-way BW/delay |
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
// - CBR/UDP flows from n0 to n3, and from n3 to n1 |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec. |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
// (i.e., DataRate of 448,000 bps) |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
// - DropTail queues |
1032
d32bc00b565f
remove p2p strings in simple-static-routing example
Tom Henderson <tomh@tomh.org>
parents:
1029
diff
changeset
|
38 |
// - Tracing of queues and packet receptions to file "simple-static-routing.tr" |
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
#include <iostream> |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
#include <fstream> |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
#include <string> |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
#include <cassert> |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
|
1048 | 45 |
#include "ns3/debug.h" |
46 |
||
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
#include "ns3/command-line.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
#include "ns3/default-value.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
#include "ns3/ptr.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
#include "ns3/random-variable.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
#include "ns3/simulator.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
#include "ns3/nstime.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
#include "ns3/data-rate.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
#include "ns3/ascii-trace.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
#include "ns3/pcap-trace.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
#include "ns3/internet-node.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
#include "ns3/p2p-channel.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
#include "ns3/p2p-net-device.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
#include "ns3/mac-address.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
#include "ns3/ipv4-address.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |
#include "ns3/ipv4.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
#include "ns3/socket.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
#include "ns3/ipv4-route.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
#include "ns3/p2p-topology.h" |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
#include "ns3/onoff-application.h" |
1040
28acccd8f62b
Add static-route-manager scaffolding
Tom Henderson <tomh@tomh.org>
parents:
1038
diff
changeset
|
68 |
#include "ns3/static-route-manager.h" |
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
using namespace ns3; |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
72 |
int main (int argc, char *argv[]) |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
73 |
{ |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
74 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
75 |
// Users may find it convenient to turn on explicit debugging |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
76 |
// for selected modules; the below lines suggest how to do this |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
77 |
#if 0 |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
78 |
DebugComponentEnable("Object"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
79 |
DebugComponentEnable("Queue"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
80 |
DebugComponentEnable("DropTailQueue"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
81 |
DebugComponentEnable("Channel"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
82 |
DebugComponentEnable("PointToPointChannel"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
83 |
DebugComponentEnable("PointToPointNetDevice"); |
1056 | 84 |
DebugComponentEnable("StaticRouter"); |
1086 | 85 |
DebugComponentEnable("StaticRouteManager"); |
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
86 |
#endif |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
88 |
// Set up some default values for the simulation. Use the Bind() |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
89 |
// technique to tell the system what subclass of Queue to use, |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
90 |
// and what the queue limit is |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
91 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
92 |
// The below Bind command tells the queue factory which class to |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
93 |
// instantiate, when the queue factory is invoked in the topology code |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
94 |
Bind ("Queue", "DropTailQueue"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
95 |
|
1033 | 96 |
// This bind tells the system to use global static routing. It results in |
97 |
// a StaticRouter interface being aggregated to the internet nodes and the |
|
98 |
// creation of a Route Manager component to oversee the route generation. |
|
99 |
Bind ("DoStaticRouting", "true"); |
|
100 |
||
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
101 |
Bind ("OnOffApplicationPacketSize", "210"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
102 |
Bind ("OnOffApplicationDataRate", "448kb/s"); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
103 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
104 |
//Bind ("DropTailQueue::m_maxPackets", 30); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
105 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
106 |
// Allow the user to override any of the defaults and the above |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
// Bind()s at run-time, via command-line arguments |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
108 |
CommandLine::Parse (argc, argv); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
109 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
110 |
// Here, we will explicitly create four nodes. In more sophisticated |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
111 |
// topologies, we could configure a node factory. |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
112 |
Ptr<Node> n0 = Create<InternetNode> (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
113 |
Ptr<Node> n1 = Create<InternetNode> (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
114 |
Ptr<Node> n2 = Create<InternetNode> (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
115 |
Ptr<Node> n3 = Create<InternetNode> (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
116 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
117 |
// We create the channels first without any IP addressing information |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
118 |
Ptr<PointToPointChannel> channel0 = |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
119 |
PointToPointTopology::AddPointToPointLink ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
120 |
n0, n2, DataRate(5000000), MilliSeconds(2)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
121 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
122 |
Ptr<PointToPointChannel> channel1 = |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
123 |
PointToPointTopology::AddPointToPointLink ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
124 |
n1, n2, DataRate(5000000), MilliSeconds(2)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
125 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
126 |
Ptr<PointToPointChannel> channel2 = |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
127 |
PointToPointTopology::AddPointToPointLink ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
128 |
n2, n3, DataRate(1500000), MilliSeconds(10)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
129 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
130 |
// Later, we add IP addresses. |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
131 |
PointToPointTopology::AddIpv4Addresses ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
132 |
channel0, n0, Ipv4Address("10.1.1.1"), |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
133 |
n2, Ipv4Address("10.1.1.2")); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
134 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
135 |
PointToPointTopology::AddIpv4Addresses ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
136 |
channel1, n1, Ipv4Address("10.1.2.1"), |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
137 |
n2, Ipv4Address("10.1.2.2")); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
138 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
139 |
PointToPointTopology::AddIpv4Addresses ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
140 |
channel2, n2, Ipv4Address("10.1.3.1"), |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
141 |
n3, Ipv4Address("10.1.3.2")); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
142 |
|
1040
28acccd8f62b
Add static-route-manager scaffolding
Tom Henderson <tomh@tomh.org>
parents:
1038
diff
changeset
|
143 |
// Here, we will use the StaticRoutingManager to build routes |
1041 | 144 |
Ptr<StaticRouteManager> routeManager = Create<StaticRouteManager> (); |
145 |
// The below functions might better be placed in some kind of |
|
146 |
// Simulator::Initialization function (for further study) |
|
147 |
routeManager->BuildStaticRoutingDatabase (); |
|
148 |
routeManager->InitializeRoutes (); |
|
1040
28acccd8f62b
Add static-route-manager scaffolding
Tom Henderson <tomh@tomh.org>
parents:
1038
diff
changeset
|
149 |
|
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
150 |
// Create the OnOff application to send UDP datagrams of size |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
151 |
// 210 bytes at a rate of 448 Kb/s |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
152 |
Ptr<OnOffApplication> ooff = Create<OnOffApplication> ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
153 |
n0, |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
154 |
Ipv4Address("10.1.3.2"), |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
155 |
80, |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
156 |
"Udp", |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
157 |
ConstantVariable(1), |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
158 |
ConstantVariable(0)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
159 |
// Start the application |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
160 |
ooff->Start(Seconds(1.0)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
161 |
ooff->Stop (Seconds(10.0)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
162 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
163 |
// Create a similar flow from n3 to n1, starting at time 1.1 seconds |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
164 |
ooff = Create<OnOffApplication> ( |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
165 |
n3, |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
166 |
Ipv4Address("10.1.2.1"), |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
167 |
80, |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
168 |
"Udp", |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
169 |
ConstantVariable(1), |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
170 |
ConstantVariable(0)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
171 |
// Start the application |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
172 |
ooff->Start(Seconds(1.1)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
173 |
ooff->Stop (Seconds(10.0)); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
174 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
175 |
// Here, finish off packet routing configuration |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
176 |
// This will likely set by some global StaticRouting object in the future |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
177 |
Ptr<Ipv4> ipv4; |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
178 |
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
179 |
ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
180 |
ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
181 |
ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
182 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
183 |
// Configure tracing of all enqueue, dequeue, and NetDevice receive events |
1032
d32bc00b565f
remove p2p strings in simple-static-routing example
Tom Henderson <tomh@tomh.org>
parents:
1029
diff
changeset
|
184 |
// Trace output will be sent to the simple-static-routing.tr file |
d32bc00b565f
remove p2p strings in simple-static-routing example
Tom Henderson <tomh@tomh.org>
parents:
1029
diff
changeset
|
185 |
AsciiTrace asciitrace ("simple-static-routing.tr"); |
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
186 |
asciitrace.TraceAllQueues (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
187 |
asciitrace.TraceAllNetDeviceRx (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
188 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
189 |
// Also configure some tcpdump traces; each interface will be traced |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
190 |
// The output files will be named simple-p2p.pcap-<nodeId>-<interfaceId> |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
191 |
// and can be read by the "tcpdump -r" command (use "-tt" option to |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
192 |
// display timestamps correctly) |
1032
d32bc00b565f
remove p2p strings in simple-static-routing example
Tom Henderson <tomh@tomh.org>
parents:
1029
diff
changeset
|
193 |
PcapTrace pcaptrace ("simple-static-routing.pcap"); |
1029
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
194 |
pcaptrace.TraceAllIp (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
195 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
196 |
Simulator::Run (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
197 |
|
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
198 |
Simulator::Destroy (); |
deca48edd34e
add example static routing script; a few changes to static-router LSAs
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
199 |
} |