コード例 #1
0
def main(argv):
   c_debug = 0

   try:
      opts, args = getopt.getopt(sys.argv[1:], "dh")
   except getopt.GetoptError:
      helptext()
      return

   for opt, arg in opts:
      if opt == '-h':
         helptext()
         return
      elif opt in ("-d"):
         c_debug=1

   if len(args) != 2:
      helptext()

   ip_address = args[0]
   port = args[1]

   xm    = XenaScriptTools(ip_address)

   if c_debug:
      xm.debugOn()
   xm.haltOn()

   xm.Logon("xena")

   cgs = xm.Send(port + " P4G_INDICES ?").split()[2:]
      
   print "\n==PACKET COUNTS====================="
   xm.PrintPortStatistics(port)
   prx = xm.Send(port + " P4_RX_ETH_COUNTERS ?")
   print prx
   ptx = xm.Send(port + " P4_TX_ETH_COUNTERS ?")
   print ptx
   print "\n==TCP GOODPUT======================="
   for cg in cgs:
      res = xm.Send(port + " P4G_TCP_TX_TOTAL_BYTES [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_TX_GOOD_BYTES [" + cg + "] ?")
      print res
   print "\n==PACKET SIZE DISTRIBUTION==========="
   res = xm.Send(port + " P4_RX_PACKET_SIZE ?")
   print res
   res = xm.Send(port + " P4_TX_PACKET_SIZE ?")
   print res
   print "\n==CONNECTION TIMES=================="
   for cg in cgs:
      res = xm.Send(port + " P4G_TCP_ESTABLISH_TIME [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_ESTABLISH_HIST [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_CLOSE_TIME [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_CLOSE_HIST [" + cg + "] ?")
      print res
   print
