예제 #1
0
def simulation(network):
    # Applications
    ns3_lib.udp_echo_app(network,
                         client_node="Urcos",
                         server_node="Ccatcca",
                         server_device="Josjo2-wimax2",
                         start=1.0,
                         stop=9.0,
                         packets=2,
                         interval=1.0)
    ns3_lib.add_wimax_service_flow(network,
                                   install=("Ccatcca", "Josjo2-wimax2"),
                                   source=("Urpay", "Josjo1-wifi1", None),
                                   dest=("Ccatcca", "Josjo2-wimax2", 9),
                                   protocol="udp",
                                   direction="down",
                                   scheduling="rtps",
                                   priority=0)

    # Tracing
    #device = network.nodes["Josjojauarina 1"].devices["Josjo1-wifi1"]
    #device.phy_helper.EnablePcap("udp_echo", device.ns3_device)

    # Run simulation
    ns3_lib.run_simulation(network, 10.0)
예제 #2
0
 def simulation(network):
     ns3_lib.udp_echo_app(network, client_node="Urcos", server_node="Ccatcca", 
         server_device="Josjo2-wimax2", start=1.0, stop=9.0, packets=2, interval=1.0)
     ns3_lib.add_wimax_service_flow(network, install=("Ccatcca", "Josjo2-wimax2"), 
         source=("Urcos", "Huiracochan-wifi1", None), dest=("Ccatcca", "Josjo2-wimax2", 9), 
         protocol="udp", direction="down", scheduling="rtps", priority=0)
         
     monitor_info = ns3_lib.enable_monitor(network, interval=0.1)
     
     ns3.LogComponentEnable("UdpEchoClientApplication", ns3.LOG_LEVEL_INFO)
     ns3.LogComponentEnable("UdpEchoServerApplication", ns3.LOG_LEVEL_INFO)
     ns3_lib.run_simulation(network, 5.0)
     
     return monitor_info
예제 #3
0
def simulation(network):
    # Applications
    ns3_lib.udp_echo_app(network, client_node="Urcos", server_node="Ccatcca", 
        server_device="Josjo2-wimax2", start=1.0, stop=9.0, packets=2, interval=1.0)
    ns3_lib.add_wimax_service_flow(network, install=("Ccatcca", "Josjo2-wimax2"), 
        source=("Urpay", "Josjo1-wifi1", None), dest=("Ccatcca", "Josjo2-wimax2", 9), 
        protocol="udp", direction="down", scheduling="rtps", priority=0)
    
    # Tracing
    #device = network.nodes["Josjojauarina 1"].devices["Josjo1-wifi1"]
    #device.phy_helper.EnablePcap("udp_echo", device.ns3_device)

    # Run simulation    
    ns3_lib.run_simulation(network, 10.0)
예제 #4
0
def simulation(network):
    ns3.LogComponentEnable("PacketSink",
                           ns3.LOG_LEVEL_ALL | ns3.LOG_PREFIX_TIME)

    # Applications
    ns3_lib.onoff_app(network,
                      client_node="Urcos",
                      server_node="Huiracochan",
                      server_device="Josjo1-wifi1",
                      start=1.0,
                      stop=9.0,
                      rate="1Mbps",
                      access_class="ac_vo")
    ns3_lib.onoff_app(network,
                      client_node="Urpay",
                      server_node="Ccatcca",
                      server_device="Josjo2-wimax2",
                      start=1.0,
                      stop=9.0,
                      rate="0.5Mbps")
    ns3_lib.add_wimax_service_flow(network,
                                   install=("Ccatcca", "Josjo2-wimax2"),
                                   source=("Urpay", "Josjo1-wifi1", None),
                                   dest=("Ccatcca", "Josjo2-wimax2", 9),
                                   protocol="udp",
                                   direction="down",
                                   scheduling="rtps",
                                   priority=0)

    # Tracing
    #device = network.nodes["Josjojauarina 1"].devices["Josjo1-wifi1"]
    #device.phy_helper.EnablePcap("onoff", device.ns3_device)

    monitor_info = ns3_lib.enable_monitor(network, interval=0.1)

    # Run simulation
    ns3_lib.run_simulation(network, 3.0)
    ns3_lib.print_monitor_results(monitor_info)
    ns3_lib.save_monitor_xmldata(monitor_info, "onoff.flowmon.xml")
    ns3_lib.create_througput_gnuplot(monitor_info, "Urcos-Huiracochan 1Mbps",
                                     "onoff")
