Ejemplo n.º 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
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
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
Ejemplo n.º 4
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()