コード例 #2
0
def main(argv):
    c_debug = 0
    c_lp = "0 1000 5000 1000"
    c_conns = 1
    c_pe = 1
    c_cap = 0
    c_nat = 0
    c_noarp = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "dhl:n:e:", ["cap=", "noarp"])
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-e"):
            c_pe = arg
        elif opt in ("--cap"):
            c_cap = int(arg)
        elif opt in ("-n"):
            c_conns = int(arg)
        elif opt in ("--noarp"):
            c_noarp = 1
        elif opt in ("-l"):
            c_lp = arg

    arglen = len(args)
    if arglen != 6:
        helptext()
        return

    l47_server = args[0]
    cln_ip = args[1]
    svr_ip = args[2]
    nat_ip = args[3]
    svrp = args[4]
    clnp = args[5]

    if cln_ip == svr_ip:
        c_routed = 0
        c_topo = "switched"
    else:
        c_routed = 1
        c_topo = "routed"

    if nat_ip != "0.0.0":
        c_nat = 1
        c_topo = "nat"

    ports = [svrp] + [clnp]

    LOADPROFILE = c_lp

    xm = XenaScriptTools(l47_server)

    if c_debug:
        xm.debugOn()
    xm.haltOn()

    arpps = 1000 * c_conns / int(c_lp.split()[1])

    if c_nat:
        if c_routed:
            print "Combination of NAT and Routed NW not supported"
            return

    SVR_GW = svr_ip + ".1"
    SVR_IP = svr_ip + ".2"

    CLN_GW = cln_ip + ".1"
    CLN_IP = cln_ip + ".3"

    NAT_GW = nat_ip + ".1"
    NAT_IP = nat_ip + ".2"

    print "==CONFIGURATION==========================================="
    print "CFG connections     %d" % (c_conns)
    print "CFG loadprofile     %s" % (c_lp)
    print "CFG arp rate        %d" % (arpps)
    print "CFG Suppress ARP    %d" % (c_noarp)
    print "CFG debug           %d" % (c_debug)
    print "CFG ports           %s" % (" ".join(ports))
    print "CFG pkteng          %s" % (c_pe)
    print "CFG capture         %d" % (c_cap)
    print "CFG NW Topo         %s" % (c_topo)
    print "CFG cln_ip          %s" % (CLN_IP)
    print "CFG svr_ip          %s" % (SVR_IP)

    if c_nat:
        print "CFG NAT_IP          %s" % (NAT_IP)
        print "CFG NAT_GW          %s" % (NAT_GW)
    else:
        if c_routed:
            print "CFG svr_gw          %s" % (SVR_GW)
            print "CFG cln_gw          %s" % (CLN_GW)
    print

    print "==TEST EXECUTION=========================================="

    xm.Comment("Logon and Reserve")

    xm.LogonAndReserve(ports, "xena", "s_route")

    xm.PortReset(ports)

    CLI_RNG = CLN_IP + " " + str(c_conns) + " 10000 1"
    SVR_RNG = SVR_IP + " 1 80 1"
    NAT_RNG = NAT_IP + " 1 80 1"

    xm.Comment("Configure")
    xm.PortAddConnGroup(clnp, 1, CLI_RNG, SVR_RNG, 4)
    if c_nat:
        xm.PortAddConnGroup(svrp, 1, CLI_RNG, NAT_RNG, 4)
    else:
        xm.PortAddConnGroup(svrp, 1, CLI_RNG, SVR_RNG, 4)

    xm.PortRole(clnp, 1, "client")
    xm.PortRole(svrp, 1, "server")

    if c_topo == "routed":
        xm.SendExpectOK(clnp + " P4G_L2_GW [1] " + CLN_GW + " 0x010101010101")
        xm.SendExpectOK(clnp + " P4G_L2_USE_GW [1] YES")
        xm.SendExpectOK(svrp + " P4G_L2_GW [1] " + SVR_GW + " 0x020202020202")
        xm.SendExpectOK(svrp + " P4G_L2_USE_GW [1] YES")
        if not c_noarp:
            xm.SendExpectOK(clnp + " P4G_L2_USE_ARP [1] YES")
            xm.SendExpectOK(svrp + " P4G_L2_USE_ARP [1] YES")
    elif c_topo == "switched":
        if not c_noarp:
            xm.SendExpectOK(clnp + " P4G_L2_USE_ARP [1] YES")
            xm.SendExpectOK(svrp + " P4G_L2_USE_ARP [1] YES")
    elif c_topo == "nat":
        xm.SendExpectOK(svrp + " P4G_PROXY [1] ON")
        if not c_noarp:
            xm.SendExpectOK(clnp + " P4G_L2_USE_ARP [1] YES")
    else:
        print "Internal Error"
        return

    for port in ports:
        xm.SendExpectOK(port + " P4_ARP_REQUEST " + str(arpps) + " 1000 3")
        xm.SendExpectOK(port + " P4E_ALLOCATE " + str(c_pe))
        xm.PortAddLoadProfile(port, 1, LOADPROFILE, "msec")
        if c_cap:
            xm.SendExpectOK(port + " P4_CAPTURE ON")
        xm.SendExpectOK(port + " P4_CLEAR_COUNTERS")
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [1] NONE")

    t = 0
    for dt in c_lp.split():
        t = t + int(dt)
    slp = t / 1000 + 1

    xm.Comment("Prepare and Run")
    print "Traffic PREPARE"
    xm.PortPrepare(ports)
    xm.PortWaitState(ports, "PREPARE_RDY")

    print "Traffic PRERUN"
    xm.PortSetTraffic(ports, "prerun")
    xm.PortWaitState(ports, "PRERUN_RDY")

    print "Traffic ON (servers)"
    xm.PortSetTraffic(svrp, "on")
    xm.PortWaitState(svrp, "RUNNING")

    print "Traffic ON (clients)"
    xm.PortSetTraffic(clnp, "on")
    xm.PortWaitState(clnp, "RUNNING")

    print "Sleeping " + str(slp) + " seconds"
    time.sleep(slp)

    xm.Comment("Stop traffic, and collect statistics")
    print "Traffic STOP"
    xm.PortSetTraffic(ports, "stop")
    xm.PortWaitState(ports, "STOPPED")
    for port in ports:
        if c_cap:
            xm.SendExpectOK(port + " P4_CAPTURE OFF")

    print "Getting TCP stats"
    n_est = 0
    print "==SERVER======================================="
    stats = xm.Send(svrp + " P4G_TCP_STATE_TOTAL [1] ?")
    n_est = n_est + int(stats.split()[9])
    print stats
    print "==CLIENT======================================="
    stats = xm.Send(clnp + " P4G_TCP_STATE_TOTAL [1] ?")
    n_est = n_est + int(stats.split()[9])
    print stats
    print "Requested conns: %d, established: %d" % (c_conns * len(svrp),
                                                    n_est / 2)
    xm.PrintPortStatistics(ports)

    if c_cap:
        xm.Comment("Extract captured packets")
        print "==CAPTURE============================================"
        xm.PortGetPackets(ports, c_cap)
        for port in ports:
            xm.SendExpectOK(port + " P4_CAPTURE OFF")

    print "==DONE============================================"

    xm.PortStateOff(ports)

    xm.PortRelease(ports)
