76 Ptr<MobilityModel> mob = node->GetObject<MobilityModel>();
77 Vector pos = mob->GetPosition();
81 mob->SetPosition(pos);
82 Simulator::Schedule(Seconds(1.0), AdvancePosition, node);
86 ns.core.CommandLine().Parse(argv)
88 ns.network.Packet.EnablePrinting();
90 wifi = ns.wifi.WifiHelper()
91 mobility = ns.mobility.MobilityHelper()
92 stas = ns.network.NodeContainer()
93 ap = ns.network.NodeContainer()
95 packetSocket = ns.network.PacketSocketHelper()
101 packetSocket.Install(stas)
102 packetSocket.Install(ap)
104 wifiPhy = ns.wifi.YansWifiPhyHelper()
105 wifiChannel = ns.wifi.YansWifiChannelHelper.Default()
106 wifiPhy.SetChannel(wifiChannel.Create())
108 ssid = ns.wifi.Ssid(
"wifi-default")
109 wifiMac = ns.wifi.WifiMacHelper()
112 wifiMac.SetType(
"ns3::StaWifiMac",
113 "Ssid", ns.wifi.SsidValue(ssid))
114 staDevs = wifi.Install(wifiPhy, wifiMac, stas)
116 wifiMac.SetType(
"ns3::ApWifiMac",
117 "Ssid", ns.wifi.SsidValue(ssid))
118 wifi.Install(wifiPhy, wifiMac, ap)
121 mobility.Install(stas)
124 ns.core.Simulator.Schedule(ns.core.Seconds(1.0), ns.cppyy.gbl.AdvancePosition, ap.Get(0))
126 socket = ns.network.PacketSocketAddress()
127 socket.SetSingleDevice(staDevs.Get(0).GetIfIndex())
128 socket.SetPhysicalAddress(staDevs.Get(1).GetAddress())
129 socket.SetProtocol(1)
131 onoff = ns.applications.OnOffHelper(
"ns3::PacketSocketFactory", socket.ConvertTo())
132 onoff.SetConstantRate (ns.network.DataRate (
"500kb/s"))
134 apps = onoff.Install(ns.network.NodeContainer(stas.Get(0)))
135 apps.Start(ns.core.Seconds(0.5))
136 apps.Stop(ns.core.Seconds(43.0))
138 ns.core.Simulator.Stop(ns.core.Seconds(44.0))
148 ns.core.Simulator.Run()
149 ns.core.Simulator.Destroy()
154if __name__ ==
'__main__':
155 sys.exit(main(sys.argv))
static void AdvancePosition(Ptr< Node > node)
Move a node position by 5m on the x axis every second, up to 210m.