コード例 #1
0
def main(argv):
    #
    # We are interacting with the outside, real, world.  This means we have to
    # interact in real-time and therefore we have to use the real-time simulator
    # and take the time to calculate checksums.
    #
    ns3.GlobalValue.Bind("SimulatorImplementationType",
                         ns3.StringValue("ns3::RealtimeSimulatorImpl"))
    ns3.GlobalValue.Bind("ChecksumEnabled", ns3.BooleanValue("true"))

    #
    # Create two ghost nodes.  The first will represent the virtual machine host
    # on the left side of the network; and the second will represent the VM on
    # the right side.
    #
    nodes = ns3.NodeContainer()
    nodes.Create(2)

    #
    # Use a CsmaHelper to get a CSMA channel created, and the needed net
    # devices installed on both of the nodes.  The data rate and delay for the
    # channel can be set through the command-line parser.
    #
    csma = ns3.CsmaHelper()
    devices = csma.Install(nodes)

    #
    # Use the TapBridgeHelper to connect to the pre-configured tap devices for
    # the left side.  We go with "UseLocal" mode since the wifi devices do not
    # support promiscuous mode (because of their natures0.  This is a special
    # case mode that allows us to extend a linux bridge into ns-3 IFF we will
    # only see traffic from one other device on that bridge.  That is the case
    # for this configuration.
    #
    tapBridge = ns3.TapBridgeHelper()
    tapBridge.SetAttribute("Mode", ns3.StringValue("UseLocal"))
    tapBridge.SetAttribute("DeviceName", ns3.StringValue("tap-left"))
    tapBridge.Install(nodes.Get(0), devices.Get(0))

    #
    # Connect the right side tap to the right side wifi device on the right-side
    # ghost node.
    #
    tapBridge.SetAttribute("DeviceName", ns3.StringValue("tap-right"))
    tapBridge.Install(nodes.Get(1), devices.Get(1))

    #
    # Run the simulation for ten minutes to give the user time to play around
    #
    ns3.Simulator.Stop(ns3.Seconds(600))
    ns3.Simulator.Run(signal_check_frequency=-1)
    ns3.Simulator.Destroy()
    return 0
コード例 #2
0
ファイル: NS3Config.py プロジェクト: Sikkandar-Sha/imalse
    def _add_onoff_app(self, start_time, end_time, local, remote, on_time,
                       off_time, data_rate, sport, dport):
        """add one ns3 onoff application to the network
        """
        # ignore the network prefix length if there is
        if '/' in remote: remote = remote.rsplit('/')[0]
        if '/' in local: local = local.rsplit('/')[0]

        ### Install OnOff Application ###
        socketType = "ns3::UdpSocketFactory"
        # socketType = "ns3::TcpSocketFactory"
        helper = ns3.OnOffHelper(socketType,
                                 ns3.InetSocketAddress(remote, dport))

        helper.SetAttribute("StartTime",
                            ns3.TimeValue(ns3.Time(str(start_time) + 's')))
        helper.SetAttribute("StopTime",
                            ns3.TimeValue(ns3.Time(str(end_time) + 's')))

        # helper.SetAttribute("Remote", ns3.AddressValue(ns3.Ipv4Address(remote)))
        local_inet = ns3.InetSocketAddress(local, sport)
        helper.SetAttribute("Local", ns3.AddressValue(local_inet))

        helper.SetAttribute("DataRate",
                            ns3.StringValue(str(data_rate) + 'b/s'))
        helper.SetAttribute("OnTime",
                            ns3.RandomVariableValue(on_time.to_ns3()))
        helper.SetAttribute("OffTime",
                            ns3.RandomVariableValue(off_time.to_ns3()))

        print('local, ', local)
        local_node = self.net.search_node(local)
        helper.Install(local_node)

        ### Install Sink Application ####
        sinkLocalAddress = ns3.Address(
            ns3.InetSocketAddress(ns3.Ipv4Address.GetAny(), dport))
        sinkHelper = ns3.PacketSinkHelper(socketType, sinkLocalAddress)
        helper.SetAttribute("StartTime",
                            ns3.TimeValue(ns3.Time(str(start_time) + 's')))
        helper.SetAttribute("StopTime",
                            ns3.TimeValue(ns3.Time(str(end_time) + 's')))
        remote_node = self.net.search_node(remote)
        print('remote, ', remote)
        sinkHelper.Install(remote_node)

        print("""add an onoff application with
                start_time: %f
                end_time: %f
                local: %s,
                remote: %s,
                on_time: %s,
                off_time: %s""" %
              (start_time, end_time, local, remote, on_time, off_time))
コード例 #3
0
def main(argv):
    #
    # Allow the user to override any of the defaults and the above Bind() at
    # run-time, via command-line arguments
    #
    cmd = ns3.CommandLine()
    cmd.Parse(argv)

    #
    # But since this is a realtime script, don't allow the user to mess with
    # that.
    #
    ns3.GlobalValue.Bind("SimulatorImplementationType",
                         ns3.StringValue("ns3::RealtimeSimulatorImpl"))

    #
    # Explicitly create the nodes required by the topology (shown above).
    #
    print "Create nodes."
    n = ns3.NodeContainer()
    n.Create(4)

    internet = ns3.InternetStackHelper()
    internet.Install(n)

    #
    # Explicitly create the channels required by the topology (shown above).
    #
    print("Create channels.")
    csma = ns3.CsmaHelper()
    csma.SetChannelAttribute("DataRate",
                             ns3.DataRateValue(ns3.DataRate(5000000)))
    csma.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(2)))
    csma.SetDeviceAttribute("Mtu", ns3.UintegerValue(1400))
    d = csma.Install(n)

    #
    # We've got the "hardware" in place.  Now we need to add IP addresses.
    #
    print("Assign IP Addresses.")
    ipv4 = ns3.Ipv4AddressHelper()
    ipv4.SetBase(ns3.Ipv4Address("10.1.1.0"), ns3.Ipv4Mask("255.255.255.0"))
    i = ipv4.Assign(d)

    print("Create Applications.")

    #
    # Create a UdpEchoServer application on node one.
    #
    port = 9  # well-known echo port number
    server = ns3.UdpEchoServerHelper(port)
    apps = server.Install(n.Get(1))
    apps.Start(ns3.Seconds(1.0))
    apps.Stop(ns3.Seconds(10.0))

    #
    # Create a UdpEchoClient application to send UDP datagrams from node zero to
    # node one.
    #
    packetSize = 1024
    maxPacketCount = 500
    interPacketInterval = ns3.Seconds(0.01)
    client = ns3.UdpEchoClientHelper(i.GetAddress(1), port)
    client.SetAttribute("MaxPackets", ns3.UintegerValue(maxPacketCount))
    client.SetAttribute("Interval", ns3.TimeValue(interPacketInterval))
    client.SetAttribute("PacketSize", ns3.UintegerValue(packetSize))
    apps = client.Install(n.Get(0))
    apps.Start(ns3.Seconds(2.0))
    apps.Stop(ns3.Seconds(10.0))

    ascii = ns3.AsciiTraceHelper()
    csma.EnableAsciiAll(ascii.CreateFileStream("realtime-udp-echo.tr"))
    csma.EnablePcapAll("realtime-udp-echo", False)

    #
    # Now, do the actual simulation.
    #
    print("Run Simulation.")
    ns3.Simulator.Run()
    ns3.Simulator.Destroy()
    print("Done.")
コード例 #4
0
ファイル: exe04.py プロジェクト: krllus/networks-ns3
wifiChannelHelper = ns3.YansWifiChannelHelper()
wifiChannel = wifiChannelHelper.Default()

wifiPhyHelper = ns3.YansWifiPhyHelper()
wifiPhy = wifiPhyHelper.Default()
wifiPhy.SetChannel(wifiChannel.Create())

nodes = ns.network.NodeContainer()
nodes.Create(2)

mac = ns3.NqosWifiMacHelper.Default()
mac.SetType("ns3::AdhocWifiMac")
 
wifiHelper.SetRemoteStationManager(
	"ns3::ConstantRateWifiManager", 
	"DataMode", ns3.StringValue("DsssRate1Mbps"), 
	"ControlMode", ns3.StringValue("DsssRate1Mbps"))
devices = wifiHelper.Install(wifiPhy,mac,nodes)

olsr = ns3.OlsrHelper()
    
#Add the IPv4 protocol stack to the nodes in our container
internet=ns3.InternetStackHelper()
internet.SetRoutingHelper (olsr)
 
internet.Install (nodes)
ipAddrss= ns3.Ipv4AddressHelper()
ipAddrss.SetBase(
	ns3.Ipv4Address("192.168.0.0"), 
	ns3.Ipv4Mask("255.255.255.0"));
