25 import ns.applications
 
   30 import ns.point_to_point
 
   80     mobility = node.GetObject(ns.mobility.MobilityModel.GetTypeId())
 
   81     mobility.SetPosition(position)
 
   85     mobility = node.GetObject(ns.mobility.MobilityModel.GetTypeId())
 
   86     return mobility.GetPosition()
 
   94     ns.core.Simulator.Schedule(ns.core.Seconds(1.0), AdvancePosition, node)
 
   98     ns.core.CommandLine().Parse(argv)
 
  100     ns.network.Packet.EnablePrinting();
 
  103     ns.core.Config.SetDefault(
"ns3::WifiRemoteStationManager::RtsCtsThreshold", ns.core.StringValue(
"0"))
 
  105     ns.core.Config.SetDefault(
"ns3::WifiRemoteStationManager::FragmentationThreshold", ns.core.StringValue(
"2200"))
 
  107     wifi = ns.wifi.WifiHelper.Default()
 
  108     mobility = ns.mobility.MobilityHelper()
 
  109     stas = ns.network.NodeContainer()
 
  110     ap = ns.network.NodeContainer()
 
  112     packetSocket = ns.network.PacketSocketHelper()
 
  118     packetSocket.Install(stas)
 
  119     packetSocket.Install(ap)
 
  121     wifiPhy = ns.wifi.YansWifiPhyHelper.Default()
 
  122     wifiChannel = ns.wifi.YansWifiChannelHelper.Default()
 
  123     wifiPhy.SetChannel(wifiChannel.Create())
 
  125     ssid = ns.wifi.Ssid(
"wifi-default")
 
  126     wifi.SetRemoteStationManager(
"ns3::ArfWifiManager")
 
  127     wifiMac = ns.wifi.NqosWifiMacHelper.Default()
 
  130     wifiMac.SetType(
"ns3::StaWifiMac",
 
  131                     "Ssid", ns.wifi.SsidValue(ssid),
 
  132                     "ActiveProbing", ns.core.BooleanValue(
False))
 
  133     staDevs = wifi.Install(wifiPhy, wifiMac, stas)
 
  135     wifiMac.SetType(
"ns3::ApWifiMac",
 
  136                     "Ssid", ns.wifi.SsidValue(ssid),
 
  137                     "BeaconGeneration", ns.core.BooleanValue(
True),
 
  138                     "BeaconInterval", ns.core.TimeValue(ns.core.Seconds(2.5)))
 
  139     wifi.Install(wifiPhy, wifiMac, ap)
 
  142     mobility.Install(stas)
 
  145     ns.core.Simulator.Schedule(ns.core.Seconds(1.0), AdvancePosition, ap.Get(0))
 
  147     socket = ns.network.PacketSocketAddress()
 
  148     socket.SetSingleDevice(staDevs.Get(0).GetIfIndex())
 
  149     socket.SetPhysicalAddress(staDevs.Get(1).GetAddress())
 
  150     socket.SetProtocol(1)
 
  152     onoff = ns.applications.OnOffHelper(
"ns3::PacketSocketFactory", ns.network.Address(socket))
 
  153     onoff.SetConstantRate (ns.network.DataRate (
"500kb/s"))
 
  155     apps = onoff.Install(ns.network.NodeContainer(stas.Get(0)))
 
  156     apps.Start(ns.core.Seconds(0.5))
 
  157     apps.Stop(ns.core.Seconds(43.0))
 
  159     ns.core.Simulator.Stop(ns.core.Seconds(44.0))
 
  169     ns.core.Simulator.Run()
 
  170     ns.core.Simulator.Destroy()
 
  175 if __name__ == 
'__main__':
 
  176     sys.exit(
main(sys.argv))