예제 #5
0
def simulation(network):
    ns3.LogComponentEnable("PacketSink", ns3.LOG_LEVEL_ALL | ns3.LOG_PREFIX_TIME)
    
    # Applications    
    ns3_lib.onoff_app(network, client_node="Urcos", 
        server_node="Huiracochan", server_device="Josjo1-wifi1", 
        start=1.0, stop=9.0, rate="1Mbps", access_class="ac_vo")
    ns3_lib.onoff_app(network, client_node="Urpay", 
        server_node="Ccatcca", server_device="Josjo2-wimax2", start=1.0, stop=9.0, rate="0.5Mbps")
    ns3_lib.add_wimax_service_flow(network, install=("Ccatcca", "Josjo2-wimax2"), 
        source=("Urpay", "Josjo1-wifi1", None), dest=("Ccatcca", "Josjo2-wimax2", 9), 
        protocol="udp", direction="down", scheduling="rtps", priority=0)

    # Tracing    
    #device = network.nodes["Josjojauarina 1"].devices["Josjo1-wifi1"]
    #device.phy_helper.EnablePcap("onoff", device.ns3_device)

    monitor_info = ns3_lib.enable_monitor(network, interval=0.1)
    
    # Run simulation
    ns3_lib.run_simulation(network, 3.0)
    ns3_lib.print_monitor_results(monitor_info)
    ns3_lib.save_monitor_xmldata(monitor_info, "onoff.flowmon.xml")
    ns3_lib.create_througput_gnuplot(monitor_info, "Urcos-Huiracochan 1Mbps", "onoff")
예제 #6
0
def siminfo(filename, stream=sys.stdout):
    """Run a simulation YML file."""
    logging.debug("Open simulation file: %s" % filename)
    config = yaml.load(open(filename).read())
    logging.info("Simulation: %s (%s)" % (config["description"], config["version"]))
    logging.debug("Simulation YAML:")
    for line in pprint.pformat(config).splitlines(): 
        logging.debug(line)
        
    assert "netinfo" in config, "missing compulsory variable: netinfo"
    siminfo_dir = os.path.dirname(os.path.abspath(filename))
    netinfo_path = os.path.join(siminfo_dir, config["netinfo"])
    network = wwnetwork.create_network_from_yaml_file(netinfo_path)
    
    # Enable Logs    
    for name, string_flags in (config["logs"] or {}).iteritems():
        attrs = ["LOG_" + s.upper() for s in string_flags.split("|")]
        flags = reduce(operator.or_, [getattr(ns3, attr) for attr in attrs])
        logging.debug("Log enabled: %s=%s" % (name, flags))
        ns3.LogComponentEnable(name, flags)
        
    # Add applications
    assert "apps" in config
    for app in config["apps"]:
        available_applications = ns3_lib.get_available_applications()
        assert (app["type"] in available_applications), \
            "Application type '%s' not found, available: %s" % \
            (app["type"], ", ".join(available_applications.keys()))
        app_kwargs = filter_dict_by_keys(app, ["type"])
        app_func = available_applications[app["type"]]
        logging.debug("Add application: %s (%s)" % (app["type"], app_kwargs))
        app_func(network, **app_kwargs)

    for flow in config.get("wimax_service_flows", []):
        logging.debug("Add service flow: %s" % flow)
        ns3_lib.add_wimax_service_flow(network, **flow)
    
    # Enable flow-monitor & tracking    
    interval = config["simulation"].get("interval", 0.1)
    logging.debug("Flow monitor interval: %s seconds" % interval)
    monitor_info = ns3_lib.enable_monitor(network, interval)

    for options in config["results"].get("save_pcap", []):
        device = network.nodes[options["node"]].devices[options["device"]]
        device.phy_helper.EnablePcap(options["filename"], device.ns3_device)
        logging.debug("Enable pcap for %s:%s" % (options["node"], options["device"]))

    # Start simulation        
    duration = config["simulation"].get("duration")
    ns3_lib.run_simulation(network, duration)
            
    # Results
    ns3_lib.print_monitor_results(monitor_info, stream=stream)    
    if "monitor" in config["results"]:
        xmlfile = results["monitor"].get("save_xml")
        if xmlfile:
            ns3_lib.save_monitor_xmldata(monitor_info, xmlfile)

    for plot in config["results"].get("plots", []):
        available_plots = ns3_lib.get_available_plots()
        assert (plot["type"] in available_plots), \
            "Plot type '%s' not found, available: %s" % \
            (plot["type"], ", ".join(available_plots.keys()))
        plot_func = available_plots[plot["type"]]
        plot_kwargs = filter_dict_by_keys(plot, ["type"])
        plot_func(monitor_info, **plot_kwargs)