ipContainer = ipAddrss.Assign(devices);
コード例 #5
0
def main(argv):
    #
    #  First, we declare and initialize a few local variables that control some
    #  simulation parameters.
    #
    backboneNodes = 10
    infraNodes = 5
    lanNodes = 5
    stopTime = 10

    #
    #  Simulation defaults are typically set next, before command line
    #  arguments are parsed.
    #
    ns3.Config.SetDefault("ns3::OnOffApplication::PacketSize",
                          ns3.StringValue("210"))
    ns3.Config.SetDefault("ns3::OnOffApplication::DataRate",
                          ns3.StringValue("448kb/s"))

    #
    #  For convenience, we add the local variables to the command line argument
    #  system so that they can be overridden with flags such as
    #  "--backboneNodes=20"
    #
    cmd = ns3.CommandLine()
    #cmd.AddValue("backboneNodes", "number of backbone nodes", backboneNodes)
    #cmd.AddValue("infraNodes", "number of leaf nodes", infraNodes)
    #cmd.AddValue("lanNodes", "number of LAN nodes", lanNodes)
    #cmd.AddValue("stopTime", "simulation stop time(seconds)", stopTime)

    #
    #  The system global variables and the local values added to the argument
    #  system can be overridden by command line arguments by using this call.
    #
    cmd.Parse(argv)

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /
    #                                                                        #
    #  Construct the backbone                                                #
    #                                                                        #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /

    #
    #  Create a container to manage the nodes of the adhoc(backbone) network.
    #  Later we'll create the rest of the nodes we'll need.
    #
    backbone = ns3.NodeContainer()
    backbone.Create(backboneNodes)
    #
    #  Create the backbone wifi net devices and install them into the nodes in
    #  our container
    #
    wifi = ns3.WifiHelper()
    mac = ns3.NqosWifiMacHelper.Default()
    mac.SetType("ns3::AdhocWifiMac")
    wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",
                                 ns3.StringValue("OfdmRate54Mbps"))
    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
    #
    print "Enabling OLSR routing on all backbone nodes"
    internet = ns3.InternetStackHelper()
    olsr = ns3.OlsrHelper()
    internet.SetRoutingHelper(olsr)
    internet.Install(backbone)
    # re-initialize for non-olsr routing.
    internet.Reset()
    #
    #  Assign IPv4 addresses to the device drivers(actually to the associated
    #  IPv4 interfaces) we just created.
    #
    ipAddrs = ns3.Ipv4AddressHelper()
    ipAddrs.SetBase(ns3.Ipv4Address("192.168.0.0"),
                    ns3.Ipv4Mask("255.255.255.0"))
    ipAddrs.Assign(backboneDevices)

    #
    #  The ad-hoc network nodes need a mobility model so we aggregate one to
    #  each of the nodes we just finished building.
    #
    mobility = ns3.MobilityHelper()
    positionAlloc = ns3.ListPositionAllocator()
    x = 0.0
    for i in range(backboneNodes):
        positionAlloc.Add(ns3.Vector(x, 0.0, 0.0))
        x += 5.0
    mobility.SetPositionAllocator(positionAlloc)
    mobility.SetMobilityModel(
        "ns3::RandomDirection2dMobilityModel", "Bounds",
        ns3.RectangleValue(ns3.Rectangle(0, 1000, 0, 1000)), "Speed",
        ns3.RandomVariableValue(ns3.ConstantVariable(2000)), "Pause",
        ns3.RandomVariableValue(ns3.ConstantVariable(0.2)))
    mobility.Install(backbone)

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /
    #                                                                        #
    #  Construct the LANs                                                    #
    #                                                                        #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /

    #  Reset the address base-- all of the CSMA networks will be in
    #  the "172.16 address space
    ipAddrs.SetBase(ns3.Ipv4Address("172.16.0.0"),
                    ns3.Ipv4Mask("255.255.255.0"))

    for i in range(backboneNodes):
        print "Configuring local area network for backbone node ", i
        #
        #  Create a container to manage the nodes of the LAN.  We need
        #  two containers here; one with all of the new nodes, and one
        #  with all of the nodes including new and existing nodes
        #
        newLanNodes = ns3.NodeContainer()
        newLanNodes.Create(lanNodes - 1)
        #  Now, create the container with all nodes on this link
        lan = ns3.NodeContainer(ns3.NodeContainer(backbone.Get(i)),
                                newLanNodes)
        #
        #  Create the CSMA net devices and install them into the nodes in our
        #  collection.
        #
        csma = ns3.CsmaHelper()
        csma.SetChannelAttribute("DataRate",
                                 ns3.DataRateValue(ns3.DataRate(5000000)))
        csma.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(2)))
        lanDevices = csma.Install(lan)
        #
        #  Add the IPv4 protocol stack to the new LAN nodes
        #
        internet.Install(newLanNodes)
        #
        #  Assign IPv4 addresses to the device drivers(actually to the
        #  associated IPv4 interfaces) we just created.
        #
        ipAddrs.Assign(lanDevices)
        #
        #  Assign a new network prefix for the next LAN, according to the
        #  network mask initialized above
        #
        ipAddrs.NewNetwork()

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /
    #                                                                        #
    #  Construct the mobile networks                                         #
    #                                                                        #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /

    #  Reset the address base-- all of the 802.11 networks will be in
    #  the "10.0" address space
    ipAddrs.SetBase(ns3.Ipv4Address("10.0.0.0"), ns3.Ipv4Mask("255.255.255.0"))

    for i in range(backboneNodes):
        print "Configuring wireless network for backbone node ", i
        #
        #  Create a container to manage the nodes of the LAN.  We need
        #  two containers here; one with all of the new nodes, and one
        #  with all of the nodes including new and existing nodes
        #
        stas = ns3.NodeContainer()
        stas.Create(infraNodes - 1)
        #  Now, create the container with all nodes on this link
        infra = ns3.NodeContainer(ns3.NodeContainer(backbone.Get(i)), stas)
        #
        #  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))

        # setup 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))
        # Collect all of these new devices
        infraDevices = ns3.NetDeviceContainer(apDevices, staDevices)

        #  Add the IPv4 protocol stack to the nodes in our container
        #
        internet.Install(stas)
        #
        #  Assign IPv4 addresses to the device drivers(actually to the associated
        #  IPv4 interfaces) we just created.
        #
        ipAddrs.Assign(infraDevices)
        #
        #  Assign a new network prefix for each mobile network, according to
        #  the network mask initialized above
        #
        ipAddrs.NewNetwork()
        #
        #  The new wireless nodes need a mobility model so we aggregate one
        #  to each of the nodes we just finished building.
        #
        subnetAlloc = ns3.ListPositionAllocator()
        for j in range(infra.GetN()):
            subnetAlloc.Add(ns3.Vector(0.0, j, 0.0))

        mobility.PushReferenceMobilityModel(backbone.Get(i))
        mobility.SetPositionAllocator(subnetAlloc)
        mobility.SetMobilityModel(
            "ns3::RandomDirection2dMobilityModel", "Bounds",
            ns3.RectangleValue(ns3.Rectangle(-25, 25, -25, 25)), "Speed",
            ns3.RandomVariableValue(ns3.ConstantVariable(30)), "Pause",
            ns3.RandomVariableValue(ns3.ConstantVariable(0.4)))
        mobility.Install(infra)

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /
    #                                                                        #
    #  Application configuration                                             #
    #                                                                        #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /

    #  Create the OnOff application to send UDP datagrams of size
    #  210 bytes at a rate of 448 Kb/s, between two nodes
    print "Create Applications."
    port = 9  #  Discard port(RFC 863)

    #  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)
    appSource = ns3.NodeList.GetNode(11)
    appSink = ns3.NodeList.GetNode(13)
    remoteAddr = ns3.Ipv4Address("172.16.0.5")

    onoff = ns3.OnOffHelper(
        "ns3::UdpSocketFactory",
        ns3.Address(ns3.InetSocketAddress(remoteAddr, port)))
    onoff.SetAttribute("OnTime",
                       ns3.RandomVariableValue(ns3.ConstantVariable(1)))
    onoff.SetAttribute("OffTime",
                       ns3.RandomVariableValue(ns3.ConstantVariable(0)))
    apps = onoff.Install(ns3.NodeContainer(appSource))
    apps.Start(ns3.Seconds(3.0))
    apps.Stop(ns3.Seconds(20.0))

    #  Create a packet sink to receive these packets
    sink = ns3.PacketSinkHelper(
        "ns3::UdpSocketFactory",
        ns3.InetSocketAddress(ns3.Ipv4Address.GetAny(), port))
    apps = sink.Install(ns3.NodeContainer(appSink))
    apps.Start(ns3.Seconds(3.0))

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /
    #                                                                        #
    #  Tracing configuration                                                 #
    #                                                                        #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # /

    print "Configure Tracing."
    #
    #  Let's set up some ns-2-like ascii traces, using another helper class
    #
    #std.ofstream ascii
    #ascii = ns3.AsciiTraceHelper();
    #stream = ascii.CreateFileStream("mixed-wireless.tr");
    #wifiPhy.EnableAsciiAll(stream);
    #csma.EnableAsciiAll(stream);
    print "(tracing not done for Python)"
    #  Look at nodes 11, 13 only
    # WifiHelper.EnableAscii(ascii, 11, 0);
    # WifiHelper.EnableAscii(ascii, 13, 0);

    #  Let's do a pcap trace on the backbone devices
    wifiPhy.EnablePcap("mixed-wireless", backboneDevices)
    #  Let's additionally trace the application Sink, ifIndex 0
    csma = ns3.CsmaHelper()
    csma.EnablePcapAll("mixed-wireless", False)

    #   #ifdef ENABLE_FOR_TRACING_EXAMPLE
    #     Config.Connect("/NodeList/*/$MobilityModel/CourseChange",
    #       MakeCallback(&CourseChangeCallback))
    #   #endif

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #                                                                        #
    #  Run simulation                                                        #
    #                                                                        #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    print "Run Simulation."
    ns3.Simulator.Stop(ns3.Seconds(stopTime))
    ns3.Simulator.Run()
    ns3.Simulator.Destroy()