コード例 #3
0
def main(argv):
    c_debug = 0
    c_lp = "0 1000 5000 1000"
    c_conns = 1
    c_pe = 1
    c_rto = 0
    c_arp = 0
    c_cap = 0
    c_ipver = 4
    c_gw = 0

    cg_id = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "6adghl:n:e:t:",
                                   ["arp", "cap="])
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-6"):
            c_ipver = 6
        elif opt in ("-g"):
            c_gw = 1
        elif opt in ("-a", "--arp"):
            c_arp = 1
        elif opt in ("-e"):
            c_pe = arg
        elif opt in ("--cap"):
            c_cap = int(arg)
        elif opt in ("-n"):
            c_conns = int(arg)
        elif opt in ("-l"):
            c_lp = arg
        elif opt in ("-t"):
            c_rto = arg

    arglen = len(args)
    if arglen < 3 or (arglen - 1) % 2 != 0:
        helptext()
        return

    ip_address = args[0]

    # Build list of server and client ports
    for i in range(arglen - 1):
        if i % 2 == 0:
            svrs.append(args[i + 1])
        else:
            clis.append(args[i + 1])

    ports = svrs + clis

    LOADPROFILE = c_lp

    xm = XenaScriptTools(ip_address)

    if c_debug:
        xm.debugOn()
    xm.haltOn()

    arpps = 1000 * c_conns / int(c_lp.split()[1])

    print "==CONFIGURATION==========================================="

    print "CFG connections   %d" % (c_conns)
    print "CFG loadprofile   %s" % (c_lp)
    if c_arp:
        print "CFG arp           " + str(c_arp)
        print "CFG arp rate      %d" % (arpps)
    print "CFG debug         %d" % (c_debug)
    print "CFG ports         " + " ".join(ports)
    print "CFG pkteng        %s" % (c_pe)
    print "CFG capture       %d" % (c_cap)
    print

    if c_ipver == 6:
        #client_starting_ip = "0xaa01aa02aa03aa04aa05aa06aa07aa08"
        #server_starting_ip = "0xbb01bb02bb03bb04bb05bb06bb07bb08"
        #client_starting_port = "49152"
        #server_starting_port = "80"
        CLIENT_RANGE = "0xaa01aa02aa03aa04aa05aa06aa07aa08 " + str(
            c_conns) + " 49152 1 65535"
        SERVER_RANGE = "0xbb01bb02bb03bb04bb05bb06bb07bb08 1 80 1"
    else:
        #client_starting_ip = "10.0.0.2"
        #server_starting_ip = "11.0.0.2"
        #client_starting_port = "49152"
        #server_starting_port = "80"
        CLIENT_RANGE = "10.0.0.2 " + str(c_conns) + " 49152 1 65535"
        SERVER_RANGE = "11.0.0.2 1 80 1"

    print "==TEST EXECUTION=========================================="

    xm.LogonSetOwner("xena", "s_ramp")

    xm.PortReserve(ports)

    xm.PortReset(ports)

    xm.PortAddConnGroup(ports, cg_id, CLIENT_RANGE, SERVER_RANGE, c_ipver)
    xm.PortRole(clis, cg_id, "client")
    xm.PortRole(svrs, cg_id, "server")
    xm.PortAllocatePE(ports, str(c_pe))

    for port in ports:
        xm.SendExpectOK(port + " P4G_LP_TIME_SCALE [{0}] msec".format(cg_id))
        xm.PortAddLoadProfile(port, cg_id, LOADPROFILE, "msec")
        if c_cap:
            xm.SendExpectOK(port + " P4_CAPTURE ON")
        if c_arp:
            xm.SendExpectOK(port + " P4_ARP_REQUEST {0} 1000 3".format(arpps))
            xm.SendExpectOK(port +
                            " P4G_L2_USE_ADDRESS_RES [{0}] YES".format(cg_id))
            xm.SendExpectOK(port + " P4_ARP_REQUEST 1000 1000 1")
        if c_gw:
            xm.SendExpectOK(port + " P4G_L2_USE_GW [{0}] YES".format(cg_id))
        if c_rto != 0:
            xm.SendExpectOK(
                port + " P4G_TCP_SYN_RTO [{0}] {1} 32 3".format(cg_id, c_rto))
            xm.SendExpectOK(
                port +
                " P4G_TCP_RTO [{0}] static {1} 32 3".format(cg_id, c_rto))
        xm.SendExpectOK(port + " P4_CLEAR_COUNTERS")
        xm.SendExpectOK(port +
                        " P4G_TEST_APPLICATION [{0}] NONE".format(cg_id))

    t = 0
    for dt in c_lp.split():
        t = t + int(dt)
    slp = t / 1000 + 1

    print "Traffic PREPARE"
    xm.PortPrepare(ports)
    xm.PortWaitState(ports, "PREPARE_RDY")

    print "Traffic PRERUN"
    xm.PortSetTraffic(ports, "prerun")
    xm.PortWaitState(ports, "PRERUN_RDY")

    print "Traffic ON (servers)"
    xm.PortSetTraffic(svrs, "on")
    xm.PortWaitState(svrs, "RUNNING")

    print "Traffic ON (clients)"
    xm.PortSetTraffic(clis, "on")
    xm.PortWaitState(clis, "RUNNING")

    print "Sleeping " + str(slp) + " seconds"
    time.sleep(slp)

    print "Traffic STOP"
    xm.PortSetTraffic(ports, "stop")
    xm.PortWaitState(ports, "STOPPED")

    print "Getting TCP stats"
    n_est = 0
    print "==SERVER======================================="
    for port in svrs:
        stats = xm.Send(port + " P4G_TCP_STATE_TOTAL [{0}] ?".format(cg_id))
        n_est = n_est + int(stats.split()[9])
        print "CLOSED: {0}".format(int(stats.split()[5]))
        print "LISTEN: {0}".format(int(stats.split()[6]))
        print "SYN_SENT: {0}".format(int(stats.split()[7]))
        print "SYN_RCVD: {0}".format(int(stats.split()[8]))
        print "ESTABLISHED: {0}".format(int(stats.split()[9]))
        print "FIN_WAIT_1: {0}".format(int(stats.split()[10]))
        print "FIN_WAIT_2: {0}".format(int(stats.split()[11]))
        print "CLOSE_WAIT: {0}".format(int(stats.split()[12]))
        print "CLOSING: {0}".format(int(stats.split()[13]))
        print "LAST_ACK: {0}".format(int(stats.split()[14]))
        print "TIME_WAIT: {0}".format(int(stats.split()[15]))
    print "==CLIENT======================================="
    for port in clis:
        stats = xm.Send(port + " P4G_TCP_STATE_TOTAL [{0}] ?".format(cg_id))
        n_est = n_est + int(stats.split()[9])
        print "CLOSED: {0}".format(int(stats.split()[5]))
        print "LISTEN: {0}".format(int(stats.split()[6]))
        print "SYN_SENT: {0}".format(int(stats.split()[7]))
        print "SYN_RCVD: {0}".format(int(stats.split()[8]))
        print "ESTABLISHED: {0}".format(int(stats.split()[9]))
        print "FIN_WAIT_1: {0}".format(int(stats.split()[10]))
        print "FIN_WAIT_2: {0}".format(int(stats.split()[11]))
        print "CLOSE_WAIT: {0}".format(int(stats.split()[12]))
        print "CLOSING: {0}".format(int(stats.split()[13]))
        print "LAST_ACK: {0}".format(int(stats.split()[14]))
        print "TIME_WAIT: {0}".format(int(stats.split()[15]))
    print "Requested conns: %d, established: %d" % (c_conns * len(svrs),
                                                    n_est / 2)

    if c_cap:
        print "==CAPTURE============================================"
        xm.PortGetPackets(ports, c_cap)

    xm.PrintPortStatistics(ports)
    print "==DONE============================================"
