Fix Python coding style.
This commit is contained in:
@@ -104,7 +104,7 @@ def main(argv):
|
||||
sink = ns3.PacketSinkHelper("ns3::UdpSocketFactory",
|
||||
ns3.Address(ns3.InetSocketAddress(ns3.Ipv4Address.GetAny(), port)))
|
||||
app = sink.Install(ns3.NodeContainer(terminals.Get(1)))
|
||||
app.Start (ns3.Seconds (0.0))
|
||||
app.Start(ns3.Seconds(0.0))
|
||||
|
||||
#
|
||||
# Create a similar flow from n3 to n0, starting at time 1.1 seconds
|
||||
@@ -116,7 +116,7 @@ def main(argv):
|
||||
app.Stop(ns3.Seconds(10.0))
|
||||
|
||||
app = sink.Install(ns3.NodeContainer(terminals.Get(0)))
|
||||
app.Start (ns3.Seconds (0.0))
|
||||
app.Start(ns3.Seconds(0.0))
|
||||
|
||||
#
|
||||
# Configure tracing of all enqueue, dequeue, and NetDevice receive events.
|
||||
|
||||
@@ -114,13 +114,13 @@ def main(argv):
|
||||
# our container
|
||||
#
|
||||
wifi = ns3.WifiHelper()
|
||||
mac = ns3.NqosWifiMacHelper.Default ()
|
||||
mac.SetType ("ns3::AdhocWifiMac")
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode", ns3.StringValue ("wifia-54mbs"))
|
||||
wifiPhy = ns3.YansWifiPhyHelper.Default ()
|
||||
wifiChannel = ns3.YansWifiChannelHelper.Default ()
|
||||
wifiPhy.SetChannel (wifiChannel.Create ())
|
||||
mac = ns3.NqosWifiMacHelper.Default()
|
||||
mac.SetType("ns3::AdhocWifiMac")
|
||||
wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
|
||||
"DataMode", ns3.StringValue("wifia-54mbs"))
|
||||
wifiPhy = ns3.YansWifiPhyHelper.Default()
|
||||
wifiChannel = ns3.YansWifiChannelHelper.Default()
|
||||
wifiPhy.SetChannel(wifiChannel.Create())
|
||||
backboneDevices = wifi.Install(wifiPhy, mac, backbone)
|
||||
#
|
||||
# Add the IPv4 protocol stack to the nodes in our container
|
||||
@@ -128,8 +128,8 @@ def main(argv):
|
||||
print "Enabling OLSR routing on all backbone nodes"
|
||||
internet = ns3.InternetStackHelper()
|
||||
olsr = ns3.OlsrHelper()
|
||||
internet.SetRoutingHelper (olsr);
|
||||
internet.Install (backbone);
|
||||
internet.SetRoutingHelper(olsr);
|
||||
internet.Install(backbone);
|
||||
#
|
||||
# Assign IPv4 addresses to the device drivers(actually to the associated
|
||||
# IPv4 interfaces) we just created.
|
||||
@@ -223,24 +223,24 @@ def main(argv):
|
||||
#
|
||||
# Create another ad hoc network and devices
|
||||
#
|
||||
ssid = ns3.Ssid ('wifi-infra' + str(i))
|
||||
wifiInfra = ns3.WifiHelper.Default ()
|
||||
wifiPhy.SetChannel (wifiChannel.Create ())
|
||||
wifiInfra.SetRemoteStationManager ('ns3::ArfWifiManager')
|
||||
macInfra = ns3.NqosWifiMacHelper.Default ();
|
||||
macInfra.SetType ("ns3::NqstaWifiMac",
|
||||
"Ssid", ns3.SsidValue (ssid),
|
||||
"ActiveProbing", ns3.BooleanValue (False))
|
||||
ssid = ns3.Ssid('wifi-infra' + str(i))
|
||||
wifiInfra = ns3.WifiHelper.Default()
|
||||
wifiPhy.SetChannel(wifiChannel.Create())
|
||||
wifiInfra.SetRemoteStationManager('ns3::ArfWifiManager')
|
||||
macInfra = ns3.NqosWifiMacHelper.Default();
|
||||
macInfra.SetType("ns3::NqstaWifiMac",
|
||||
"Ssid", ns3.SsidValue(ssid),
|
||||
"ActiveProbing", ns3.BooleanValue(False))
|
||||
|
||||
# setup stas
|
||||
staDevices = wifiInfra.Install (wifiPhy, macInfra, stas)
|
||||
staDevices = wifiInfra.Install(wifiPhy, macInfra, stas)
|
||||
# setup ap.
|
||||
macInfra.SetType ("ns3::NqapWifiMac", "Ssid", ns3.SsidValue (ssid),
|
||||
"BeaconGeneration", ns3.BooleanValue (True),
|
||||
"BeaconInterval", ns3.TimeValue (ns3.Seconds (2.5)))
|
||||
apDevices = wifiInfra.Install (wifiPhy, macInfra, backbone.Get (i))
|
||||
macInfra.SetType("ns3::NqapWifiMac", "Ssid", ns3.SsidValue(ssid),
|
||||
"BeaconGeneration", ns3.BooleanValue(True),
|
||||
"BeaconInterval", ns3.TimeValue(ns3.Seconds(2.5)))
|
||||
apDevices = wifiInfra.Install(wifiPhy, macInfra, backbone.Get(i))
|
||||
# Collect all of these new devices
|
||||
infraDevices = ns3.NetDeviceContainer (apDevices, staDevices)
|
||||
infraDevices = ns3.NetDeviceContainer(apDevices, staDevices)
|
||||
|
||||
# Add the IPv4 protocol stack to the nodes in our container
|
||||
#
|
||||
@@ -284,7 +284,7 @@ def main(argv):
|
||||
|
||||
# Let's make sure that the user does not define too few LAN nodes
|
||||
# to make this example work. We need lanNodes >= 5
|
||||
assert (lanNodes >= 5)
|
||||
assert(lanNodes >= 5)
|
||||
appSource = ns3.NodeList.GetNode(11)
|
||||
appSink = ns3.NodeList.GetNode(13)
|
||||
remoteAddr = ns3.Ipv4Address("172.16.0.5")
|
||||
|
||||
@@ -31,74 +31,74 @@ import ns3;
|
||||
|
||||
def main(argv):
|
||||
|
||||
cmd = ns3.CommandLine ();
|
||||
cmd = ns3.CommandLine();
|
||||
|
||||
cmd.Parse (argv);
|
||||
cmd.Parse(argv);
|
||||
|
||||
# Create nodes
|
||||
print "Create nodes"
|
||||
n0 = ns3.Node ();
|
||||
r = ns3.Node ();
|
||||
n1 = ns3.Node ();
|
||||
# Create nodes
|
||||
print "Create nodes"
|
||||
n0 = ns3.Node();
|
||||
r = ns3.Node();
|
||||
n1 = ns3.Node();
|
||||
|
||||
net1 = ns3.NodeContainer ();
|
||||
net1.Add (n0);
|
||||
net1.Add (r);
|
||||
net2 = ns3.NodeContainer ();
|
||||
net2.Add (r);
|
||||
net2.Add (n1);
|
||||
all = ns3.NodeContainer ();
|
||||
all.Add (n0);
|
||||
all.Add (r);
|
||||
all.Add (n1);
|
||||
net1 = ns3.NodeContainer();
|
||||
net1.Add(n0);
|
||||
net1.Add(r);
|
||||
net2 = ns3.NodeContainer();
|
||||
net2.Add(r);
|
||||
net2.Add(n1);
|
||||
all = ns3.NodeContainer();
|
||||
all.Add(n0);
|
||||
all.Add(r);
|
||||
all.Add(n1);
|
||||
|
||||
# Create IPv6 Internet Stack
|
||||
internetv6 = ns3.InternetStackHelper ();
|
||||
internetv6.Install (all);
|
||||
# Create IPv6 Internet Stack
|
||||
internetv6 = ns3.InternetStackHelper();
|
||||
internetv6.Install(all);
|
||||
|
||||
# Create channels
|
||||
csma = ns3.CsmaHelper ();
|
||||
csma.SetChannelAttribute ("DataRate", ns3.DataRateValue (ns3.DataRate (5000000)));
|
||||
csma.SetChannelAttribute ("Delay", ns3.TimeValue (ns3.MilliSeconds (2)));
|
||||
d1 = csma.Install (net1);
|
||||
d2 = csma.Install (net2);
|
||||
# Create channels
|
||||
csma = ns3.CsmaHelper();
|
||||
csma.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(5000000)));
|
||||
csma.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(2)));
|
||||
d1 = csma.Install(net1);
|
||||
d2 = csma.Install(net2);
|
||||
|
||||
# Create networks and assign IPv6 Addresses
|
||||
print "Addressing"
|
||||
ipv6 = ns3.Ipv6AddressHelper ();
|
||||
ipv6.NewNetwork (ns3.Ipv6Address ("2001:1::"), ns3.Ipv6Prefix (64));
|
||||
i1 = ipv6.Assign (d1);
|
||||
i1.SetRouter (1, True);
|
||||
ipv6.NewNetwork (ns3.Ipv6Address ("2001:2::"), ns3.Ipv6Prefix (64));
|
||||
i2 = ipv6.Assign (d2);
|
||||
i2.SetRouter (0, True);
|
||||
# Create networks and assign IPv6 Addresses
|
||||
print "Addressing"
|
||||
ipv6 = ns3.Ipv6AddressHelper();
|
||||
ipv6.NewNetwork(ns3.Ipv6Address("2001:1::"), ns3.Ipv6Prefix(64));
|
||||
i1 = ipv6.Assign(d1);
|
||||
i1.SetRouter(1, True);
|
||||
ipv6.NewNetwork(ns3.Ipv6Address("2001:2::"), ns3.Ipv6Prefix(64));
|
||||
i2 = ipv6.Assign(d2);
|
||||
i2.SetRouter(0, True);
|
||||
|
||||
# Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r
|
||||
print "Application"
|
||||
packetSize = 1024;
|
||||
maxPacketCount = 5;
|
||||
interPacketInterval = ns3.Seconds (1.);
|
||||
ping6 = ns3.Ping6Helper ();
|
||||
# Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r
|
||||
print "Application"
|
||||
packetSize = 1024;
|
||||
maxPacketCount = 5;
|
||||
interPacketInterval = ns3.Seconds(1.);
|
||||
ping6 = ns3.Ping6Helper();
|
||||
|
||||
ping6.SetLocal (i1.GetAddress (0, 1));
|
||||
ping6.SetRemote (i2.GetAddress (1, 1));
|
||||
ping6.SetLocal(i1.GetAddress(0, 1));
|
||||
ping6.SetRemote(i2.GetAddress(1, 1));
|
||||
|
||||
ping6.SetAttribute ("MaxPackets", ns3.UintegerValue (maxPacketCount));
|
||||
ping6.SetAttribute ("Interval", ns3.TimeValue (interPacketInterval));
|
||||
ping6.SetAttribute ("PacketSize", ns3.UintegerValue (packetSize));
|
||||
ping6.SetAttribute("MaxPackets", ns3.UintegerValue(maxPacketCount));
|
||||
ping6.SetAttribute("Interval", ns3.TimeValue(interPacketInterval));
|
||||
ping6.SetAttribute("PacketSize", ns3.UintegerValue(packetSize));
|
||||
|
||||
apps = ping6.Install (ns3.NodeContainer (net1.Get (0)));
|
||||
apps.Start (ns3.Seconds (2.0));
|
||||
apps.Stop (ns3.Seconds (20.0));
|
||||
apps = ping6.Install(ns3.NodeContainer(net1.Get(0)));
|
||||
apps.Start(ns3.Seconds(2.0));
|
||||
apps.Stop(ns3.Seconds(20.0));
|
||||
|
||||
print "Tracing"
|
||||
ascii = ns3.ofstream ("simple-routing-ping6.tr");
|
||||
ns3.CsmaHelper.EnableAsciiAll (ascii);
|
||||
ns3.CsmaHelper.EnablePcapAll ("simple-routing-ping6", True);
|
||||
print "Tracing"
|
||||
ascii = ns3.ofstream("simple-routing-ping6.tr");
|
||||
ns3.CsmaHelper.EnableAsciiAll(ascii);
|
||||
ns3.CsmaHelper.EnablePcapAll("simple-routing-ping6", True);
|
||||
|
||||
# Run Simulation
|
||||
ns3.Simulator.Run ();
|
||||
ns3.Simulator.Destroy ();
|
||||
# Run Simulation
|
||||
ns3.Simulator.Run();
|
||||
ns3.Simulator.Destroy();
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
@@ -29,30 +29,30 @@ import ns3
|
||||
# std::cout << " TX to=" << address << " p: " << *p << std::endl;
|
||||
# }
|
||||
# void
|
||||
# DevRxTrace (std::string context, Ptr<const Packet> p, Mac48Address address)
|
||||
# DevRxTrace(std::string context, Ptr<const Packet> p, Mac48Address address)
|
||||
# {
|
||||
# std::cout << " RX from=" << address << " p: " << *p << std::endl;
|
||||
# }
|
||||
# void
|
||||
# PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
|
||||
# PhyRxOkTrace(std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
|
||||
# {
|
||||
# std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet << std::endl;
|
||||
# }
|
||||
# void
|
||||
# PhyRxErrorTrace (std::string context, Ptr<const Packet> packet, double snr)
|
||||
# PhyRxErrorTrace(std::string context, Ptr<const Packet> packet, double snr)
|
||||
# {
|
||||
# std::cout << "PHYRXERROR snr=" << snr << " " << *packet << std::endl;
|
||||
# }
|
||||
# void
|
||||
# PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
|
||||
# PhyTxTrace(std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
|
||||
# {
|
||||
# std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl;
|
||||
# }
|
||||
# void
|
||||
# PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy::State state)
|
||||
# PhyStateTrace(std::string context, Time start, Time duration, enum WifiPhy::State state)
|
||||
# {
|
||||
# std::cout << " state=";
|
||||
# switch (state) {
|
||||
# switch(state) {
|
||||
# case WifiPhy::TX:
|
||||
# std::cout << "tx ";
|
||||
# break;
|
||||
@@ -79,7 +79,7 @@ def GetPosition(node):
|
||||
return mobility.GetPosition()
|
||||
|
||||
def AdvancePosition(node):
|
||||
pos = GetPosition (node);
|
||||
pos = GetPosition(node);
|
||||
pos.x += 5.0
|
||||
if pos.x >= 210.0:
|
||||
return
|
||||
@@ -88,12 +88,12 @@ def AdvancePosition(node):
|
||||
|
||||
|
||||
def main(argv):
|
||||
ns3.Packet.EnablePrinting ();
|
||||
ns3.Packet.EnablePrinting();
|
||||
|
||||
# enable rts cts all the time.
|
||||
ns3.Config.SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", ns3.StringValue("0"))
|
||||
# disable fragmentation
|
||||
ns3.Config.SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold", ns3.StringValue ("2200"))
|
||||
ns3.Config.SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold", ns3.StringValue("2200"))
|
||||
|
||||
wifi = ns3.WifiHelper.Default()
|
||||
mobility = ns3.MobilityHelper()
|
||||
@@ -115,7 +115,7 @@ def main(argv):
|
||||
|
||||
ssid = ns3.Ssid("wifi-default")
|
||||
wifi.SetRemoteStationManager("ns3::ArfWifiManager")
|
||||
wifiMac = ns3.NqosWifiMacHelper.Default ()
|
||||
wifiMac = ns3.NqosWifiMacHelper.Default()
|
||||
|
||||
# setup stas.
|
||||
wifiMac.SetType("ns3::NqstaWifiMac",
|
||||
@@ -149,12 +149,12 @@ def main(argv):
|
||||
|
||||
ns3.Simulator.Stop(ns3.Seconds(44.0))
|
||||
|
||||
# Config::Connect ("/NodeList/*/DeviceList/*/Tx", MakeCallback (&DevTxTrace));
|
||||
# Config::Connect ("/NodeList/*/DeviceList/*/Rx", MakeCallback (&DevRxTrace));
|
||||
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/RxOk", MakeCallback (&PhyRxOkTrace));
|
||||
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/RxError", MakeCallback (&PhyRxErrorTrace));
|
||||
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/Tx", MakeCallback (&PhyTxTrace));
|
||||
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/State", MakeCallback (&PhyStateTrace));
|
||||
# Config::Connect("/NodeList/*/DeviceList/*/Tx", MakeCallback(&DevTxTrace));
|
||||
# Config::Connect("/NodeList/*/DeviceList/*/Rx", MakeCallback(&DevRxTrace));
|
||||
# Config::Connect("/NodeList/*/DeviceList/*/Phy/RxOk", MakeCallback(&PhyRxOkTrace));
|
||||
# Config::Connect("/NodeList/*/DeviceList/*/Phy/RxError", MakeCallback(&PhyRxErrorTrace));
|
||||
# Config::Connect("/NodeList/*/DeviceList/*/Phy/Tx", MakeCallback(&PhyTxTrace));
|
||||
# Config::Connect("/NodeList/*/DeviceList/*/Phy/State", MakeCallback(&PhyStateTrace));
|
||||
|
||||
ascii = ns3.ofstream("wifi-ap.tr")
|
||||
ns3.YansWifiPhyHelper.EnableAsciiAll(ascii)
|
||||
|
||||
Reference in New Issue
Block a user