コード例 #6
0
ファイル: uan-thorp-tap.py プロジェクト: rubiruchi/SDUWN
def runMain(argc, argv):

    #ns.core.LogComponentEnable("UanChannel", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("UanHelper", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("UanNetDevice", ns.core.LOG_ALL)
    ns.core.LogComponentEnable("UanPhyGen", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("UanPropModelThorp", ns.core.LOG_ALL)
    #ns.core.LogComponentEnable("OnOffApplication", ns.core.LOG_ALL)
    ns.core.LogComponentEnableAll(ns.core.LOG_PREFIX_NODE)
    ns.core.LogComponentEnableAll(ns.core.LOG_PREFIX_TIME)

    ns3.GlobalValue.Bind("SimulatorImplementationType",
                         ns3.StringValue("ns3::RealtimeSimulatorImpl"))
    ns3.GlobalValue.Bind("ChecksumEnabled", ns3.BooleanValue(True))

    nNodes = 100
    sPreadCoef = 1.5
    rxThresh = 5
    txPower = 140
    windspeed = 4.5
    shipcontri = 0.5
    ''' channel module configurations begin '''
    nodes = ns.network.NodeContainer()
    nodes.Create(nNodes)

    uan = ns.uan.UanHelper()
    chan = ns.uan.UanChannel()

    # noise configuration
    noise_object = ns.uan.UanNoiseModelDefault()
    noise_ptr = noise_object.GetObject(ns.uan.UanNoiseModelDefault.GetTypeId())
    #noise.SetWind(windspeed)
    #noise.SetShipping(shipcontri)
    #noise.Wind = ns.core.DoubleValue(windspeed)
    #noise.Shipping = ns.core.DoubleValue(shipcontri)
    #noisePtr = ns.core.PointerValue(noise)
    chan.SetNoiseModel(noise_ptr)
    #chan.SetAttribute("NoiseModel", noise_ptr)
    # propagation model configuration
    prop_object = ns.uan.UanPropModelThorp()
    prop_ptr = prop_object.GetObject(ns.uan.UanPropModelThorp.GetTypeId())
    #prop.SpreadCoef = ns.core.DoubleValue(sPreadCoef)
    #prop.SetSpreadCoef(sPreadCoef)
    #propPtr = ns.core.PointerValue(prop)
    chan.SetPropagationModel(prop_ptr)
    #chan.SetAttribute("PropagationModel", prop_ptr)

    # modulation mode configuration
    mode = ns.uan.UanTxMode()
    mode = ns.uan.UanTxModeFactory.CreateMode(
        ns.uan.UanTxMode.FSK,  # modulation type
        1624,  # data rate in BPS: 1152B/5.67s
        1624,
        24000,  # cetner frequency in Hz
        6000,  # bandwidth in Hz
        2,  # modulation constellation size, 2 for BPSK, 4 for QPSK
        "Default mode")

    myModes = ns.uan.UanModesList()
    myModes.AppendMode(mode)

    # physical layer channel configuration
    perModel = "ns3::UanPhyPerGenDefault"
    sinrModel = "ns3::UanPhyCalcSinrDefault"
    obf = ns.core.ObjectFactory()
    obf.SetTypeId(perModel)
    per = obf.Create()  # watch
    obf.SetTypeId(sinrModel)
    sinr = obf.Create()

    # watch
    uan.SetPhy("ns3::UanPhyGen", "PerModel", ns.core.PointerValue(per),
               "SinrModel", ns.core.PointerValue(sinr), "SupportedModes",
               ns.uan.UanModesListValue(myModes), "RxThreshold",
               ns.core.DoubleValue(rxThresh), "TxPower",
               ns.core.DoubleValue(txPower))

    # configure MAC module for uan channel
    uan.SetMac("ns3::UanMacAloha")

    # install wireless devices onto ghost nodes

    #devices = ns.network.NetDeviceContainer(uan.Install(nodes, chan))
    devices = uan.Install(nodes, chan)
    #devices = uan.Install(nodes)
    #mobility
    mobility = ns.mobility.MobilityHelper()
    positionAlloc = ns.mobility.ListPositionAllocator()

    mDist = 50

    for i in range(0, nNodes):
        positionAlloc.Add(ns.core.Vector((i - nNodes / 2) * mDist, 0.0, -10.0))
    mobility.SetPositionAllocator(positionAlloc)
    mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel")
    mobility.Install(nodes)

    mobility.SetPositionAllocator(positionAlloc)
    mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel")
    mobility.Install(nodes)
    ''' setup tap bridges from vmuan-2km.cc '''
    tapBridge = ns3.TapBridgeHelper()
    tapBridge.SetAttribute("Mode", ns.core.StringValue("UseLocal"))
    tapBridge.SetAttribute("DeviceName", ns3.StringValue("tap-vNode1"))
    tapBridge.Install(nodes.Get(0), devices.Get(0))

    #tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-vNode2"));
    #tapBridge.Install (nodes.Get (1), devices.Get (1));

    #tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-vNode3"));
    #tapBridge.Install (nodes.Get (2), devices.Get (2));

    #tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-vNode4"));
    #tapBridge.Install (nodes.Get (3), devices.Get (3));

    #tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-vNode5"));
    #tapBridge.Install (nodes.Get (4), devices.Get (4));

    #tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-vNode6"));
    #tapBridge.Install (nodes.Get (5), devices.Get (5));
    '''
	pktskth=ns.network.PacketSocketHelper()
	pktskth.Install(nodes)
	appsocket=ns.network.PacketSocketAddress()

	appsocket.SetSingleDevice(devices.Get(nNodes-1).GetIfIndex())
	appsocket.SetPhysicalAddress(devices.Get (nNodes-1).GetAddress())
	appsocket.SetProtocol(0)
	
	app=ns.applications.OnOffHelper("ns3::PacketSocketFactory",appsocket.GetPhysicalAddress())
	app.SetAttribute("OnTime",ns.core.StringValue("ns3::ConstantRandomVariable[Constant=1]"))
	app.SetAttribute("OffTime",ns.core.StringValue("ns3::ConstantRandomVariable[Constant=0]"))
	app.SetAttribute("DataRate",ns.network.DataRateValue(ns.network.DataRate(1300)))
	app.SetAttribute("PacketSize",ns.core.UintegerValue(1000))
	apps=ns.network.ApplicationContainer(app.Install(nodes.Get(0)))

	sinkNode=nodes.Get(nNodes-1)
    #Ptr<Node> sinkNode = nodes.Get (nNodes-1);
  	psfid = ns3.TypeId.LookupByName("ns3::PacketSocketFactory")
  	sinkSocket = ns3.Socket.CreateSocket(sinkNode, psfid)
  	sinkSocket.Bind (appsocket)
  	#sinkSocket.SetRecvCallback(ns.core.MakeCallback(ReceivePacket));
	
  	apps.Start(ns.core.Seconds(0.5))
	apps.Stop(ns.core.Seconds(100.5))
	'''
    #NS_LOG_INFO ("Run Simulation.");
    #ns3.Simulator.Stop(ns.core.Seconds(100.))
    ns3.Simulator.Run()
    ns3.Simulator.Destroy()
コード例 #7
0
ファイル: wifi-ap.py プロジェクト: amirkrifa/ns-allinone-3.9
def main(argv):
    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"))

    wifi = ns3.WifiHelper.Default()
    mobility = ns3.MobilityHelper()
    stas = ns3.NodeContainer()
    ap = ns3.NodeContainer()
    #NetDeviceContainer staDevs;
    packetSocket = ns3.PacketSocketHelper()

    stas.Create(2)
    ap.Create(1)

    # give packet socket powers to nodes.
    packetSocket.Install(stas)
    packetSocket.Install(ap)

    wifiPhy = ns3.YansWifiPhyHelper.Default()
    wifiChannel = ns3.YansWifiChannelHelper.Default()
    wifiPhy.SetChannel(wifiChannel.Create())

    ssid = ns3.Ssid("wifi-default")
    wifi.SetRemoteStationManager("ns3::ArfWifiManager")
    wifiMac = ns3.NqosWifiMacHelper.Default()

    # setup stas.
    wifiMac.SetType("ns3::NqstaWifiMac", "Ssid", ns3.SsidValue(ssid),
                    "ActiveProbing", ns3.BooleanValue(False))
    staDevs = wifi.Install(wifiPhy, wifiMac, stas)
    # setup ap.
    wifiMac.SetType("ns3::NqapWifiMac", "Ssid",
                    ns3.SsidValue(ssid), "BeaconGeneration",
                    ns3.BooleanValue(True), "BeaconInterval",
                    ns3.TimeValue(ns3.Seconds(2.5)))
    wifi.Install(wifiPhy, wifiMac, ap)

    # mobility.
    mobility.Install(stas)
    mobility.Install(ap)

    ns3.Simulator.Schedule(ns3.Seconds(1.0), AdvancePosition, ap.Get(0))

    socket = ns3.PacketSocketAddress()
    socket.SetSingleDevice(staDevs.Get(0).GetIfIndex())
    socket.SetPhysicalAddress(staDevs.Get(1).GetAddress())
    socket.SetProtocol(1)

    onoff = ns3.OnOffHelper("ns3::PacketSocketFactory", ns3.Address(socket))
    onoff.SetAttribute("OnTime",
                       ns3.RandomVariableValue(ns3.ConstantVariable(42)))
    onoff.SetAttribute("OffTime",
                       ns3.RandomVariableValue(ns3.ConstantVariable(0)))

    apps = onoff.Install(ns3.NodeContainer(stas.Get(0)))
    apps.Start(ns3.Seconds(0.5))
    apps.Stop(ns3.Seconds(43.0))

    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));

    ns3.Simulator.Run()
    ns3.Simulator.Destroy()

    return 0
コード例 #8
0
def wifi_network(network_info, net_index, short_net_name, ns3_mode, nodes,
                 get_node_from_ns3node, node_member, terminal_members):
    """Configure a WiFi network (1 AP - n STAs)."""
    max_distance = get_max_distance_in_network(nodes, node_member,
                                               terminal_members)

    logging.info("Network '%s': AP-node = '%s', STA-nodes = %s" %
                 (short_net_name, node_member, terminal_members))
    logging.info("Network '%s': ns-3 mode: %s, max_distance: %d meters" %
                 (short_net_name, ns3_mode, max_distance))

    # Wifi channel
    channel = ns3.YansWifiChannelHelper.Default()
    phy = ns3.YansWifiPhyHelper.Default()
    channel = ns3.YansWifiChannelHelper.Default()
    channel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel")
    channel.AddPropagationLoss("ns3::FixedRssLossModel", "Rss",
                               ns3.DoubleValue(0))
    phy.SetChannel(channel.Create())

    address_helper = ns3.Ipv4AddressHelper()
    netaddr = "10.1.%d.0" % net_index
    address_helper.SetBase(ns3.Ipv4Address(netaddr),
                           ns3.Ipv4Mask("255.255.255.0"))

    def configure_node(wifi_helper, name):
        ns3_node = nodes[name].ns3_node
        sta_device = wifi_helper.Install(phy, mac, ns3_node)
        node = get_node_from_ns3node(ns3_node)
        add_device_to_node(node,
                           short_net_name,
                           network_info,
                           sta_device.Get(0),
                           helper=wifi_helper,
                           phy_helper=phy)
        set_wifi_timeouts(sta_device.Get(0), max_distance)
        sta_interface = address_helper.Assign(sta_device)
        address = sta_interface.GetAddress(0)
        add_interface_to_device_node(node, short_net_name, network_info,
                                     address)

    # STA devices & and interfaces
    wifi_helper = ns3.WifiHelper.Default()
    wifi_helper.SetRemoteStationManager("ns3::ConstantRateWifiManager",
                                        "DataMode", ns3.StringValue(ns3_mode),
                                        "RtsCtsThreshold",
                                        ns3.StringValue("2200"))

    mac = ns3.NqosWifiMacHelper.Default()
    ssid = ns3.Ssid("%s%d" % (short_net_name[:5], net_index))
    mac.SetType("ns3::QstaWifiMac", "Ssid", ns3.SsidValue(ssid),
                "ActiveProbing", ns3.BooleanValue(False))

    for terminal_member in terminal_members:
        configure_node(wifi_helper, terminal_member)

    # AP devices & interfaces
    wifi_helper = ns3.WifiHelper.Default()
    mac = ns3.NqosWifiMacHelper.Default()
    mac.SetType("ns3::QapWifiMac", "Ssid", ns3.SsidValue(ssid),
                "BeaconGeneration", ns3.BooleanValue(True), "BeaconInterval",
                ns3.TimeValue(ns3.Seconds(2.5)))
    configure_node(wifi_helper, node_member)
