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",
114 ns.core.BooleanValue(
True),
116 ns.wifi.SsidValue(ssid))
117 staDevs = wifi.Install(wifiPhy, wifiMac, stas)
119 wifiMac.SetType(
"ns3::ApWifiMac",
120 "Ssid", ns.wifi.SsidValue(ssid))
121 wifi.Install(wifiPhy, wifiMac, ap)
124 mobility.Install(stas)
127 ns.core.Simulator.Schedule(ns.core.Seconds(1.0), ns.cppyy.gbl.AdvancePosition, ap.Get(0))
129 socket = ns.network.PacketSocketAddress()
130 socket.SetSingleDevice(staDevs.Get(0).GetIfIndex())
131 socket.SetPhysicalAddress(staDevs.Get(1).GetAddress())
132 socket.SetProtocol(1)
134 onoff = ns.applications.OnOffHelper(
"ns3::PacketSocketFactory", socket.ConvertTo())
135 onoff.SetConstantRate (ns.network.DataRate (
"500kb/s"))
137 apps = onoff.Install(ns.network.NodeContainer(stas.Get(0)))
138 apps.Start(ns.core.Seconds(0.5))
139 apps.Stop(ns.core.Seconds(43.0))
141 ns.core.Simulator.Stop(ns.core.Seconds(44.0))
151 ns.core.Simulator.Run()
152 ns.core.Simulator.Destroy()
157if __name__ ==
'__main__':
158 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.