Zdroje 1: examples/routing/static-routing-slash32.cc examples/routing/rip-simple-network.cc
Zdroje 2: examples/wireless/wifi-simple-adhoc-grid.cc examples/wireless/wifi-tcp.cc src/aodv/examples/aodv.cc
Zdroje 3: nižšie
Pokec:
nastavenie smerovania v ns3
Môžu spolupracovať Ipv4ListRoutingHelper . Nastavením metriky a priority…
video (zatial bez audia doplnim coskoro)
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); NetDeviceContainer ndc1 = csma.Install (net1); NetDeviceContainer ndc2 = csma.Install (net2); NetDeviceContainer ndc3 = csma.Install (net3); NetDeviceContainer ndc4 = csma.Install (net4); NetDeviceContainer ndc5 = csma.Install (net5); NetDeviceContainer ndc6 = csma.Install (net6); NetDeviceContainer ndc7 = csma.Install (net7); NS_LOG_INFO ("Create IPv4 and routing"); RipHelper ripRouting; // Rule of thumb: // Interfaces are added sequentially, starting from 0 // However, interface 0 is always the loopback... ripRouting.ExcludeInterface (a, 1); ripRouting.ExcludeInterface (d, 3); ripRouting.SetInterfaceMetric (c, 3, met1); ripRouting.SetInterfaceMetric (d, 1, met1); ripRouting.SetInterfaceMetric (a, 3, met2); ripRouting.SetInterfaceMetric (c, 1, met2); Ipv4ListRoutingHelper listRH; listRH.Add (ripRouting, prRIP); Ipv4StaticRoutingHelper staticRh; listRH.Add (staticRh, prSTA); InternetStackHelper internet; internet.SetIpv6StackInstall (false); internet.SetRoutingHelper (listRH); internet.Install (routers); InternetStackHelper internetNodes; internetNodes.SetIpv6StackInstall (false); internetNodes.Install (nodes); // Assign addresses. // The source and destination networks have global addresses // The "core" network just needs link-local addresses for routing. // We assign global addresses to the routers as well to receive // ICMPv6 errors. NS_LOG_INFO ("Assign IPv4 Addresses."); Ipv4AddressHelper ipv4; ipv4.SetBase (Ipv4Address ("10.0.0.0"), Ipv4Mask ("255.255.255.0")); Ipv4InterfaceContainer iic1 = ipv4.Assign (ndc1); ipv4.SetBase (Ipv4Address ("10.0.1.0"), Ipv4Mask ("255.255.255.0")); Ipv4InterfaceContainer iic2 = ipv4.Assign (ndc2); ipv4.SetBase (Ipv4Address ("10.0.2.0"), Ipv4Mask ("255.255.255.0")); Ipv4InterfaceContainer iic3 = ipv4.Assign (ndc3); ipv4.SetBase (Ipv4Address ("10.0.3.0"), Ipv4Mask ("255.255.255.0")); Ipv4InterfaceContainer iic4 = ipv4.Assign (ndc4); ipv4.SetBase (Ipv4Address ("10.0.4.0"), Ipv4Mask ("255.255.255.0")); Ipv4InterfaceContainer iic5 = ipv4.Assign (ndc5); ipv4.SetBase (Ipv4Address ("10.0.5.0"), Ipv4Mask ("255.255.255.0")); Ipv4InterfaceContainer iic6 = ipv4.Assign (ndc6); ipv4.SetBase (Ipv4Address ("10.0.6.0"), Ipv4Mask ("255.255.255.0")); Ipv4InterfaceContainer iic7 = ipv4.Assign (ndc7); Ptr<Ipv4StaticRouting> staticRouting; staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (a->GetObject<Ipv4> ()->GetRoutingProtocol() ); staticRouting->SetDefaultRoute("10.0.1.2",2,met0); // A->B, interface, metrika |
upravene aodv (nizsie) nie je spustitelne vo VM PS2-012 su tam pridane funkcie z kniznice BOOST, s ktorou to treba konfigurovat ta je vyuzita vo funkcii changeMobility od čísla riadku 239.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
void AodvExample::InstallApplications (){ ns3::PacketMetadata::Enable (); V4PingHelper ping (interfaces.GetAddress (size - 1)); ping.SetAttribute ("Verbose", BooleanValue (false)); ApplicationContainer p; p.Add(ping.Install(nodes.Get (0))); p.Start (Seconds (0)); p.Stop (Seconds (totalTime) - Seconds (0.001)); // move node away Ptr<Node> node = nodes.Get (size/2); Ptr<MobilityModel> mob = node->GetObject<MobilityModel> (); Simulator::Schedule (Seconds (totalTime/4), &MobilityModel::SetPosition, mob, Vector (size/2*step, size/2*step, 0)); Simulator::Schedule (Seconds (totalTime/4), &changeMobility, "Sns3::UniformRandomVariable[Min=10.0|Max=50.0];T500ms;Dns3::ConstantRandomVariable[Constant=-2.5]"); Config::ConnectWithoutContext("NodeList/9/$ns3::MobilityModel/CourseChange",MakeBoundCallback(&pohyb, this)); Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt",MakeCallback(&AodvExample::MojaFunkcia, this)); Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",MakeCallback(&AodvExample::TxStart, this)); Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",MakeCallback(&AodvExample::RxEnd, this)); } |