|
|
| 18 |
|
18 |
|
| 19 |
|
19 |
|
| 20 |
// This script exercises global routing code in a mixed point-to-point |
20 |
// This script exercises global routing code in a mixed point-to-point |
| 21 |
// and csma/cd environment |
21 |
// and csma/cd environment. We bring up and down interfaces and observe |
|
|
22 |
// the effect on global routing. We explicitly enable the attribute |
| 23 |
// to respond to interface events, so that routes are recomputed |
| 24 |
// automatically. |
| 22 |
// |
25 |
// |
| 23 |
// Network topology |
26 |
// Network topology |
| 24 |
// |
27 |
// |
|
|
| 41 |
// n1 to n6 is via the direct point-to-point link |
44 |
// n1 to n6 is via the direct point-to-point link |
| 42 |
// At time 1s, start CBR traffic flow from n1 to n6 |
45 |
// At time 1s, start CBR traffic flow from n1 to n6 |
| 43 |
// At time 2s, set the n1 point-to-point interface to down. Packets |
46 |
// At time 2s, set the n1 point-to-point interface to down. Packets |
| 44 |
// will start to be dropped |
47 |
// will be diverted to the n1-n2-n5-n6 path |
| 45 |
// At time 3s, call RecomputeRoutingTables() and traffic will |
48 |
// At time 4s, re-enable the n1/n6 interface to up. n1-n6 route restored. |
| 46 |
// start flowing again on the alternate path |
|
|
| 47 |
// At time 4s, re-enable the n1/n6 interface to up. Will not change routing |
| 48 |
// At time 5s, call RecomputeRoutingTables() and traffic will start flowing |
| 49 |
// again on the original path |
| 50 |
// At time 6s, set the n6-n1 point-to-point Ipv4 interface to down (note, this |
49 |
// At time 6s, set the n6-n1 point-to-point Ipv4 interface to down (note, this |
| 51 |
// keeps the point-to-point link "up" from n1's perspective). Packets |
50 |
// keeps the point-to-point link "up" from n1's perspective). Traffic will |
| 52 |
// will traverse the link and be dropped at n6 upon receipt. These drops |
51 |
// flow through the path n1-n2-n5-n6 |
| 53 |
// are not visible in the pcap trace but in the ascii trace. |
52 |
// At time 8s, bring the interface back up. Path n1-n6 is restored |
| 54 |
// At time 7s, call RecomputeRoutingTables() and traffic will flow again |
|
|
| 55 |
// through the path n1-n2-n5-n6 |
| 56 |
// At time 8s, bring the interface back up. |
| 57 |
// At time 9s, call RecomputeRoutingTables() and traffic will flow again |
| 58 |
// through the path n1-n6 |
| 59 |
// At time 10s, stop the first flow. |
53 |
// At time 10s, stop the first flow. |
| 60 |
// At time 11s, start a new flow, but to n6's other IP address (the one |
54 |
// At time 11s, start a new flow, but to n6's other IP address (the one |
| 61 |
// on the n1/n6 p2p link) |
55 |
// on the n1/n6 p2p link) |
| 62 |
// At time 12s, bring the n1 interface down between n1 and n6. Packets |
56 |
// At time 12s, bring the n1 interface down between n1 and n6. Packets |
| 63 |
// will start to be dropped |
57 |
// will be diverted to the alternate path |
| 64 |
// At time 13s, call RecomputeRoutingTables() and traffic will |
|
|
| 65 |
// start flowing again on the alternate path |
| 66 |
// At time 14s, re-enable the n1/n6 interface to up. This will change |
58 |
// At time 14s, re-enable the n1/n6 interface to up. This will change |
| 67 |
// routing back to n1-n6 since the interface up notification will cause |
59 |
// routing back to n1-n6 since the interface up notification will cause |
| 68 |
// a new local interface route, at higher priority than global routing |
60 |
// a new local interface route, at higher priority than global routing |
| 69 |
// At time 15s, call RecomputeRoutingTables(), but there is no effect |
|
|
| 70 |
// since global routing is lower in priority than static routing |
| 71 |
// At time 16s, stop the second flow. |
61 |
// At time 16s, stop the second flow. |
| 72 |
|
62 |
|
| 73 |
// - Tracing of queues and packet receptions to file "dynamic-global-routing.tr" |
63 |
// - Tracing of queues and packet receptions to file "dynamic-global-routing.tr" |
|
|
| 89 |
int |
79 |
int |
| 90 |
main (int argc, char *argv[]) |
80 |
main (int argc, char *argv[]) |
| 91 |
{ |
81 |
{ |
|
|
82 |
// The below value configures the default behavior of global routing. |
| 83 |
// By default, it is disabled. To respond to interface events, set to true |
| 84 |
Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (false)); |
| 85 |
|
| 92 |
// Allow the user to override any of the defaults and the above |
86 |
// Allow the user to override any of the defaults and the above |
| 93 |
// Bind ()s at run-time, via command-line arguments |
87 |
// Bind ()s at run-time, via command-line arguments |
| 94 |
CommandLine cmd; |
88 |
CommandLine cmd; |
|
|
| 206 |
uint32_t ipv4ifIndex1 = 2; |
200 |
uint32_t ipv4ifIndex1 = 2; |
| 207 |
|
201 |
|
| 208 |
Simulator::Schedule (Seconds (2),&Ipv4::SetDown,ipv41, ipv4ifIndex1); |
202 |
Simulator::Schedule (Seconds (2),&Ipv4::SetDown,ipv41, ipv4ifIndex1); |
| 209 |
Simulator::Schedule (Seconds (3),&Ipv4GlobalRoutingHelper::RecomputeRoutingTables); |
|
|
| 210 |
Simulator::Schedule (Seconds (4),&Ipv4::SetUp,ipv41, ipv4ifIndex1); |
203 |
Simulator::Schedule (Seconds (4),&Ipv4::SetUp,ipv41, ipv4ifIndex1); |
| 211 |
Simulator::Schedule (Seconds (5),&Ipv4GlobalRoutingHelper::RecomputeRoutingTables); |
|
|
| 212 |
|
204 |
|
| 213 |
Ptr<Node> n6 = c.Get (6); |
205 |
Ptr<Node> n6 = c.Get (6); |
| 214 |
Ptr<Ipv4> ipv46 = n6->GetObject<Ipv4> (); |
206 |
Ptr<Ipv4> ipv46 = n6->GetObject<Ipv4> (); |
|
|
| 216 |
// then the next p2p is numbered 2 |
208 |
// then the next p2p is numbered 2 |
| 217 |
uint32_t ipv4ifIndex6 = 2; |
209 |
uint32_t ipv4ifIndex6 = 2; |
| 218 |
Simulator::Schedule (Seconds (6),&Ipv4::SetDown,ipv46, ipv4ifIndex6); |
210 |
Simulator::Schedule (Seconds (6),&Ipv4::SetDown,ipv46, ipv4ifIndex6); |
| 219 |
Simulator::Schedule (Seconds (7),&Ipv4GlobalRoutingHelper::RecomputeRoutingTables); |
|
|
| 220 |
Simulator::Schedule (Seconds (8),&Ipv4::SetUp,ipv46, ipv4ifIndex6); |
211 |
Simulator::Schedule (Seconds (8),&Ipv4::SetUp,ipv46, ipv4ifIndex6); |
| 221 |
Simulator::Schedule (Seconds (9),&Ipv4GlobalRoutingHelper::RecomputeRoutingTables); |
|
|
| 222 |
|
212 |
|
| 223 |
Simulator::Schedule (Seconds (12),&Ipv4::SetDown,ipv41, ipv4ifIndex1); |
213 |
Simulator::Schedule (Seconds (12),&Ipv4::SetDown,ipv41, ipv4ifIndex1); |
| 224 |
Simulator::Schedule (Seconds (13),&Ipv4GlobalRoutingHelper::RecomputeRoutingTables); |
|
|
| 225 |
Simulator::Schedule (Seconds (14),&Ipv4::SetUp,ipv41, ipv4ifIndex1); |
214 |
Simulator::Schedule (Seconds (14),&Ipv4::SetUp,ipv41, ipv4ifIndex1); |
| 226 |
Simulator::Schedule (Seconds (15),&Ipv4GlobalRoutingHelper::RecomputeRoutingTables); |
|
|
| 227 |
|
215 |
|
| 228 |
NS_LOG_INFO ("Run Simulation."); |
216 |
NS_LOG_INFO ("Run Simulation."); |
| 229 |
Simulator::Run (); |
217 |
Simulator::Run (); |