23except ModuleNotFoundError:
25 "Error: ns3 Python module not found;"
26 " Python bindings may not be enabled"
27 " or your PYTHONPATH might not be properly configured"
32 ns.CommandLine().Parse(argv)
39 ns.GlobalValue.Bind(
"SimulatorImplementationType", ns.StringValue(
"ns3::RealtimeSimulatorImpl"))
40 ns.GlobalValue.Bind(
"ChecksumEnabled", ns.BooleanValue(
True))
47 nodes = ns.NodeContainer()
53 wifi = ns.WifiHelper()
54 wifi.SetStandard(ns.WIFI_STANDARD_80211a)
55 wifi.SetRemoteStationManager(
56 "ns3::ConstantRateWifiManager",
"DataMode", ns.StringValue(
"OfdmRate54Mbps")
62 wifiMac = ns.WifiMacHelper()
63 wifiMac.SetType(
"ns3::AdhocWifiMac")
68 wifiChannel = ns.YansWifiChannelHelper.Default()
69 wifiPhy = ns.YansWifiPhyHelper()
70 wifiPhy.SetChannel(wifiChannel.Create())
75 devices = wifi.Install(wifiPhy, wifiMac, nodes)
81 mobility = ns.MobilityHelper()
82 positionAlloc = ns.ListPositionAllocator()
83 positionAlloc.Add(ns.Vector(0.0, 0.0, 0.0))
84 positionAlloc.Add(ns.Vector(5.0, 0.0, 0.0))
85 mobility.SetPositionAllocator(positionAlloc)
86 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel")
87 mobility.Install(nodes)
97 tapBridge = ns.TapBridgeHelper()
98 tapBridge.SetAttribute(
"Mode", ns.StringValue(
"UseLocal"))
99 tapBridge.SetAttribute(
"DeviceName", ns.StringValue(
"tap-left"))
100 tapBridge.Install(nodes.Get(0), devices.Get(0))
106 tapBridge.SetAttribute(
"DeviceName", ns.StringValue(
"tap-right"))
107 tapBridge.Install(nodes.Get(1), devices.Get(1))
112 ns.Simulator.Stop(ns.Seconds(600))
114 ns.Simulator.Destroy()
118if __name__ ==
"__main__":
119 sys.exit(main(sys.argv))