コード例 #4
0
ファイル: Ipv4v6.py プロジェクト: stearny/xenascriptlibs
def main(argv):
    c_debug = 0
    c_owner = "s_ip64"
    c_conns = "1"
    c_cap = 0
    c_tc = "0x00"
    c_fl = "0x00000000"
    c_pe = 2

    try:
        opts, args = getopt.getopt(sys.argv[1:], "dhcn:f:t:e:")
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-c"):
            c_cap = 1
        elif opt in ("-4"):
            c_v4 = 1
        elif opt in ("-n"):
            c_conns = arg
        elif opt in ("-f"):
            c_fl = arg
        elif opt in ("-e"):
            c_pe = int(arg)
        elif opt in ("-t"):
            c_tc = arg

    if len(args) != 1:
        helptext()

    ip_address = args[0]

    xm = XenaScriptTools(ip_address)

    if c_debug:
        xm.debugOn()
    xm.haltOn()

    server = "1/0"
    client = "1/1"
    ports = [server, client]

    lp = LoadProfile(0, 2000, 2000, 2000, "msecs")

    xm.LogonSetOwner("xena", c_owner)
    xm.PortReserve(ports)
    xm.PortReset(ports)

    for port in ports:
        xm.SendExpectOK(port + " P4E_ALLOCATE " + str(c_pe))
        xm.SendExpectOK(port + " P4G_CREATE [0]")
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [0] RAW")
        xm.SendExpectOK(port + " P4G_RAW_TEST_SCENARIO [0] DOWNLOAD")
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TOTAL_LEN [0] INFINITE 1")
        if c_cap:
            xm.SendExpectOK(port + "P4_CAPTURE ON")

        xm.SendExpectOK(port + " P4G_CLIENT_RANGE [0] 10.1.10.2 " + c_conns +
                        " 40000 1 65535")
        xm.SendExpectOK(port + " P4G_SERVER_RANGE [0] 11.1.11.2 1 50000 1")

        xm.SendExpectOK(port + " P4G_CREATE [1]")
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [1] RAW")
        xm.SendExpectOK(port + " P4G_RAW_TEST_SCENARIO [1] DOWNLOAD")
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TOTAL_LEN [1] INFINITE 1")

        xm.SendExpectOK(port + " P4G_IP_VERSION [1] IPV6")
        xm.SendExpectOK(port + " P4G_IPV6_TRAFFIC_CLASS [1] " + c_tc)
        xm.SendExpectOK(port + " P4G_IPV6_FLOW_LABEL [1] " + c_fl)
        xm.SendExpectOK(
            port +
            " P4G_IPV6_CLIENT_RANGE [1] 0xaa01aa02aa03aa04aa05aa06aa07aa08 " +
            c_conns + " 40000 1 65535")
        xm.SendExpectOK(
            port +
            " P4G_IPV6_SERVER_RANGE [1] 0xbb01bb02bb03bb04bb05bb06bb07bb08 1 50000 1"
        )

    xm.SendExpectOK(server + " P4G_ROLE [0] server")
    xm.SendExpectOK(server + " P4G_ROLE [1] server")
    xm.PortAddLoadProfile(ports, 0, lp.shape(), lp.timescale)
    xm.PortAddLoadProfile(ports, 1, lp.shape(), lp.timescale)

    for port in ports:
        print xm.Send(port + " P4_STATE ?")

    xm.PortPrepare(ports)

    xm.PortSetTraffic(ports, "prerun")
    xm.PortWaitState(ports, "PRERUN_RDY")

    xm.PortSetTraffic(server, "on")
    xm.PortWaitState(server, "RUNNING")
    xm.PortSetTraffic(client, "on")
    xm.PortWaitState(client, "RUNNING")

    slp = lp.duration_sec() + 1
    for i in range(slp):
        print "Sleep %d/%d" % (i, slp)
        time.sleep(1)

    for port in ports:
        res = xm.Send(port + " P4G_TCP_STATE_TOTAL [0] ?")
        est_conn = int(res.split()[9])
        print "Port: %s, group [0] conns: %d" % (port, est_conn)
        res = xm.Send(port + " P4G_TCP_STATE_TOTAL [1] ?")
        est_conn = int(res.split()[9])
        print "Port: %s, group [1] conns: %d" % (port, est_conn)

    xm.PrintPortStatistics(ports)

    xm.PortSetTraffic(ports, "stop")
    xm.PortWaitState(ports, "STOPPED")
    for port in ports:
        if c_cap:
            xm.SendExpectOK(port + " P4_CAPTURE OFF")

    #xm.PortRelease(ports)
    print "DONE"
