equal
deleted
inserted
replaced
72 #include "ns3/simulator-module.h" |
72 #include "ns3/simulator-module.h" |
73 #include "ns3/node-module.h" |
73 #include "ns3/node-module.h" |
74 #include "ns3/core-module.h" |
74 #include "ns3/core-module.h" |
75 #include "ns3/helper-module.h" |
75 #include "ns3/helper-module.h" |
76 #include "ns3/bridge-module.h" |
76 #include "ns3/bridge-module.h" |
77 #include "ns3/global-route-manager.h" |
|
78 |
77 |
79 using namespace ns3; |
78 using namespace ns3; |
80 |
79 |
81 NS_LOG_COMPONENT_DEFINE ("CsmaBridgeOneHopExample"); |
80 NS_LOG_COMPONENT_DEFINE ("CsmaBridgeOneHopExample"); |
82 |
81 |
140 // which are the three CSMA net devices on the node in the diagram above. |
139 // which are the three CSMA net devices on the node in the diagram above. |
141 // |
140 // |
142 BridgeHelper bridge; |
141 BridgeHelper bridge; |
143 bridge.Install (bridge1, topBridgeDevices); |
142 bridge.Install (bridge1, topBridgeDevices); |
144 |
143 |
145 // Add internet stack to the topLan nodes |
144 // Add internet stack to the router nodes |
|
145 NodeContainer routerNodes (n0, n1, n2, n3, n4); |
146 InternetStackHelper internet; |
146 InternetStackHelper internet; |
147 internet.Install (topLan); |
147 internet.Install (routerNodes); |
148 |
148 |
149 // Repeat for bottom bridged LAN |
149 // Repeat for bottom bridged LAN |
150 NetDeviceContainer bottomLanDevices; |
150 NetDeviceContainer bottomLanDevices; |
151 NetDeviceContainer bottomBridgeDevices; |
151 NetDeviceContainer bottomBridgeDevices; |
152 NodeContainer bottomLan (n2, n3, n4); |
152 NodeContainer bottomLan (n2, n3, n4); |
156 bottomLanDevices.Add (link.Get (0)); |
156 bottomLanDevices.Add (link.Get (0)); |
157 bottomBridgeDevices.Add (link.Get (1)); |
157 bottomBridgeDevices.Add (link.Get (1)); |
158 } |
158 } |
159 bridge.Install (bridge2, bottomBridgeDevices); |
159 bridge.Install (bridge2, bottomBridgeDevices); |
160 |
160 |
161 // Add internet stack to the bottomLan nodes |
|
162 internet.Install (NodeContainer (n3, n4)); |
|
163 |
|
164 // We've got the "hardware" in place. Now we need to add IP addresses. |
161 // We've got the "hardware" in place. Now we need to add IP addresses. |
165 NS_LOG_INFO ("Assign IP Addresses."); |
162 NS_LOG_INFO ("Assign IP Addresses."); |
166 Ipv4AddressHelper ipv4; |
163 Ipv4AddressHelper ipv4; |
167 ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
164 ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
168 ipv4.Assign (topLanDevices); |
165 ipv4.Assign (topLanDevices); |
172 // |
169 // |
173 // Create router nodes, initialize routing database and set up the routing |
170 // Create router nodes, initialize routing database and set up the routing |
174 // tables in the nodes. We excuse the bridge nodes from having to serve as |
171 // tables in the nodes. We excuse the bridge nodes from having to serve as |
175 // routers, since they don't even have internet stacks on them. |
172 // routers, since they don't even have internet stacks on them. |
176 // |
173 // |
177 NodeContainer routerNodes (n0, n1, n2, n3, n4); |
174 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
178 GlobalRouteManager::PopulateRoutingTables (routerNodes); |
|
179 |
175 |
180 // |
176 // |
181 // Create an OnOff application to send UDP datagrams from node zero to node 1. |
177 // Create an OnOff application to send UDP datagrams from node zero to node 1. |
182 // |
178 // |
183 NS_LOG_INFO ("Create Applications."); |
179 NS_LOG_INFO ("Create Applications."); |