Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
(...skipping 30 matching lines...) Expand all Loading... | |
41 int· | 41 int· |
42 main (int argc, char *argv[]) | 42 main (int argc, char *argv[]) |
43 { | 43 { |
44 LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); | 44 LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); |
45 LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); | 45 LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); |
46 | 46 |
47 NodeContainer nodes12; | 47 NodeContainer nodes12; |
48 nodes12.Create (2); | 48 nodes12.Create (2); |
49 | 49 |
50 NodeContainer nodes23; | 50 NodeContainer nodes23; |
51 nodes23.Add(nodes12.Get(1)); | 51 nodes23.Add (nodes12.Get (1)); |
52 nodes23.Create(1); | 52 nodes23.Create (1); |
53 | 53 |
54 NodeContainer nodes34; | 54 NodeContainer nodes34; |
55 nodes34.Add(nodes23.Get(1)); | 55 nodes34.Add(nodes23.Get (1)); |
56 nodes34.Create(1); | 56 nodes34.Create (1); |
57 | 57 |
58 PointToPointHelper pointToPoint; | 58 PointToPointHelper pointToPoint; |
59 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); | 59 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); |
60 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); | 60 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); |
61 | 61 |
62 NodeContainer allNodes = NodeContainer(nodes12, nodes23.Get(1), nodes34.Get(1) ); | 62 NodeContainer allNodes = NodeContainer (nodes12, nodes23.Get (1), nodes34.Get (1)); |
63 ·· | 63 ·· |
64 // NixHelper to install nix-vector routing | 64 // NixHelper to install nix-vector routing |
65 // on all nodes | 65 // on all nodes |
66 Ipv4NixVectorHelper nixHelper; | 66 Ipv4NixVectorHelper nixRouting; |
67 Ipv4StaticRoutingHelper staticRouting; | 67 Ipv4StaticRoutingHelper staticRouting; |
craigdo
2009/09/11 22:38:17
Why have nixHelper, and staticRouting? It seems c
Josh Pelkey
2009/09/12 18:34:14
Done.
| |
68 | 68 |
69 Ipv4ListRoutingHelper list; | 69 Ipv4ListRoutingHelper list; |
70 list.Add (staticRouting, 0); | 70 list.Add (staticRouting, 0); |
71 list.Add (nixHelper, 10); | 71 list.Add (nixRouting, 10); |
72 | 72 |
73 InternetStackHelper stack; | 73 InternetStackHelper stack; |
74 stack.SetRoutingHelper (list); | 74 stack.SetRoutingHelper (list); |
75 stack.Install (allNodes); | 75 stack.Install (allNodes); |
76 | 76 |
77 NetDeviceContainer devices12; | 77 NetDeviceContainer devices12; |
78 NetDeviceContainer devices23; | 78 NetDeviceContainer devices23; |
79 NetDeviceContainer devices34; | 79 NetDeviceContainer devices34; |
80 devices12 = pointToPoint.Install (nodes12); | 80 devices12 = pointToPoint.Install (nodes12); |
81 devices23 = pointToPoint.Install (nodes23); | 81 devices23 = pointToPoint.Install (nodes23); |
82 devices34 = pointToPoint.Install (nodes34); | 82 devices34 = pointToPoint.Install (nodes34); |
83 | 83 |
84 Ipv4AddressHelper address1; | 84 Ipv4AddressHelper address1; |
85 address1.SetBase ("10.1.1.0", "255.255.255.0"); | 85 address1.SetBase ("10.1.1.0", "255.255.255.0"); |
86 Ipv4AddressHelper address2; | 86 Ipv4AddressHelper address2; |
87 address2.SetBase ("10.1.2.0", "255.255.255.0"); | 87 address2.SetBase ("10.1.2.0", "255.255.255.0"); |
88 Ipv4AddressHelper address3; | 88 Ipv4AddressHelper address3; |
89 address3.SetBase ("10.1.3.0", "255.255.255.0"); | 89 address3.SetBase ("10.1.3.0", "255.255.255.0"); |
90 | |
91 | 90 |
92 address1.Assign (devices12); | 91 address1.Assign (devices12); |
93 address2.Assign (devices23); | 92 address2.Assign (devices23); |
94 Ipv4InterfaceContainer interfaces = address3.Assign (devices34); | 93 Ipv4InterfaceContainer interfaces = address3.Assign (devices34); |
95 | 94 |
96 UdpEchoServerHelper echoServer (9); | 95 UdpEchoServerHelper echoServer (9); |
97 | 96 |
98 ApplicationContainer serverApps = echoServer.Install (nodes34.Get (1)); | 97 ApplicationContainer serverApps = echoServer.Install (nodes34.Get (1)); |
99 serverApps.Start (Seconds (1.0)); | 98 serverApps.Start (Seconds (1.0)); |
100 serverApps.Stop (Seconds (10.0)); | 99 serverApps.Stop (Seconds (10.0)); |
101 | 100 |
102 UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9); | 101 UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9); |
103 echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); | 102 echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); |
104 echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); | 103 echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); |
105 echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); | 104 echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); |
106 | 105 |
107 ApplicationContainer clientApps = echoClient.Install (nodes12.Get (0)); | 106 ApplicationContainer clientApps = echoClient.Install (nodes12.Get (0)); |
108 clientApps.Start (Seconds (2.0)); | 107 clientApps.Start (Seconds (2.0)); |
109 clientApps.Stop (Seconds (10.0)); | 108 clientApps.Stop (Seconds (10.0)); |
110 | 109 |
111 | 110 |
112 Simulator::Run (); | 111 Simulator::Run (); |
113 Simulator::Destroy (); | 112 Simulator::Destroy (); |
114 return 0; | 113 return 0; |
115 } | 114 } |
LEFT | RIGHT |