예제 #7
0
def siminfo(filename, stream=sys.stdout):
    """Run a simulation YML file."""
    logging.debug("Open simulation file: %s" % filename)
    config = yaml.load(open(filename).read())
    logging.info("Simulation: %s (%s)" %
                 (config["description"], config["version"]))
    logging.debug("Simulation YAML:")
    for line in pprint.pformat(config).splitlines():
        logging.debug(line)

    assert "netinfo" in config, "missing compulsory variable: netinfo"
    siminfo_dir = os.path.dirname(os.path.abspath(filename))
    netinfo_path = os.path.join(siminfo_dir, config["netinfo"])
    network = wwnetwork.create_network_from_yaml_file(netinfo_path)

    # Enable Logs
    for name, string_flags in (config["logs"] or {}).iteritems():
        attrs = ["LOG_" + s.upper() for s in string_flags.split("|")]
        flags = reduce(operator.or_, [getattr(ns3, attr) for attr in attrs])
        logging.debug("Log enabled: %s=%s" % (name, flags))
        ns3.LogComponentEnable(name, flags)

    # Add applications
    assert "apps" in config
    for app in config["apps"]:
        available_applications = ns3_lib.get_available_applications()
        assert (app["type"] in available_applications), \
            "Application type '%s' not found, available: %s" % \
            (app["type"], ", ".join(available_applications.keys()))
        app_kwargs = filter_dict_by_keys(app, ["type"])
        app_func = available_applications[app["type"]]
        logging.debug("Add application: %s (%s)" % (app["type"], app_kwargs))
        app_func(network, **app_kwargs)

    for flow in config.get("wimax_service_flows", []):
        logging.debug("Add service flow: %s" % flow)
        ns3_lib.add_wimax_service_flow(network, **flow)

    # Enable flow-monitor & tracking
    interval = config["simulation"].get("interval", 0.1)
    logging.debug("Flow monitor interval: %s seconds" % interval)
    monitor_info = ns3_lib.enable_monitor(network, interval)

    for options in config["results"].get("save_pcap", []):
        device = network.nodes[options["node"]].devices[options["device"]]
        device.phy_helper.EnablePcap(options["filename"], device.ns3_device)
        logging.debug("Enable pcap for %s:%s" %
                      (options["node"], options["device"]))

    # Start simulation
    duration = config["simulation"].get("duration")
    ns3_lib.run_simulation(network, duration)

    # Results
    ns3_lib.print_monitor_results(monitor_info, stream=stream)
    if "monitor" in config["results"]:
        xmlfile = results["monitor"].get("save_xml")
        if xmlfile:
            ns3_lib.save_monitor_xmldata(monitor_info, xmlfile)

    for plot in config["results"].get("plots", []):
        available_plots = ns3_lib.get_available_plots()
        assert (plot["type"] in available_plots), \
            "Plot type '%s' not found, available: %s" % \
            (plot["type"], ", ".join(available_plots.keys()))
        plot_func = available_plots[plot["type"]]
        plot_kwargs = filter_dict_by_keys(plot, ["type"])
        plot_func(monitor_info, **plot_kwargs)