コード例 #5
0
ファイル: UDP.py プロジェクト: hyuxenanetworks/xenascriptlibs
def main(argv):
    c_debug = 0
    c_lp = "0 1000 5000 1000"
    c_conns = 1
    c_pe = 2
    c_rto = 0
    c_arp = 0
    c_cap = 0
    c_ipver = 4
    c_gw = 0

    cg_id = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "6adghl:n:e:t:",
                                   ["arp", "cap="])
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-6"):
            c_ipver = 6
        elif opt in ("-g"):
            c_gw = 1
        elif opt in ("-a", "--arp"):
            c_arp = 1
        elif opt in ("-e"):
            c_pe = arg
        elif opt in ("--cap"):
            c_cap = int(arg)
        elif opt in ("-n"):
            c_conns = int(arg)
        elif opt in ("-l"):
            c_lp = arg
        elif opt in ("-t"):
            c_rto = arg

    arglen = len(args)
    if arglen < 3 or (arglen - 1) % 2 != 0:
        helptext()
        return

    ip_address = args[0]

    # Build list of server and client ports
    for i in range(arglen - 1):
        if i % 2 == 0:
            svrs.append(args[i + 1])
        else:
            clis.append(args[i + 1])

    ports = svrs + clis

    LOADPROFILE = c_lp

    xm = XenaScriptTools(ip_address)

    if c_debug:
        xm.debugOn()
    xm.haltOn()

    arpps = 1000 * c_conns / int(c_lp.split()[1])

    print "==CONFIGURATION==========================================="
    print "CFG connections   %d" % (c_conns)
    print "CFG loadprofile   %s" % (c_lp)
    if c_arp:
        print "CFG arp           " + str(c_arp)
        print "CFG arp rate      %d" % (arpps)
    print "CFG debug         %d" % (c_debug)
    print "CFG ports         " + " ".join(ports)
    print "CFG pkteng        %s" % (c_pe)
    print "CFG capture       %d" % (c_cap)
    print

    if c_ipver == 6:
        CLIENT_RANGE = "0xaa01aa02aa03aa04aa05aa06aa07aa08 " + str(
            c_conns) + " 10000 1 65535"
        SERVER_RANGE = "0xbb01bb02bb03bb04bb05bb06bb07bb08 1 50000 1"
    else:
        CLIENT_RANGE = "10.0.0.2 " + str(c_conns) + " 100 1 65535"
        SERVER_RANGE = "17.0.0.1 1 5000 1"

    print "==TEST EXECUTION=========================================="

    xm.LogonSetOwner("xena", "s_ramp")

    xm.PortReserve(ports)

    xm.PortReset(ports)

    xm.PortAddConnGroup(ports, cg_id, CLIENT_RANGE, SERVER_RANGE, c_ipver)
    xm.PortRole(clis, cg_id, "client")
    xm.PortRole(svrs, cg_id, "server")
    xm.PortAllocatePE(ports, str(c_pe))

    for port in ports:
        # Clear port counters
        xm.SendExpectOK(port + " P4_CLEAR_COUNTERS")

        if c_cap:
            xm.SendExpectOK(port + " P4_CAPTURE ON")
        if c_arp:
            xm.SendExpectOK(port + " P4_ARP_REQUEST {0} 1000 3".format(arpps))
            xm.SendExpectOK(port +
                            " P4G_L2_USE_ADDRESS_RES [{0}] YES".format(cg_id))
            xm.SendExpectOK(port + " P4_ARP_REQUEST 1000 1000 1")
        if c_gw:
            xm.SendExpectOK(port + " P4G_L2_USE_GW [{0}] YES".format(cg_id))

        # UDP scenario
        xm.SendExpectOK(port + " P4G_L4_PROTOCOL [{0}] UDP".format(cg_id))

        # Load profile
        xm.PortAddLoadProfile(port, cg_id, LOADPROFILE, "msec")

        # UDP download scenario, server-to-client
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [{0}] RAW".format(cg_id))
        xm.SendExpectOK(port +
                        " P4G_RAW_TEST_SCENARIO [{0}] DOWNLOAD".format(cg_id))

        # UDP packet size = fixed, 800 bytes (excl. ETH, IP, UDP headers) max = 1472
        xm.SendExpectOK(
            port + " P4G_UDP_PACKET_SIZE_TYPE [{0}] INCREMENT".format(cg_id))
        xm.SendExpectOK(port +
                        " P4G_UDP_PACKET_SIZE_VALUE [{0}] 800".format(cg_id))

        # UDP packet size = increment, from 800 to 900 bytes (excl. ETH, IP, UDP headers) max = 1472
        #xm.SendExpectOK(port + " P4G_UDP_PACKET_SIZE_TYPE [{0}] FIXED".format(cg_id))
        #xm.SendExpectOK(port + " P4G_UDP_PACKET_SIZE_MINMAX [{0}] 800 900".format(cg_id))

        # UDP packet content = increment (e.g. 0x00 01 02 03 04 05 06 ...)
        xm.SendExpectOK(port +
                        " P4G_RAW_PAYLOAD_TYPE [{0}] INCREMENT".format(cg_id))

        # On the application layer there is infinite amount of data to transmit.
        xm.SendExpectOK(
            port + " P4G_RAW_PAYLOAD_TOTAL_LEN [{0}] INFINITE 0".format(cg_id))

        # Using 100% of the port speed.
        xm.SendExpectOK(port +
                        " P4G_RAW_UTILIZATION [{0}] 1000000".format(cg_id))

        xm.SendExpectOK(port +
                        " P4G_RAW_TX_DURING_RAMP [{0}] YES YES".format(cg_id))

        # One UDP stream lives for some time and then recreated using the same IP address. Repeat the process until the end of the test.
        #xm.SendExpectOK(port + " P4G_RAW_CONN_INCARNATION [{0}] IMMORTAL".format(cg_id))
        #xm.SendExpectOK(port + " P4G_RAW_CONN_LIFETIME [{0}] SECOND {1}".format(cg_id, int(c_lp.split()[1])))
        #xm.SendExpectOK(port + " P4G_RAW_CONN_REPETITIONS [{0}] INFINITE 0".format(cg_id))

        # UDP streams live until the end of the test
        xm.SendExpectOK(port +
                        " P4G_RAW_CONN_INCARNATION [{0}] ONCE".format(cg_id))

    t = 0
    for dt in c_lp.split():
        t = t + int(dt)
    slp = t / 1000 + 1

    print "Traffic PREPARE"
    xm.PortPrepare(ports)
    xm.PortWaitState(ports, "PREPARE_RDY")

    print "Traffic PRERUN"
    xm.PortSetTraffic(ports, "prerun")
    xm.PortWaitState(ports, "PRERUN_RDY")

    print "Traffic ON (servers)"
    xm.PortSetTraffic(svrs, "on")
    xm.PortWaitState(svrs, "RUNNING")

    print "Traffic ON (clients)"
    xm.PortSetTraffic(clis, "on")
    xm.PortWaitState(clis, "RUNNING")

    print "Waiting for " + str(slp) + " seconds"
    time.sleep(slp)

    print "Traffic STOP"
    xm.PortSetTraffic(ports, "stop")
    xm.PortWaitState(ports, "STOPPED")

    print "Getting UDP stats"
    n_est = 0
    print "==SERVER======================================="
    for port in svrs:
        stats = xm.Send(port + " P4G_UDP_STATE_TOTAL [{0}] ?".format(cg_id))
        n_est = n_est + int(stats.split()[5])
        print "CLOSED: {0}".format(int(stats.split()[5]))
        print "OPEN: {0}".format(int(stats.split()[6]))
        print "ACTIVE: {0}".format(int(stats.split()[7]))
    print "==CLIENT======================================="
    for port in clis:
        stats = xm.Send(port + " P4G_UDP_STATE_TOTAL [{0}] ?".format(cg_id))
        n_est = n_est + int(stats.split()[5])
        print "CLOSED: {0}".format(int(stats.split()[5]))
        print "OPEN: {0}".format(int(stats.split()[6]))
        print "ACTIVE: {0}".format(int(stats.split()[7]))
    print "Requested conns: %d, established: %d" % (c_conns * len(svrs),
                                                    n_est / 2)

    if c_cap:
        print "==CAPTURE============================================"
        xm.PortGetPackets(ports, c_cap)

    xm.PrintPortStatistics(ports)
    print "==DONE============================================"