コード例 #9
0
def main(argv):
    #
    # We are interacting with the outside, real, world.  This means we have to
    # interact in real-time and therefore we have to use the real-time simulator
    # and take the time to calculate checksums.
    #
    ns3.GlobalValue.Bind("SimulatorImplementationType",
                         ns3.StringValue("ns3::RealtimeSimulatorImpl"))
    ns3.GlobalValue.Bind("ChecksumEnabled", ns3.BooleanValue("true"))

    #
    # Create two ghost nodes.  The first will represent the virtual machine host
    # on the left side of the network; and the second will represent the VM on
    # the right side.
    #
    nodes = ns3.NodeContainer()
    nodes.Create(2)

    #
    # We're going to use 802.11 A so set up a wifi helper to reflect that.
    #
    wifi = ns3.WifiHelper.Default()
    wifi.SetStandard(ns3.WIFI_PHY_STANDARD_80211a)
    wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",
                                 ns3.StringValue("wifia-54mbs"))

    #
    # No reason for pesky access points, so we'll use an ad-hoc network.
    #
    wifiMac = ns3.NqosWifiMacHelper.Default()
    wifiMac.SetType("ns3::AdhocWifiMac")

    #
    # Configure the physcial layer.
    #
    wifiChannel = ns3.YansWifiChannelHelper.Default()
    wifiPhy = ns3.YansWifiPhyHelper.Default()
    wifiPhy.SetChannel(wifiChannel.Create())

    #
    # Install the wireless devices onto our ghost nodes.
    #
    devices = wifi.Install(wifiPhy, wifiMac, nodes)

    #
    # We need location information since we are talking about wifi, so add a
    # constant position to the ghost nodes.
    #
    mobility = ns3.MobilityHelper()
    positionAlloc = ns3.ListPositionAllocator()
    positionAlloc.Add(ns3.Vector(0.0, 0.0, 0.0))
    positionAlloc.Add(ns3.Vector(5.0, 0.0, 0.0))
    mobility.SetPositionAllocator(positionAlloc)
    mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel")
    mobility.Install(nodes)

    #
    # Use the TapBridgeHelper to connect to the pre-configured tap devices for
    # the left side.  We go with "UseLocal" mode since the wifi devices do not
    # support promiscuous mode (because of their natures0.  This is a special
    # case mode that allows us to extend a linux bridge into ns-3 IFF we will
    # only see traffic from one other device on that bridge.  That is the case
    # for this configuration.
    #
    tapBridge = ns3.TapBridgeHelper()
    tapBridge.SetAttribute("Mode", ns3.StringValue("UseLocal"))
    tapBridge.SetAttribute("DeviceName", ns3.StringValue("tap-left"))
    tapBridge.Install(nodes.Get(0), devices.Get(0))

    #
    # Connect the right side tap to the right side wifi device on the right-side
    # ghost node.
    #
    tapBridge.SetAttribute("DeviceName", ns3.StringValue("tap-right"))
    tapBridge.Install(nodes.Get(1), devices.Get(1))

    #
    # Run the simulation for ten minutes to give the user time to play around
    #
    ns3.Simulator.Stop(ns3.Seconds(600))
    ns3.Simulator.Run(signal_check_frequency=-1)
    ns3.Simulator.Destroy()
    return 0
