12except ModuleNotFoundError:
14 "Error: ns3 Python module not found;"
15 " Python bindings may not be enabled"
16 " or your PYTHONPATH might not be properly configured"
21 ns.CommandLine().Parse(argv)
28 ns.GlobalValue.Bind(
"SimulatorImplementationType", ns.StringValue(
"ns3::RealtimeSimulatorImpl"))
29 ns.GlobalValue.Bind(
"ChecksumEnabled", ns.BooleanValue(
True))
36 nodes = ns.NodeContainer()
42 wifi = ns.WifiHelper()
43 wifi.SetStandard(ns.WIFI_STANDARD_80211a)
44 wifi.SetRemoteStationManager(
45 "ns3::ConstantRateWifiManager",
"DataMode", ns.StringValue(
"OfdmRate54Mbps")
51 wifiMac = ns.WifiMacHelper()
52 wifiMac.SetType(
"ns3::AdhocWifiMac")
57 wifiChannel = ns.YansWifiChannelHelper.Default()
58 wifiPhy = ns.YansWifiPhyHelper()
59 wifiPhy.SetChannel(wifiChannel.Create())
64 devices = wifi.Install(wifiPhy, wifiMac, nodes)
70 mobility = ns.MobilityHelper()
71 positionAlloc = ns.ListPositionAllocator()
72 positionAlloc.Add(ns.Vector(0.0, 0.0, 0.0))
73 positionAlloc.Add(ns.Vector(5.0, 0.0, 0.0))
74 mobility.SetPositionAllocator(positionAlloc)
75 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel")
76 mobility.Install(nodes)
86 tapBridge = ns.TapBridgeHelper()
87 tapBridge.SetAttribute(
"Mode", ns.StringValue(
"UseLocal"))
88 tapBridge.SetAttribute(
"DeviceName", ns.StringValue(
"tap-left"))
89 tapBridge.Install(nodes.Get(0), devices.Get(0))
95 tapBridge.SetAttribute(
"DeviceName", ns.StringValue(
"tap-right"))
96 tapBridge.Install(nodes.Get(1), devices.Get(1))
101 ns.Simulator.Stop(ns.Seconds(600))
103 ns.Simulator.Destroy()
107if __name__ ==
"__main__":
108 sys.exit(main(sys.argv))