コード例 #10
0
def main(argv):

    cmd = ns3.CommandLine()
    cmd.AddValue("deviceName_emu_0", "device name", emuDevice_emu_0)
    cmd.AddValue("deviceName_emu_1", "device name", emuDevice_emu_1)
    cmd.AddValue("deviceName_emu_2", "device name", emuDevice_emu_2)
    cmd.AddValue("mode_tap_0", "Mode Setting of TapBridge", mode_tap_0)
    cmd.AddValue("tapName_tap_0", "Name of the OS tap device", tapName_tap_0)
    cmd.AddValue("mode_tap_1", "Mode Setting of TapBridge", mode_tap_1)
    cmd.AddValue("tapName_tap_1", "Name of the OS tap device", tapName_tap_1)
    cmd.AddValue("mode_tap_2", "Mode Setting of TapBridge", mode_tap_2)
    cmd.AddValue("tapName_tap_2", "Name of the OS tap device", tapName_tap_2)
    cmd.AddValue("deviceName_emu_0", "device name", emuDevice_emu_0)
    cmd.AddValue("deviceName_emu_1", "device name", emuDevice_emu_1)
    cmd.AddValue("deviceName_emu_2", "device name", emuDevice_emu_2)
    cmd.AddValue("mode_tap_0", "Mode Setting of TapBridge", mode_tap_0)
    cmd.AddValue("tapName_tap_0", "Name of the OS tap device", tapName_tap_0)
    cmd.AddValue("mode_tap_1", "Mode Setting of TapBridge", mode_tap_1)
    cmd.AddValue("tapName_tap_1", "Name of the OS tap device", tapName_tap_1)
    cmd.AddValue("mode_tap_2", "Mode Setting of TapBridge", mode_tap_2)
    cmd.AddValue("tapName_tap_2", "Name of the OS tap device", tapName_tap_2)
    cmd.Parse (argv)

    # Configuration.
    GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
    GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
    ns3.GlobalValue.Bind ("SimulatorImplementationType", ns3.StringValue ("ns3::RealtimeSimulatorImpl"));
    ns3.GlobalValue.Bind ("ChecksumEnabled", ns3.BooleanValue (true));

    # Build nodes
    term_0 = ns3.NodeContainer()
    term_0.Create (10)
    term_1 = ns3.NodeContainer()
    term_1.Create (10)
    term_2 = ns3.NodeContainer()
    term_2.Create (10)
    bridge_0 = ns3.NodeContainer()
    bridge_0.Create (1)
    ap_0 = ns3.NodeContainer()
    ap_0.Create (1)
    station_0 = ns3.NodeContainer()
    station_0.Create (1)
    station_1 = ns3.NodeContainer()
    station_1.Create (1)
    station_2 = ns3.NodeContainer()
    station_2.Create (1)
    station_3 = ns3.NodeContainer()
    station_3.Create (1)
    station_4 = ns3.NodeContainer()
    station_4.Create (1)
    station_5 = ns3.NodeContainer()
    station_5.Create (1)
    station_6 = ns3.NodeContainer()
    station_6.Create (1)
    term_3 = ns3.NodeContainer()
    term_3.Create (1)
    term_4 = ns3.NodeContainer()
    term_4.Create (1)
    term_5 = ns3.NodeContainer()
    term_5.Create (1)
    term_6 = ns3.NodeContainer()
    term_6.Create (1)
    bridge_1 = ns3.NodeContainer()
    bridge_1.Create (1)
    bridge_2 = ns3.NodeContainer()
    bridge_2.Create (1)
    emu_0 = ns3.NodeContainer()
    emu_0.Create (1)
    emu_1 = ns3.NodeContainer()
    emu_1.Create (1)
    term_7 = ns3.NodeContainer()
    term_7.Create (1)
    term_8 = ns3.NodeContainer()
    term_8.Create (1)
    term_9 = ns3.NodeContainer()
    term_9.Create (1)
    term_10 = ns3.NodeContainer()
    term_10.Create (1)
    term_11 = ns3.NodeContainer()
    term_11.Create (1)
    term_12 = ns3.NodeContainer()
    term_12.Create (10)
    term_13 = ns3.NodeContainer()
    term_13.Create (10)
    term_14 = ns3.NodeContainer()
    term_14.Create (10)
    bridge_3 = ns3.NodeContainer()
    bridge_3.Create (1)
    term_15 = ns3.NodeContainer()
    term_15.Create (1)
    term_16 = ns3.NodeContainer()
    term_16.Create (1)
    term_17 = ns3.NodeContainer()
    term_17.Create (1)
    term_18 = ns3.NodeContainer()
    term_18.Create (1)
    term_19 = ns3.NodeContainer()
    term_19.Create (1)
    term_20 = ns3.NodeContainer()
    term_20.Create (1)
    term_21 = ns3.NodeContainer()
    term_21.Create (1)
    term_22 = ns3.NodeContainer()
    term_22.Create (1)
    term_23 = ns3.NodeContainer()
    term_23.Create (1)
    term_24 = ns3.NodeContainer()
    term_24.Create (1)
    bridge_4 = ns3.NodeContainer()
    bridge_4.Create (1)
    ap_1 = ns3.NodeContainer()
    ap_1.Create (1)
    station_7 = ns3.NodeContainer()
    station_7.Create (1)
    station_8 = ns3.NodeContainer()
    station_8.Create (1)
    station_9 = ns3.NodeContainer()
    station_9.Create (1)
    station_10 = ns3.NodeContainer()
    station_10.Create (1)
    station_11 = ns3.NodeContainer()
    station_11.Create (1)
    station_12 = ns3.NodeContainer()
    station_12.Create (1)
    station_13 = ns3.NodeContainer()
    station_13.Create (1)
    emu_2 = ns3.NodeContainer()
    emu_2.Create (1)
    tap_0 = ns3.NodeContainer()
    tap_0.Create (1)
    tap_1 = ns3.NodeContainer()
    tap_1.Create (1)
    tap_2 = ns3.NodeContainer()
    tap_2.Create (1)
    term_0 = ns3.NodeContainer()
    term_0.Create (10)
    term_1 = ns3.NodeContainer()
    term_1.Create (10)
    term_2 = ns3.NodeContainer()
    term_2.Create (10)
    bridge_0 = ns3.NodeContainer()
    bridge_0.Create (1)
    router_0 = ns3.NodeContainer()
    router_0.Create (1)
    ap_0 = ns3.NodeContainer()
    ap_0.Create (1)
    station_0 = ns3.NodeContainer()
    station_0.Create (1)
    station_1 = ns3.NodeContainer()
    station_1.Create (1)
    station_2 = ns3.NodeContainer()
    station_2.Create (1)
    station_3 = ns3.NodeContainer()
    station_3.Create (1)
    station_4 = ns3.NodeContainer()
    station_4.Create (1)
    station_5 = ns3.NodeContainer()
    station_5.Create (1)
    station_6 = ns3.NodeContainer()
    station_6.Create (1)
    term_3 = ns3.NodeContainer()
    term_3.Create (1)
    term_4 = ns3.NodeContainer()
    term_4.Create (1)
    term_5 = ns3.NodeContainer()
    term_5.Create (1)
    term_6 = ns3.NodeContainer()
    term_6.Create (1)
    bridge_1 = ns3.NodeContainer()
    bridge_1.Create (1)
    bridge_2 = ns3.NodeContainer()
    bridge_2.Create (1)
    emu_0 = ns3.NodeContainer()
    emu_0.Create (1)
    emu_1 = ns3.NodeContainer()
    emu_1.Create (1)
    term_7 = ns3.NodeContainer()
    term_7.Create (1)
    term_8 = ns3.NodeContainer()
    term_8.Create (1)
    term_9 = ns3.NodeContainer()
    term_9.Create (1)
    term_10 = ns3.NodeContainer()
    term_10.Create (1)
    term_11 = ns3.NodeContainer()
    term_11.Create (1)
    term_12 = ns3.NodeContainer()
    term_12.Create (10)
    term_13 = ns3.NodeContainer()
    term_13.Create (10)
    term_14 = ns3.NodeContainer()
    term_14.Create (10)
    bridge_3 = ns3.NodeContainer()
    bridge_3.Create (1)
    term_15 = ns3.NodeContainer()
    term_15.Create (1)
    term_16 = ns3.NodeContainer()
    term_16.Create (1)
    term_17 = ns3.NodeContainer()
    term_17.Create (1)
    term_18 = ns3.NodeContainer()
    term_18.Create (1)
    term_19 = ns3.NodeContainer()
    term_19.Create (1)
    term_20 = ns3.NodeContainer()
    term_20.Create (1)
    term_21 = ns3.NodeContainer()
    term_21.Create (1)
    term_22 = ns3.NodeContainer()
    term_22.Create (1)
    term_23 = ns3.NodeContainer()
    term_23.Create (1)
    term_24 = ns3.NodeContainer()
    term_24.Create (1)
    bridge_4 = ns3.NodeContainer()
    bridge_4.Create (1)
    ap_1 = ns3.NodeContainer()
    ap_1.Create (1)
    station_7 = ns3.NodeContainer()
    station_7.Create (1)
    station_8 = ns3.NodeContainer()
    station_8.Create (1)
    station_9 = ns3.NodeContainer()
    station_9.Create (1)
    station_10 = ns3.NodeContainer()
    station_10.Create (1)
    station_11 = ns3.NodeContainer()
    station_11.Create (1)
    station_12 = ns3.NodeContainer()
    station_12.Create (1)
    station_13 = ns3.NodeContainer()
    station_13.Create (1)
    emu_2 = ns3.NodeContainer()
    emu_2.Create (1)
    tap_0 = ns3.NodeContainer()
    tap_0.Create (1)
    tap_1 = ns3.NodeContainer()
    tap_1.Create (1)
    tap_2 = ns3.NodeContainer()
    tap_2.Create (1)
    router_2 = ns3.NodeContainer()
    router_2.Create (1)
    term_50 = ns3.NodeContainer()
    term_50.Create (1)
    term_51 = ns3.NodeContainer()
    term_51.Create (1)

    # Build link.
    csma_bridge_0 = ns3.CsmaHelper();
    csma_bridge_0.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_0.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    wifiPhy_ap_0 = ns3.YansWifiPhyHelper.Default()
    wifiChannel_ap_0 = ns3.YansWifiChannelHelper.Default()
    wifiPhy_ap_0.SetChannel(wifiChannel_ap_0.Create())
    csma_bridge_1 = ns3.CsmaHelper();
    csma_bridge_1.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_1.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    csma_bridge_2 = ns3.CsmaHelper();
    csma_bridge_2.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_2.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    csma_hub_0 = ns3.CsmaHelper()
    csma_hub_0.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_0.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    emu_0 = ns3.EmuHelper()
    emu_0.SetAttribute ("DeviceName", StringValue (emuDevice_emu_0))
    emu_1 = ns3.EmuHelper()
    emu_1.SetAttribute ("DeviceName", StringValue (emuDevice_emu_1))
    csma_hub_1 = ns3.CsmaHelper()
    csma_hub_1.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_1.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_hub_2 = ns3.CsmaHelper()
    csma_hub_2.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_2.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_bridge_3 = ns3.CsmaHelper();
    csma_bridge_3.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_3.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    csma_bridge_4 = ns3.CsmaHelper();
    csma_bridge_4.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_4.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    wifiPhy_ap_1 = ns3.YansWifiPhyHelper.Default()
    wifiChannel_ap_1 = ns3.YansWifiChannelHelper.Default()
    wifiPhy_ap_1.SetChannel(wifiChannel_ap_1.Create())
    emu_2 = ns3.EmuHelper()
    emu_2.SetAttribute ("DeviceName", StringValue (emuDevice_emu_2))
    csma_hub_3 = ns3.CsmaHelper()
    csma_hub_3.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_3.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_tap_0 = ns3.CsmaHelper()
    csma_tap_0.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)));
    csma_tap_0.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)));
    csma_hub_4 = ns3.CsmaHelper()
    csma_hub_4.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_4.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_tap_1 = ns3.CsmaHelper()
    csma_tap_1.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)));
    csma_tap_1.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)));
    csma_tap_2 = ns3.CsmaHelper()
    csma_tap_2.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)));
    csma_tap_2.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)));
    csma_hub_5 = ns3.CsmaHelper()
    csma_hub_5.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_5.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_hub_6 = ns3.CsmaHelper()
    csma_hub_6.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_6.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_bridge_0 = ns3.CsmaHelper();
    csma_bridge_0.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_0.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    wifiPhy_ap_0 = ns3.YansWifiPhyHelper.Default()
    wifiChannel_ap_0 = ns3.YansWifiChannelHelper.Default()
    wifiPhy_ap_0.SetChannel(wifiChannel_ap_0.Create())
    p2p_p2p_0 = ns3.PointToPointHelper()
    p2p_p2p_0.SetDeviceAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    p2p_p2p_0.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_bridge_1 = ns3.CsmaHelper();
    csma_bridge_1.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_1.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    csma_bridge_2 = ns3.CsmaHelper();
    csma_bridge_2.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_2.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    csma_hub_0 = ns3.CsmaHelper()
    csma_hub_0.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_0.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    emu_0 = ns3.EmuHelper()
    emu_0.SetAttribute ("DeviceName", StringValue (emuDevice_emu_0))
    emu_1 = ns3.EmuHelper()
    emu_1.SetAttribute ("DeviceName", StringValue (emuDevice_emu_1))
    csma_hub_1 = ns3.CsmaHelper()
    csma_hub_1.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_1.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_hub_2 = ns3.CsmaHelper()
    csma_hub_2.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_2.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_bridge_3 = ns3.CsmaHelper();
    csma_bridge_3.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_3.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    csma_bridge_4 = ns3.CsmaHelper();
    csma_bridge_4.SetChannelAttribute("DataRate", ns3.DataRateValue (ns3.DataRate(100000000)))
    csma_bridge_4.SetChannelAttribute("Delay",  ns3.TimeValue (ns3.MilliSeconds(10000)))
    wifiPhy_ap_1 = ns3.YansWifiPhyHelper.Default()
    wifiChannel_ap_1 = ns3.YansWifiChannelHelper.Default()
    wifiPhy_ap_1.SetChannel(wifiChannel_ap_1.Create())
    p2p_p2p_1 = ns3.PointToPointHelper()
    p2p_p2p_1.SetDeviceAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    p2p_p2p_1.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)))
    emu_2 = ns3.EmuHelper()
    emu_2.SetAttribute ("DeviceName", StringValue (emuDevice_emu_2))
    csma_hub_3 = ns3.CsmaHelper()
    csma_hub_3.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_3.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_tap_0 = ns3.CsmaHelper()
    csma_tap_0.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)));
    csma_tap_0.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)));
    csma_hub_4 = ns3.CsmaHelper()
    csma_hub_4.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_4.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_tap_1 = ns3.CsmaHelper()
    csma_tap_1.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)));
    csma_tap_1.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)));
    csma_tap_2 = ns3.CsmaHelper()
    csma_tap_2.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)));
    csma_tap_2.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)));
    csma_hub_5 = ns3.CsmaHelper()
    csma_hub_5.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_5.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    csma_hub_6 = ns3.CsmaHelper()
    csma_hub_6.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    csma_hub_6.SetChannelAttribute("Delay",  ns3.TimeValue(ns3.MilliSeconds(10000)))
    p2p_p2p_4 = ns3.PointToPointHelper()
    p2p_p2p_4.SetDeviceAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(100000000)))
    p2p_p2p_4.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(10000)))

    # Build link net device container.
    all_bridge_0 = ns3.NodeContainer()
    all_bridge_0.Add (term_0)
    all_bridge_0.Add (term_1)
    all_bridge_0.Add (term_2)
    terminalDevices_bridge_0 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_0 = ns3.NetDeviceContainer()
    for i in range(3):
        link = csma_bridge_0.Install(NodeContainer(all_bridge_0.Get(i), bridge_0))
        terminalDevices_bridge_0.Add(link.Get(0))
        BridgeDevices_bridge_0.Add(link.Get(1))
    bridge_bridge_0 = ns3.BridgeHelper
    bridge_bridge_0.Install(bridge_0.Get(0), BridgeDevices_bridge_0)
    ndc_bridge_0 = terminalDevices_bridge_0
    all_ap_0 = ns3.NodeContainer()
    ndc_ap_0 = ns3.NetDeviceContainer()
    ssid_ap_0 = ns3.Ssid("wifi-default-0")
    wifi_ap_0 = ns3.WifiHelper.Default()
    wifiMac_ap_0 = ns3.NqosWifiMacHelper.Default()
    wifi_ap_0.SetRemoteStationManager("ns3::ArfWifiManager")
    wifiMac_ap_0.SetType ("ns3::ApWifiMac", 
       "Ssid", ns3.SsidValue(ssid_ap_0), 
       "BeaconGeneration", ns3.BooleanValue(True),
       "BeaconInterval", ns3.TimeValue(ns3.Seconds(2.5)))
    ndc_ap_0.Add(wifi_ap_0.Install(wifiPhy_ap_0, wifiMac_ap_0, ap_0))
    wifiMac_ap_0.SetType("ns3::StaWifiMac",
       "Ssid", ns3.SsidValue(ssid_ap_0), 
       "ActiveProbing", ns3.BooleanValue(False))
    ndc_ap_0.Add(wifi_ap_0.Install(wifiPhy_ap_0, wifiMac_ap_0, all_ap_0 ))
    mobility_ap_0 = ns3.MobilityHelper()
    mobility_ap_0.SetMobilityModel ("ns3::ConstantPositionMobilityModel")
    mobility_ap_0.Install(ap_0)
    mobility_ap_0.Install(all_ap_0)
    all_bridge_1 = ns3.NodeContainer()
    all_bridge_1.Add (term_6)
    all_bridge_1.Add (term_4)
    all_bridge_1.Add (term_5)
    all_bridge_1.Add (term_3)
    all_bridge_1.Add (term_11)
    all_bridge_1.Add (term_10)
    all_bridge_1.Add (term_9)
    all_bridge_1.Add (term_8)
    terminalDevices_bridge_1 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_1 = ns3.NetDeviceContainer()
    for i in range(8):
        link = csma_bridge_1.Install(NodeContainer(all_bridge_1.Get(i), bridge_1))
        terminalDevices_bridge_1.Add(link.Get(0))
        BridgeDevices_bridge_1.Add(link.Get(1))
    bridge_bridge_1 = ns3.BridgeHelper
    bridge_bridge_1.Install(bridge_1.Get(0), BridgeDevices_bridge_1)
    ndc_bridge_1 = terminalDevices_bridge_1
    all_bridge_2 = ns3.NodeContainer()
    terminalDevices_bridge_2 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_2 = ns3.NetDeviceContainer()
    for i in range(0):
        link = csma_bridge_2.Install(NodeContainer(all_bridge_2.Get(i), bridge_2))
        terminalDevices_bridge_2.Add(link.Get(0))
        BridgeDevices_bridge_2.Add(link.Get(1))
    bridge_bridge_2 = ns3.BridgeHelper
    bridge_bridge_2.Install(bridge_2.Get(0), BridgeDevices_bridge_2)
    ndc_bridge_2 = terminalDevices_bridge_2
    all_hub_0 = ns3.NodeContainer()
    all_hub_0.Add (bridge_1)
    all_hub_0.Add (bridge_2)
    ndc_hub_0 = csma_hub_0.Install(all_hub_0)
    all_emu_0 = ns3.NodeContainer()
    all_emu_0.Add (emu_0)
    ndc_emu_0 = emu_0.Install (all_emu_0)
    all_emu_1 = ns3.NodeContainer()
    all_emu_1.Add (emu_1)
    ndc_emu_1 = emu_1.Install (all_emu_1)
    all_hub_1 = ns3.NodeContainer()
    all_hub_1.Add (bridge_2)
    all_hub_1.Add (emu_0)
    ndc_hub_1 = csma_hub_1.Install(all_hub_1)
    all_hub_2 = ns3.NodeContainer()
    all_hub_2.Add (bridge_2)
    all_hub_2.Add (emu_1)
    ndc_hub_2 = csma_hub_2.Install(all_hub_2)
    all_bridge_3 = ns3.NodeContainer()
    all_bridge_3.Add (term_12)
    all_bridge_3.Add (term_13)
    all_bridge_3.Add (term_14)
    terminalDevices_bridge_3 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_3 = ns3.NetDeviceContainer()
    for i in range(3):
        link = csma_bridge_3.Install(NodeContainer(all_bridge_3.Get(i), bridge_3))
        terminalDevices_bridge_3.Add(link.Get(0))
        BridgeDevices_bridge_3.Add(link.Get(1))
    bridge_bridge_3 = ns3.BridgeHelper
    bridge_bridge_3.Install(bridge_3.Get(0), BridgeDevices_bridge_3)
    ndc_bridge_3 = terminalDevices_bridge_3
    all_bridge_4 = ns3.NodeContainer()
    all_bridge_4.Add (term_21)
    all_bridge_4.Add (term_22)
    all_bridge_4.Add (term_20)
    all_bridge_4.Add (term_7)
    all_bridge_4.Add (term_24)
    all_bridge_4.Add (term_23)
    all_bridge_4.Add (term_15)
    all_bridge_4.Add (term_19)
    all_bridge_4.Add (term_16)
    all_bridge_4.Add (term_17)
    all_bridge_4.Add (term_18)
    all_bridge_4.Add (term_51)
    all_bridge_4.Add (term_50)
    terminalDevices_bridge_4 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_4 = ns3.NetDeviceContainer()
    for i in range(13):
        link = csma_bridge_4.Install(NodeContainer(all_bridge_4.Get(i), bridge_4))
        terminalDevices_bridge_4.Add(link.Get(0))
        BridgeDevices_bridge_4.Add(link.Get(1))
    bridge_bridge_4 = ns3.BridgeHelper
    bridge_bridge_4.Install(bridge_4.Get(0), BridgeDevices_bridge_4)
    ndc_bridge_4 = terminalDevices_bridge_4
    all_ap_1 = ns3.NodeContainer()
    ndc_ap_1 = ns3.NetDeviceContainer()
    ssid_ap_1 = ns3.Ssid("wifi-default-1")
    wifi_ap_1 = ns3.WifiHelper.Default()
    wifiMac_ap_1 = ns3.NqosWifiMacHelper.Default()
    wifi_ap_1.SetRemoteStationManager("ns3::ArfWifiManager")
    wifiMac_ap_1.SetType ("ns3::ApWifiMac", 
       "Ssid", ns3.SsidValue(ssid_ap_1), 
       "BeaconGeneration", ns3.BooleanValue(True),
       "BeaconInterval", ns3.TimeValue(ns3.Seconds(2.5)))
    ndc_ap_1.Add(wifi_ap_1.Install(wifiPhy_ap_1, wifiMac_ap_1, ap_1))
    wifiMac_ap_1.SetType("ns3::StaWifiMac",
       "Ssid", ns3.SsidValue(ssid_ap_1), 
       "ActiveProbing", ns3.BooleanValue(False))
    ndc_ap_1.Add(wifi_ap_1.Install(wifiPhy_ap_1, wifiMac_ap_1, all_ap_1 ))
    mobility_ap_1 = ns3.MobilityHelper()
    mobility_ap_1.SetMobilityModel ("ns3::ConstantPositionMobilityModel")
    mobility_ap_1.Install(ap_1)
    mobility_ap_1.Install(all_ap_1)
    all_emu_2 = ns3.NodeContainer()
    all_emu_2.Add (emu_2)
    ndc_emu_2 = emu_2.Install (all_emu_2)
    all_hub_3 = ns3.NodeContainer()
    all_hub_3.Add (bridge_2)
    all_hub_3.Add (emu_2)
    ndc_hub_3 = csma_hub_3.Install(all_hub_3)
    NodeContainer all_tap_0;
    all_tap_0.Add (tap_0);
    ndc_tap_0 = csma_tap_0.Install(all_tap_0);
    all_hub_4 = ns3.NodeContainer()
    all_hub_4.Add (emu_2)
    all_hub_4.Add (tap_0)
    ndc_hub_4 = csma_hub_4.Install(all_hub_4)
    NodeContainer all_tap_1;
    all_tap_1.Add (tap_1);
    ndc_tap_1 = csma_tap_1.Install(all_tap_1);
    NodeContainer all_tap_2;
    all_tap_2.Add (tap_2);
    ndc_tap_2 = csma_tap_2.Install(all_tap_2);
    all_hub_5 = ns3.NodeContainer()
    all_hub_5.Add (emu_0)
    all_hub_5.Add (tap_2)
    ndc_hub_5 = csma_hub_5.Install(all_hub_5)
    all_hub_6 = ns3.NodeContainer()
    all_hub_6.Add (emu_1)
    all_hub_6.Add (tap_1)
    ndc_hub_6 = csma_hub_6.Install(all_hub_6)
    all_bridge_6 = ns3.NodeContainer()
    all_bridge_6.Add (router_0)
    all_bridge_6.Add (term_0)
    all_bridge_6.Add (term_1)
    all_bridge_6.Add (term_2)
    terminalDevices_bridge_0 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_0 = ns3.NetDeviceContainer()
    for i in range(4):
        link = csma_bridge_0.Install(NodeContainer(all_bridge_6.Get(i), bridge_0))
        terminalDevices_bridge_0.Add(link.Get(0))
        BridgeDevices_bridge_0.Add(link.Get(1))
    bridge_bridge_0 = ns3.BridgeHelper
    bridge_bridge_0.Install(bridge_0.Get(0), BridgeDevices_bridge_0)
    ndc_bridge_0 = terminalDevices_bridge_0
    all_ap_2 = ns3.NodeContainer()
    ndc_ap_2 = ns3.NetDeviceContainer()
    ssid_ap_0 = ns3.Ssid("wifi-default-2")
    wifi_ap_0 = ns3.WifiHelper.Default()
    wifiMac_ap_0 = ns3.NqosWifiMacHelper.Default()
    wifi_ap_0.SetRemoteStationManager("ns3::ArfWifiManager")
    wifiMac_ap_0.SetType ("ns3::ApWifiMac", 
       "Ssid", ns3.SsidValue(ssid_ap_0), 
       "BeaconGeneration", ns3.BooleanValue(True),
       "BeaconInterval", ns3.TimeValue(ns3.Seconds(2.5)))
    ndc_ap_2.Add(wifi_ap_0.Install(wifiPhy_ap_0, wifiMac_ap_0, ap_0))
    wifiMac_ap_0.SetType("ns3::StaWifiMac",
       "Ssid", ns3.SsidValue(ssid_ap_0), 
       "ActiveProbing", ns3.BooleanValue(False))
    ndc_ap_2.Add(wifi_ap_0.Install(wifiPhy_ap_0, wifiMac_ap_0, all_ap_2 ))
    mobility_ap_0 = ns3.MobilityHelper()
    mobility_ap_0.SetMobilityModel ("ns3::ConstantPositionMobilityModel")
    mobility_ap_0.Install(ap_0)
    mobility_ap_0.Install(all_ap_2)
    all_p2p_2 = ns3.NodeContainer()
    all_p2p_2.Add (router_0)
    ndc_p2p_2 = p2p_p2p_0.Install(all_p2p_2)
    all_bridge_7 = ns3.NodeContainer()
    all_bridge_7.Add (term_6)
    all_bridge_7.Add (term_4)
    all_bridge_7.Add (term_5)
    all_bridge_7.Add (term_3)
    all_bridge_7.Add (term_11)
    all_bridge_7.Add (term_10)
    all_bridge_7.Add (term_9)
    all_bridge_7.Add (term_8)
    terminalDevices_bridge_1 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_1 = ns3.NetDeviceContainer()
    for i in range(8):
        link = csma_bridge_1.Install(NodeContainer(all_bridge_7.Get(i), bridge_1))
        terminalDevices_bridge_1.Add(link.Get(0))
        BridgeDevices_bridge_1.Add(link.Get(1))
    bridge_bridge_1 = ns3.BridgeHelper
    bridge_bridge_1.Install(bridge_1.Get(0), BridgeDevices_bridge_1)
    ndc_bridge_1 = terminalDevices_bridge_1
    all_bridge_8 = ns3.NodeContainer()
    all_bridge_8.Add (router_0)
    terminalDevices_bridge_2 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_2 = ns3.NetDeviceContainer()
    for i in range(1):
        link = csma_bridge_2.Install(NodeContainer(all_bridge_8.Get(i), bridge_2))
        terminalDevices_bridge_2.Add(link.Get(0))
        BridgeDevices_bridge_2.Add(link.Get(1))
    bridge_bridge_2 = ns3.BridgeHelper
    bridge_bridge_2.Install(bridge_2.Get(0), BridgeDevices_bridge_2)
    ndc_bridge_2 = terminalDevices_bridge_2
    all_hub_7 = ns3.NodeContainer()
    all_hub_7.Add (bridge_1)
    all_hub_7.Add (bridge_2)
    ndc_hub_7 = csma_hub_0.Install(all_hub_7)
    all_emu_3 = ns3.NodeContainer()
    all_emu_3.Add (emu_0)
    all_emu_3.Add (emu_0)
    ndc_emu_3 = emu_0.Install (all_emu_3)
    all_emu_4 = ns3.NodeContainer()
    all_emu_4.Add (emu_1)
    all_emu_4.Add (emu_1)
    ndc_emu_4 = emu_1.Install (all_emu_4)
    all_hub_8 = ns3.NodeContainer()
    all_hub_8.Add (bridge_2)
    all_hub_8.Add (emu_0)
    ndc_hub_8 = csma_hub_1.Install(all_hub_8)
    all_hub_9 = ns3.NodeContainer()
    all_hub_9.Add (bridge_2)
    all_hub_9.Add (emu_1)
    ndc_hub_9 = csma_hub_2.Install(all_hub_9)
    all_bridge_9 = ns3.NodeContainer()
    all_bridge_9.Add (router_0)
    all_bridge_9.Add (term_12)
    all_bridge_9.Add (term_13)
    all_bridge_9.Add (term_14)
    terminalDevices_bridge_3 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_3 = ns3.NetDeviceContainer()
    for i in range(4):
        link = csma_bridge_3.Install(NodeContainer(all_bridge_9.Get(i), bridge_3))
        terminalDevices_bridge_3.Add(link.Get(0))
        BridgeDevices_bridge_3.Add(link.Get(1))
    bridge_bridge_3 = ns3.BridgeHelper
    bridge_bridge_3.Install(bridge_3.Get(0), BridgeDevices_bridge_3)
    ndc_bridge_3 = terminalDevices_bridge_3
    all_bridge_10 = ns3.NodeContainer()
    all_bridge_10.Add (router_0)
    all_bridge_10.Add (term_21)
    all_bridge_10.Add (term_22)
    all_bridge_10.Add (term_20)
    all_bridge_10.Add (term_7)
    all_bridge_10.Add (term_24)
    all_bridge_10.Add (term_23)
    all_bridge_10.Add (term_15)
    all_bridge_10.Add (term_19)
    all_bridge_10.Add (term_16)
    all_bridge_10.Add (term_17)
    all_bridge_10.Add (term_18)
    terminalDevices_bridge_4 = ns3.NetDeviceContainer()
    BridgeDevices_bridge_4 = ns3.NetDeviceContainer()
    for i in range(12):
        link = csma_bridge_4.Install(NodeContainer(all_bridge_10.Get(i), bridge_4))
        terminalDevices_bridge_4.Add(link.Get(0))
        BridgeDevices_bridge_4.Add(link.Get(1))
    bridge_bridge_4 = ns3.BridgeHelper
    bridge_bridge_4.Install(bridge_4.Get(0), BridgeDevices_bridge_4)
    ndc_bridge_4 = terminalDevices_bridge_4
    all_ap_3 = ns3.NodeContainer()
    ndc_ap_3 = ns3.NetDeviceContainer()
    ssid_ap_1 = ns3.Ssid("wifi-default-3")
    wifi_ap_1 = ns3.WifiHelper.Default()
    wifiMac_ap_1 = ns3.NqosWifiMacHelper.Default()
    wifi_ap_1.SetRemoteStationManager("ns3::ArfWifiManager")
    wifiMac_ap_1.SetType ("ns3::ApWifiMac", 
       "Ssid", ns3.SsidValue(ssid_ap_1), 
       "BeaconGeneration", ns3.BooleanValue(True),
       "BeaconInterval", ns3.TimeValue(ns3.Seconds(2.5)))
    ndc_ap_3.Add(wifi_ap_1.Install(wifiPhy_ap_1, wifiMac_ap_1, ap_1))
    wifiMac_ap_1.SetType("ns3::StaWifiMac",
       "Ssid", ns3.SsidValue(ssid_ap_1), 
       "ActiveProbing", ns3.BooleanValue(False))
    ndc_ap_3.Add(wifi_ap_1.Install(wifiPhy_ap_1, wifiMac_ap_1, all_ap_3 ))
    mobility_ap_1 = ns3.MobilityHelper()
    mobility_ap_1.SetMobilityModel ("ns3::ConstantPositionMobilityModel")
    mobility_ap_1.Install(ap_1)
    mobility_ap_1.Install(all_ap_3)
    all_p2p_3 = ns3.NodeContainer()
    all_p2p_3.Add (router_0)
    ndc_p2p_3 = p2p_p2p_1.Install(all_p2p_3)
    all_emu_5 = ns3.NodeContainer()
    all_emu_5.Add (emu_2)
    all_emu_5.Add (emu_2)
    ndc_emu_5 = emu_2.Install (all_emu_5)
    all_hub_10 = ns3.NodeContainer()
    all_hub_10.Add (bridge_2)
    all_hub_10.Add (emu_2)
    ndc_hub_10 = csma_hub_3.Install(all_hub_10)
    NodeContainer all_tap_3;
    all_tap_3.Add (tap_0);
    all_tap_3.Add (tap_0);
    ndc_tap_3 = csma_tap_0.Install(all_tap_3);
    all_hub_11 = ns3.NodeContainer()
    all_hub_11.Add (emu_2)
    all_hub_11.Add (tap_0)
    ndc_hub_11 = csma_hub_4.Install(all_hub_11)
    NodeContainer all_tap_4;
    all_tap_4.Add (tap_1);
    all_tap_4.Add (tap_1);
    ndc_tap_4 = csma_tap_1.Install(all_tap_4);
    NodeContainer all_tap_5;
    all_tap_5.Add (tap_2);
    all_tap_5.Add (tap_2);
    ndc_tap_5 = csma_tap_2.Install(all_tap_5);
    all_hub_12 = ns3.NodeContainer()
    all_hub_12.Add (emu_0)
    all_hub_12.Add (tap_2)
    ndc_hub_12 = csma_hub_5.Install(all_hub_12)
    all_hub_13 = ns3.NodeContainer()
    all_hub_13.Add (emu_1)
    all_hub_13.Add (tap_1)
    ndc_hub_13 = csma_hub_6.Install(all_hub_13)
    all_p2p_4 = ns3.NodeContainer()
    all_p2p_4.Add (router_2)
    all_p2p_4.Add (router_0)
    ndc_p2p_4 = p2p_p2p_4.Install(all_p2p_4)

    # Install the IP stack.
    internetStackH = ns3.InternetStackHelper()
    internetStackH.Install (term_0)
    internetStackH.Install (term_1)
    internetStackH.Install (term_2)
    internetStackH.Install (ap_0)
    internetStackH.Install (station_0)
    internetStackH.Install (station_1)
    internetStackH.Install (station_2)
    internetStackH.Install (station_3)
    internetStackH.Install (station_4)
    internetStackH.Install (station_5)
    internetStackH.Install (station_6)
    internetStackH.Install (term_3)
    internetStackH.Install (term_4)
    internetStackH.Install (term_5)
    internetStackH.Install (term_6)
    internetStackH.Install (emu_0)
    internetStackH.Install (emu_1)
    internetStackH.Install (term_7)
    internetStackH.Install (term_8)
    internetStackH.Install (term_9)
    internetStackH.Install (term_10)
    internetStackH.Install (term_11)
    internetStackH.Install (term_12)
    internetStackH.Install (term_13)
    internetStackH.Install (term_14)
    internetStackH.Install (term_15)
    internetStackH.Install (term_16)
    internetStackH.Install (term_17)
    internetStackH.Install (term_18)
    internetStackH.Install (term_19)
    internetStackH.Install (term_20)
    internetStackH.Install (term_21)
    internetStackH.Install (term_22)
    internetStackH.Install (term_23)
    internetStackH.Install (term_24)
    internetStackH.Install (ap_1)
    internetStackH.Install (station_7)
    internetStackH.Install (station_8)
    internetStackH.Install (station_9)
    internetStackH.Install (station_10)
    internetStackH.Install (station_11)
    internetStackH.Install (station_12)
    internetStackH.Install (station_13)
    internetStackH.Install (emu_2)
    internetStackH.Install (tap_0)
    internetStackH.Install (tap_1)
    internetStackH.Install (tap_2)
    internetStackH.Install (term_0)
    internetStackH.Install (term_1)
    internetStackH.Install (term_2)
    internetStackH.Install (router_0)
    internetStackH.Install (ap_0)
    internetStackH.Install (station_0)
    internetStackH.Install (station_1)
    internetStackH.Install (station_2)
    internetStackH.Install (station_3)
    internetStackH.Install (station_4)
    internetStackH.Install (station_5)
    internetStackH.Install (station_6)
    internetStackH.Install (term_3)
    internetStackH.Install (term_4)
    internetStackH.Install (term_5)
    internetStackH.Install (term_6)
    internetStackH.Install (emu_0)
    internetStackH.Install (emu_1)
    internetStackH.Install (term_7)
    internetStackH.Install (term_8)
    internetStackH.Install (term_9)
    internetStackH.Install (term_10)
    internetStackH.Install (term_11)
    internetStackH.Install (term_12)
    internetStackH.Install (term_13)
    internetStackH.Install (term_14)
    internetStackH.Install (term_15)
    internetStackH.Install (term_16)
    internetStackH.Install (term_17)
    internetStackH.Install (term_18)
    internetStackH.Install (term_19)
    internetStackH.Install (term_20)
    internetStackH.Install (term_21)
    internetStackH.Install (term_22)
    internetStackH.Install (term_23)
    internetStackH.Install (term_24)
    internetStackH.Install (ap_1)
    internetStackH.Install (station_7)
    internetStackH.Install (station_8)
    internetStackH.Install (station_9)
    internetStackH.Install (station_10)
    internetStackH.Install (station_11)
    internetStackH.Install (station_12)
    internetStackH.Install (station_13)
    internetStackH.Install (emu_2)
    internetStackH.Install (tap_0)
    internetStackH.Install (tap_1)
    internetStackH.Install (tap_2)
    internetStackH.Install (router_2)
    internetStackH.Install (term_50)
    internetStackH.Install (term_51)

    # IP assign.
    ipv4 = ns3.Ipv4AddressHelper()
    ipv4.SetBase (ns3.Ipv4Address("10.0.0.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_0 = ipv4.Assign (ndc_bridge_0)
    ipv4.SetBase (ns3.Ipv4Address("10.0.1.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_ap_0 = ipv4.Assign (ndc_ap_0)
    ipv4.SetBase (ns3.Ipv4Address("10.0.2.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_1 = ipv4.Assign (ndc_bridge_1)
    ipv4.SetBase (ns3.Ipv4Address("10.0.3.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_2 = ipv4.Assign (ndc_bridge_2)
    ipv4.SetBase (ns3.Ipv4Address("10.0.4.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_0 = ipv4.Assign (ndc_hub_0)
    ipv4.SetBase (ns3.Ipv4Address("10.0.5.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_emu_0 = ipv4.Assign (ndc_emu_0)
    ipv4.SetBase (ns3.Ipv4Address("10.0.6.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_emu_1 = ipv4.Assign (ndc_emu_1)
    ipv4.SetBase (ns3.Ipv4Address("10.0.7.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_1 = ipv4.Assign (ndc_hub_1)
    ipv4.SetBase (ns3.Ipv4Address("10.0.8.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_2 = ipv4.Assign (ndc_hub_2)
    ipv4.SetBase (ns3.Ipv4Address("10.0.9.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_3 = ipv4.Assign (ndc_bridge_3)
    ipv4.SetBase (ns3.Ipv4Address("10.0.10.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_4 = ipv4.Assign (ndc_bridge_4)
    ipv4.SetBase (ns3.Ipv4Address("10.0.11.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_ap_1 = ipv4.Assign (ndc_ap_1)
    ipv4.SetBase (ns3.Ipv4Address("10.0.12.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_emu_2 = ipv4.Assign (ndc_emu_2)
    ipv4.SetBase (ns3.Ipv4Address("10.0.13.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_3 = ipv4.Assign (ndc_hub_3)
    ipv4.SetBase (ns3.Ipv4Address("10.0.14.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_tap_0 = ipv4.Assign (ndc_tap_0)
    ipv4.SetBase (ns3.Ipv4Address("10.0.15.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_4 = ipv4.Assign (ndc_hub_4)
    ipv4.SetBase (ns3.Ipv4Address("10.0.16.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_tap_1 = ipv4.Assign (ndc_tap_1)
    ipv4.SetBase (ns3.Ipv4Address("10.0.17.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_tap_2 = ipv4.Assign (ndc_tap_2)
    ipv4.SetBase (ns3.Ipv4Address("10.0.18.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_5 = ipv4.Assign (ndc_hub_5)
    ipv4.SetBase (ns3.Ipv4Address("10.0.19.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_6 = ipv4.Assign (ndc_hub_6)
    ipv4.SetBase (ns3.Ipv4Address("10.0.20.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_6 = ipv4.Assign (ndc_bridge_6)
    ipv4.SetBase (ns3.Ipv4Address("10.0.21.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_ap_2 = ipv4.Assign (ndc_ap_2)
    ipv4.SetBase (ns3.Ipv4Address("10.0.22.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_p2p_2 = ipv4.Assign (ndc_p2p_2)
    ipv4.SetBase (ns3.Ipv4Address("10.0.23.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_7 = ipv4.Assign (ndc_bridge_7)
    ipv4.SetBase (ns3.Ipv4Address("10.0.24.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_8 = ipv4.Assign (ndc_bridge_8)
    ipv4.SetBase (ns3.Ipv4Address("10.0.25.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_7 = ipv4.Assign (ndc_hub_7)
    ipv4.SetBase (ns3.Ipv4Address("10.0.26.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_emu_3 = ipv4.Assign (ndc_emu_3)
    ipv4.SetBase (ns3.Ipv4Address("10.0.27.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_emu_4 = ipv4.Assign (ndc_emu_4)
    ipv4.SetBase (ns3.Ipv4Address("10.0.28.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_8 = ipv4.Assign (ndc_hub_8)
    ipv4.SetBase (ns3.Ipv4Address("10.0.29.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_9 = ipv4.Assign (ndc_hub_9)
    ipv4.SetBase (ns3.Ipv4Address("10.0.30.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_9 = ipv4.Assign (ndc_bridge_9)
    ipv4.SetBase (ns3.Ipv4Address("10.0.31.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_bridge_10 = ipv4.Assign (ndc_bridge_10)
    ipv4.SetBase (ns3.Ipv4Address("10.0.32.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_ap_3 = ipv4.Assign (ndc_ap_3)
    ipv4.SetBase (ns3.Ipv4Address("10.0.33.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_p2p_3 = ipv4.Assign (ndc_p2p_3)
    ipv4.SetBase (ns3.Ipv4Address("10.0.34.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_emu_5 = ipv4.Assign (ndc_emu_5)
    ipv4.SetBase (ns3.Ipv4Address("10.0.35.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_10 = ipv4.Assign (ndc_hub_10)
    ipv4.SetBase (ns3.Ipv4Address("10.0.36.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_tap_3 = ipv4.Assign (ndc_tap_3)
    ipv4.SetBase (ns3.Ipv4Address("10.0.37.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_11 = ipv4.Assign (ndc_hub_11)
    ipv4.SetBase (ns3.Ipv4Address("10.0.38.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_tap_4 = ipv4.Assign (ndc_tap_4)
    ipv4.SetBase (ns3.Ipv4Address("10.0.39.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_tap_5 = ipv4.Assign (ndc_tap_5)
    ipv4.SetBase (ns3.Ipv4Address("10.0.40.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_12 = ipv4.Assign (ndc_hub_12)
    ipv4.SetBase (ns3.Ipv4Address("10.0.41.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_hub_13 = ipv4.Assign (ndc_hub_13)
    ipv4.SetBase (ns3.Ipv4Address("10.0.42.0"), ns3.Ipv4Mask("255.255.255.0"))
    iface_ndc_p2p_4 = ipv4.Assign (ndc_p2p_4)

    # Tap Bridge.
    tapBridge_tap_0 = ns3.TapBridgeHelper(iface_ndc_tap_0.GetAddress(1))
    tapBridge_tap_0.SetAttribute("Mode", ns3.StringValue (mode_tap_0))
    tapBridge_tap_0.SetAttribute("DeviceName", ns3.StringValue (tapName_tap_0))
    tapBridge_tap_0.Install(tap_0.Get(0), ndc_tap_0.Get(0))
    tapBridge_tap_1 = ns3.TapBridgeHelper(iface_ndc_tap_1.GetAddress(1))
    tapBridge_tap_1.SetAttribute("Mode", ns3.StringValue (mode_tap_1))
    tapBridge_tap_1.SetAttribute("DeviceName", ns3.StringValue (tapName_tap_1))
    tapBridge_tap_1.Install(tap_1.Get(0), ndc_tap_1.Get(0))
    tapBridge_tap_2 = ns3.TapBridgeHelper(iface_ndc_tap_2.GetAddress(1))
    tapBridge_tap_2.SetAttribute("Mode", ns3.StringValue (mode_tap_2))
    tapBridge_tap_2.SetAttribute("DeviceName", ns3.StringValue (tapName_tap_2))
    tapBridge_tap_2.Install(tap_2.Get(0), ndc_tap_2.Get(0))
    tapBridge_tap_0 = ns3.TapBridgeHelper(iface_ndc_tap_3.GetAddress(1))
    tapBridge_tap_0.SetAttribute("Mode", ns3.StringValue (mode_tap_0))
    tapBridge_tap_0.SetAttribute("DeviceName", ns3.StringValue (tapName_tap_0))
    tapBridge_tap_0.Install(tap_0.Get(0), ndc_tap_3.Get(0))
    tapBridge_tap_1 = ns3.TapBridgeHelper(iface_ndc_tap_4.GetAddress(1))
    tapBridge_tap_1.SetAttribute("Mode", ns3.StringValue (mode_tap_1))
    tapBridge_tap_1.SetAttribute("DeviceName", ns3.StringValue (tapName_tap_1))
    tapBridge_tap_1.Install(tap_1.Get(0), ndc_tap_4.Get(0))
    tapBridge_tap_2 = ns3.TapBridgeHelper(iface_ndc_tap_5.GetAddress(1))
    tapBridge_tap_2.SetAttribute("Mode", ns3.StringValue (mode_tap_2))
    tapBridge_tap_2.SetAttribute("DeviceName", ns3.StringValue (tapName_tap_2))
    tapBridge_tap_2.Install(tap_2.Get(0), ndc_tap_5.Get(0))

    # Generate Route.
    ns3.Ipv4GlobalRoutingHelper.PopulateRoutingTables ()

    # Generate Application.

    # Simulation.
    # Pcap output.
    # Stop the simulation after x seconds.
    stopTime = 1
    ns3.Simulator.Stop (ns3.Seconds(stopTime))
    # Start and clean simulation.
    ns3.Simulator.Run()
    ns3.Simulator.Destroy()
コード例 #11
0
ファイル: wifi3.py プロジェクト: naman/ns3-simulations
wifihelper = ns3.WifiHelper()
wifihelper.SetStandard(ns3.WIFI_PHY_STANDARD_80211b)
wifiphyhelper = ns3.YansWifiPhyHelper()
wifiphy = wifiphyhelper.Default()
wifiphy.Set("TxGain", ns3.DoubleValue(25))
wifiphy.Set("RxGain", ns3.DoubleValue(90))
wifichannel = ns3.YansWifiChannelHelper()
wifi_chan = wifichannel.Default()
wifi_chan.AddPropagationLoss("ns3::FriisPropagationLossModel")
wifiphy.SetChannel(wifi_chan.Create())

mac = ns3.NqosWifiMacHelper.Default()
mac.SetType("ns3::AdhocWifiMac")

wifihelper.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",
                                   ns3.StringValue("DsssRate1Mbps"),
                                   "ControlMode",
                                   ns3.StringValue("DsssRate1Mbps"))
devices = wifihelper.Install(wifiphy, mac, nodes)

olsr = ns3.OlsrHelper()

#Add the IPv4 protocol stack to the nodes in our container
internet = ns3.InternetStackHelper()
internet.SetRoutingHelper(olsr)

internet.Install(nodes)
ipaddrss = ns3.Ipv4AddressHelper()
ipaddrss.SetBase(ns3.Ipv4Address("192.168.0.0"), ns3.Ipv4Mask("255.255.255.0"))
ipcontainer = ipaddrss.Assign(devices)
コード例 #12
0
ファイル: first.py プロジェクト: amirkrifa/ns-allinone-3.9
#  *
#  * You should have received a copy of the GNU General Public License
#  * along with this program; if not, write to the Free Software
#  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#  */

import ns3

ns3.LogComponentEnable("UdpEchoClientApplication", ns3.LOG_LEVEL_INFO)
ns3.LogComponentEnable("UdpEchoServerApplication", ns3.LOG_LEVEL_INFO)

nodes = ns3.NodeContainer()
nodes.Create(2)

pointToPoint = ns3.PointToPointHelper()
pointToPoint.SetDeviceAttribute("DataRate", ns3.StringValue("5Mbps"))
pointToPoint.SetChannelAttribute("Delay", ns3.StringValue("2ms"))

devices = pointToPoint.Install(nodes)

stack = ns3.InternetStackHelper()
stack.Install(nodes)

address = ns3.Ipv4AddressHelper()
address.SetBase(ns3.Ipv4Address("10.1.1.0"), ns3.Ipv4Mask("255.255.255.0"))

interfaces = address.Assign(devices)

echoServer = ns3.UdpEchoServerHelper(9)

serverApps = echoServer.Install(nodes.Get(1))
コード例 #13
0
ファイル: wifi.py プロジェクト: naman/ns3-simulations
import ns3
nodes = ns3.NodeContainer()
nodes.Create(2)

wifihelper = ns3.WifiHelper()

wifiphyhelper = ns3.YansWifiPhyHelper()
wifiphy = wifiphyhelper.Default()
wifichannel = ns3.YansWifiChannelHelper()
wifi_chan = wifichannel.Default()
wifiphy.SetChannel(wifi_chan.Create())

mac = ns3.NqosWifiMacHelper.Default()
mac.SetType("ns3::AdhocWifiMac")

wifihelper.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",
                                   ns3.StringValue("wifia-54mbs"))
wifihelper.Install(wifiphy, mac, nodes)