示例#1
0
def main(argv):
   c_debug = 0
   c_all = 0
   portlist = []

   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) < 1:
      helptext()

   ip_address = args[0]

   if len(args) == 1:
      c_all = 1
   else:
      portlist = args[1:]

   xm = XenaScriptTools(ip_address)
   if c_debug:
       xm.debugOn()
   xm.haltOn()

   xm.LogonSetOwner("xena", "s_reset")
     
   # Now for Module
   modules = xm.Send("c_remoteportcounts ?").split()

   if c_all:   
      for i in range(len(modules)-1):
         ports = int(modules[i+1])
         if ports != 0:
            for port in range(ports):
               portlist.append( str(i) + "/" + str(port))

   print "The following ports will be reset"
   print portlist

   xm.PortReserve(portlist)
   xm.PortReset(portlist)
   xm.PortRelease(portlist)
示例#2
0
def main(argv):
   c_debug = 0
   c_res = 0

   try:
      opts, args = getopt.getopt(sys.argv[1:], "dhr")
   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 ("-r"):
         c_res = 1

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

   ip_address = args[0]
   if arglen > 1:
      portlist = args[1:]
   else:
      portlist = []

   xm    = XenaScriptTools(ip_address)

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

   xm.Logon("xena")

   if arglen == 1:
      modules = xm.Send("c_remoteportcounts ?").split()

      for i in range(len(modules)-1):
         ports = int(modules[i+1])
         if ports != 0:
            for port in range(ports):
               portlist.append( str(i) + "/" + str(port))

   if c_res:
      printReservations(xm, portlist)
   else:
      printPortStates(xm, portlist)
示例#3
0
def main(argv):

   if len(argv) != 4:
      sys.stderr.write("Usage: %s IPaddr port nb_pkts\n" % (argv[0]))
      return 1

   ip_address = argv[1]
   port = argv[2] 
   n =  int(argv[3])

   xm    = XenaScriptTools(ip_address)
   #xm.debugOn()
   xm.haltOn()

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

   xm.PortGetPackets(port, n) 
示例#4
0
def main(argv):
    c_debug = 0
    c_res = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "dhr")
    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 ("-r"):
            c_res = 1

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

    ip_address = args[0]
    if arglen > 1:
        portlist = args[1:]
    else:
        portlist = []

    xm = XenaScriptTools(ip_address)

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

    xm.Logon("xena")

    if arglen == 1:
        modules = xm.Send("c_remoteportcounts ?").split()

        for i in range(len(modules) - 1):
            ports = int(modules[i + 1])
            if ports != 0:
                for port in range(ports):
                    portlist.append(str(i) + "/" + str(port))

    if c_res:
        printReservations(xm, portlist)
    else:
        printPortStates(xm, portlist)
示例#5
0
def main(argv):
    c_debug = 0
    c_what = "restart"

    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) != 1 and len(args) != 2:
        helptext()

    ip_address = args[0]
    if len(args) == 2:
        c_what = "poweroff"

    xm = XenaScriptTools(ip_address)

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

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

    xm.Send("C_RESERVATION relinquish")
    xm.Send("C_RESERVATION reserve")

    print "====================================="
    xm.SendExpectOK("C_DOWN  -1480937026 " + c_what)

    print "DONE"
    print "===================================="
示例#6
0
def main(argv):

    if len(argv) != 4:
        sys.stderr.write("Usage: %s IPaddr port nb_pkts\n" % (argv[0]))
        return 1

    ip_address = argv[1]
    port = argv[2]
    n = int(argv[3])

    xm = XenaScriptTools(ip_address)
    #xm.debugOn()
    xm.haltOn()

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

    xm.PortGetPackets(port, n)
示例#7
0
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"
示例#8
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_ETH_RX_COUNTERS ?")
   print prx
   ptx = xm.Send(port + " P4_ETH_TX_COUNTERS ?")
   print ptx
   print "\n==TCP GOODPUT======================="
   for cg in cgs:
      res = xm.Send(port + " P4G_TCP_TX_PAYLOAD_COUNTERS  [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_RX_PAYLOAD_COUNTERS [" + cg + "] ?")
      print res
   print "\n==CONNECTION TIMES=================="
   for cg in cgs:
      res = xm.Send(port + " P4G_TCP_ESTABLISH_HIST [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_CLOSE_HIST [" + cg + "] ?")
      print res
   print
示例#9
0
def main(argv):
    c_debug = 0
    c_owner = "s_ipv6"
    c_v4 = 0
    c_conns = "1"
    c_cap = 0
    c_tc = "0x00"
    c_fl = "0x00000000"
    c_gw = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "dh4cgn:f:t:")
    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 ("-g"):
            c_gw = 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 ("-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]

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

    for port in ports:
        xm.SendExpectOK(port + " P4E_ALLOCATE 2")
        xm.SendExpectOK(port + " P4G_CREATE [0]")
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [0] NONE")
        if c_cap:
            xm.SendExpectOK(port + "P4_CAPTURE ON")

        if c_v4:
            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")
        else:
            xm.SendExpectOK(port + " P4G_IP_VERSION [0] IPV6")
            xm.SendExpectOK(port + " P4G_IPV6_TRAFFIC_CLASS [0] " + c_tc)
            xm.SendExpectOK(port + " P4G_IPV6_FLOW_LABEL [0] " + c_fl)
            xm.SendExpectOK(
                port +
                " P4G_IPV6_CLIENT_RANGE [0] 0xaa01aa02aa03aa04aa05aa06aa07aa08 "
                + c_conns + " 40000 1 65535")
            xm.SendExpectOK(
                port +
                " P4G_IPV6_SERVER_RANGE [0] 0xbb01bb02bb03bb04bb05bb06bb07bb08 1 50000 1"
            )

    if c_gw:
        xm.SendExpectOK(client + " P4G_L2_USE_GW [0] YES")
        xm.SendExpectOK(server + " P4G_L2_USE_GW [0] YES")
        xm.SendExpectOK(
            client +
            " P4G_L2_IPV6_GW [0] 0x00000000000000000000000000000000 0x111111111111"
        )
        xm.SendExpectOK(
            server +
            " P4G_L2_IPV6_GW [0] 0x00000000000000000000000000000000 0x222222222222"
        )

    xm.SendExpectOK(server + " P4G_ROLE [0] server")
    xm.PortAddLoadProfile(ports, 0, LOADPROFILE, "msecs")

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

    print "sleeping 8"
    time.sleep(8)

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

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

    print "DONE"
示例#10
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)
示例#11
0
def main():
    global ports
    c_res = 5
    c_nat = 0
    c_pe = 2
    c_debug = 0
    c_arp = 0
    c_ipver = 4
    s_ipver = "IPv4"

    cg_id = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "46adhr:pe:",
                                   ["nat", "pkteng=", "arp"])
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-r"):
            c_res = int(arg)
        elif opt in ("-n", "--nat"):
            c_nat = 1
        elif opt in ("-a", "--arp"):
            c_arp = 1
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-6"):
            c_ipver = 6
            s_ipver = "IPv6"
        elif opt in ("-4"):
            c_ipver = 4
            s_ipver = "IPv4"
        elif opt in ("-e", "--pkteng"):
            c_pe = int(arg)

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

    ports.append(args[5])
    ports.append(args[6])

    ip_address = args[0]
    nip = int(args[1])
    nprt = int(args[2])
    n = nip * nprt
    ru_max = max(int(args[3]), int(args[4]))
    ru_min = min(int(args[3]), int(args[4]))
    rd_max = ru_max
    rd_min = ru_min

    print "==CONFIGURATION==========================================="
    print "CFG Ports:       " + " ".join(ports)
    print "CFG Connections: " + str(n)
    print "CFG IPversion:   " + s_ipver
    print "CFG NAT:       " + str(c_nat)
    print "CFG Prerun arp:  " + str(c_arp)
    print "CFG Resolution:  " + str(c_res)
    print "CFG Pkteng/Port: " + str(c_pe)
    print "CFG Debug:       " + str(c_debug)
    print

    xm = XenaScriptTools(ip_address)
    if c_debug:
        xm.debugOn()
    xm.haltOn()

    print "==PREPARATION==========================================="
    xm.Comment("Preparation")

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

    if c_ipver == 6:
        CLIENT_RANGE = "0xaa01aa02aa03aa04aa05aa060a000001 " + str(
            nip) + " 10000 " + str(nprt) + " 65535"
        SERVER_RANGE = "0xbb01bb02bb03bb04bb05bb06bb07bb08 1 80 1"
    else:
        CLIENT_RANGE = "10.0.1.2 " + str(nip) + " 10000 " + str(
            nprt) + " 65535"
        SERVER_RANGE = "10.0.0.1 1 80 1"

    xm.PortAddConnGroup(ports, cg_id, CLIENT_RANGE, SERVER_RANGE, c_ipver)

    xm.PortRole(ports[1], cg_id, "client")
    xm.PortRole(ports[0], cg_id, "server")
    if c_nat:
        xm.SendExpectOK(ports[0] + " P4G_NAT [{0}] on".format(cg_id))

    xm.PortAllocatePE(ports, str(c_pe))

    for port in ports:
        #xm.SendExpectOK(port + " P4G_TCP_SYN_RTO [1] 10000 1 3")
        ##xm.SendExpectOK(port + " P4G_TCP_RTO [1] static 10000 1 3")
        if c_arp:
            xm.SendExpectOK(port +
                            " P4G_L2_USE_ADDRESS_RES [{0}] YES".format(cg_id))
        xm.SendExpectOK(port + " P4G_LP_TIME_SCALE [{0}] msec".format(cg_id))
        xm.SendExpectOK(port +
                        " P4G_TEST_APPLICATION [{0}] NONE".format(cg_id))

    print "==EXECUTION==========================================="
    xm.Comment("Fast limit")

    print "== Phase 1: Fast Limit   ==             - Ramp up   %d CPS (%s ms)" % (
        n * 1000 / ru_min, ru_min)
    print "                                          Ramp down %d CPS (%d ms)" % (
        n * 1000 / rd_min, rd_min)
    res = oneramp(xm, cg_id, ru_min, 2000, ru_min, n)

    if res[0] == 1:
        errexit("Max ramp up   (fastest ramp passed) - rerun")
    if res[1] == 1:
        errexit("Max ramp down (fastest ramp passed) - rerun")

    ru = ru_max
    rd = rd_max

    for i in range(1, 21):
        xm.Comment("Ramp Up - Iteration %2d" % (i))
        print "== Phase 2: Ramp Up - iteration %2d ==   - Ramp up   %d CPS (%d ms)" % (
            i, n * 1000 / ru, ru)
        print "                                          Ramp down %d CPS (%d ms)" % (
            n * 1000 / rd, rd)
        res = oneramp(xm, cg_id, ru, 2000, rd, n)

        if res[0] == 1:
            if res[1] == 1:
                rd_max = rd
            else:
                if rd == rd_max:
                    errexit("Max ramp down (slowest ramp failed)")
                rd_min = rd
            rd = (rd_max + rd_min) / 2
            ru_max = ru
        else:
            ru_min = ru
        ru = (ru_max + ru_min) / 2

        if (ru_max - ru_min) <= c_res:
            break

        print

    if (i == 20):
        errexit("Max Iterations reached")

    if ru_max == ru and res[0] == 0:
        errexit("Max ramp up (slowest ramp failed) - rerun")

    print
    for i in range(1, 21):
        xm.Comment("Ramp Down -Iteration %2d" % (i))
        print "== Phase 3: Ramp Down - iteration %2d == - Ramp down %d CPS (%d ms)" % (
            i, n * 1000 / rd, rd)

        res = oneramp(xm, cg_id, ru_max + 1000, 2000, rd, n)

        if (res[1] == 1):
            rd_max = rd
        else:
            rd_min = rd
        rd = (rd_max + rd_min) / 2

        if (rd_max - rd_min) <= c_res:
            break

        print

    xm.Comment("Done")
    if (i == 20):
        errexit("Status FAILED: Max iterations reached - rerun")

    if rd_max == rd and res[1] == 0:
        errexit("Max ramp down (slowest ramp failed) - rerun")

    xm.PortRelease(ports)

    print "==RESULT=================================================="
    print "Max ramp up    %d CPS (%d ms)" % (n * 1000 / ru_max, ru_max)
    print "Max ramp down  %d CPS (%d ms)" % (n * 1000 / rd_max, rd_max)
    print "=========================================================="
    print "Status PASSED"
示例#12
0
def main():
    global ports
    c_res   = 5
    c_nat = 0
    c_pe    = 2
    c_debug = 0
    c_arp   = 0
    c_ipver = 4
    s_ipver = "IPv4"
    
    cg_id = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "46adhr:pe:", ["nat", "pkteng=", "arp"])
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-r"):
            c_res = int(arg)
        elif opt in ("-n", "--nat"):
            c_nat = 1
        elif opt in ("-a", "--arp"):
            c_arp = 1
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-6"):
            c_ipver = 6
            s_ipver = "IPv6"
        elif opt in ("-4"):
            c_ipver = 4
            s_ipver = "IPv4"
        elif opt in ("-e", "--pkteng"):
            c_pe = int(arg)

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

    ports.append(args[5])
    ports.append(args[6])



    ip_address = args[0]
    nip = int(args[1])
    nprt= int(args[2])
    n   = nip*nprt
    ru_max = max(int(args[3]), int(args[4]))
    ru_min = min(int(args[3]), int(args[4]))
    rd_max = ru_max
    rd_min = ru_min

    print "==CONFIGURATION==========================================="
    print "CFG Ports:       " + " ".join(ports)
    print "CFG Connections: " + str(n)
    print "CFG IPversion:   " + s_ipver
    print "CFG NAT:       " + str(c_nat)
    print "CFG Prerun arp:  " + str(c_arp)
    print "CFG Resolution:  " + str(c_res)
    print "CFG Pkteng/Port: " + str(c_pe)
    print "CFG Debug:       " + str(c_debug)
    print

    xm = XenaScriptTools(ip_address)
    if c_debug:
        xm.debugOn()
    xm.haltOn()

    print "==PREPARATION==========================================="
    xm.Comment("Preparation")

    xm.LogonSetOwner("xena", "s_bisect")
    xm.PortReserve(ports)
    xm.PortReset(ports)
    
    if c_ipver == 6:
       CLIENT_RANGE = "0xaa01aa02aa03aa04aa05aa060a000001 " + str(nip) +" 10000 " + str(nprt) + " 65535"
       SERVER_RANGE = "0xbb01bb02bb03bb04bb05bb06bb07bb08 1 80 1"
    else:
       CLIENT_RANGE = "10.0.1.2 " + str(nip) +" 10000 " + str(nprt) + " 65535"
       SERVER_RANGE = "10.0.0.1 1 80 1"
    
    xm.PortAddConnGroup(ports, cg_id, CLIENT_RANGE, SERVER_RANGE, c_ipver)

    xm.PortRole(ports[1], cg_id, "client")
    xm.PortRole(ports[0], cg_id, "server")
    if c_nat:
       xm.SendExpectOK(ports[0] + " P4G_NAT [{0}] on".format(cg_id))

    xm.PortAllocatePE(ports, str(c_pe))
    
    for port in ports:
       #xm.SendExpectOK(port + " P4G_TCP_SYN_RTO [1] 10000 1 3")
       ##xm.SendExpectOK(port + " P4G_TCP_RTO [1] static 10000 1 3")
       if c_arp:
          xm.SendExpectOK(port + " P4G_L2_USE_ADDRESS_RES [{0}] YES".format(cg_id))
       xm.SendExpectOK(port + " P4G_LP_TIME_SCALE [{0}] msec".format(cg_id))
       xm.SendExpectOK(port + " P4G_TEST_APPLICATION [{0}] NONE".format(cg_id))

    print "==EXECUTION==========================================="
    xm.Comment("Fast limit")

    print "== Phase 1: Fast Limit   ==             - Ramp up   %d CPS (%s ms)" % (n*1000/ru_min, ru_min)
    print "                                          Ramp down %d CPS (%d ms)" % (n*1000/rd_min, rd_min)
    res = oneramp(xm, cg_id, ru_min, 2000, ru_min, n)

    if res[0] == 1:
        errexit("Max ramp up   (fastest ramp passed) - rerun")
    if res[1] == 1:
        errexit("Max ramp down (fastest ramp passed) - rerun")

    ru = ru_max 
    rd = rd_max 
 
    for i in range(1, 21):
        xm.Comment("Ramp Up - Iteration %2d" % (i))
        print "== Phase 2: Ramp Up - iteration %2d ==   - Ramp up   %d CPS (%d ms)" % (i, n*1000/ru, ru)
        print "                                          Ramp down %d CPS (%d ms)" % (   n*1000/rd, rd)
        res = oneramp(xm, cg_id, ru, 2000, rd, n)
   
        if res[0] == 1:
            if res[1] == 1:
                rd_max = rd
            else:
                if rd == rd_max:
                    errexit("Max ramp down (slowest ramp failed)")
                rd_min = rd
            rd = (rd_max + rd_min)/2
            ru_max = ru
        else:
            ru_min = ru
        ru = (ru_max + ru_min)/2

        if  (ru_max - ru_min) <= c_res :
            break;

        print 

    if (i == 20):
        errexit("Max Iterations reached")

    if ru_max == ru and res[0] == 0:
        errexit("Max ramp up (slowest ramp failed) - rerun")

    print
    for i in range(1, 21):
        xm.Comment("Ramp Down -Iteration %2d" % (i))
        print "== Phase 3: Ramp Down - iteration %2d == - Ramp down %d CPS (%d ms)" % (i , n*1000/rd, rd)

        res = oneramp(xm, cg_id, ru_max + 1000, 2000, rd, n)
   
        if (res[1] == 1):
            rd_max = rd
        else:
            rd_min = rd
        rd = (rd_max + rd_min)/2

        if (rd_max - rd_min) <= c_res :
            break;

        print 

    xm.Comment("Done")
    if (i == 20):
        errexit("Status FAILED: Max iterations reached - rerun")

    if rd_max ==  rd and res[1] == 0:
        errexit("Max ramp down (slowest ramp failed) - rerun")

    xm.PortRelease(ports)

    print "==RESULT=================================================="
    print "Max ramp up    %d CPS (%d ms)" % (n*1000/ru_max, ru_max)
    print "Max ramp down  %d CPS (%d ms)" % (n*1000/rd_max, rd_max)
    print "=========================================================="
    print "Status PASSED"
示例#13
0
def main():
   c_debug  = 0
   c_pe     = 2
   c_repeat = 0 
   c_conn   = 1000
   c_len    = 1460

   try:
      opts, args = getopt.getopt(sys.argv[1:], "hde:r:n:s:")
   except getopt.GetoptError:
      helptext()

   for opt, arg in opts:
       if opt == '-h':
          helptext()
       elif opt in ("-d"):
          c_debug = 1
       elif opt in ("-e"):
          c_pe = int(arg)
       elif opt in ("-r"):
          c_repeat = int(arg)
       elif opt in ("-n"):
          c_conn= int(arg)
       elif opt in ("-s"):
          c_len= int(arg)

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

   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

   xm    = XenaScriptTools(ip_address)
   if c_debug:
      xm.debugOn()
   xm.haltOn()

   lp = LoadProfile(0, 1000, 8000, 1000, "msecs")

   s_repeat = str(c_repeat)
   if c_repeat == 0:
      s_repeat = "INFINITE"

   print
   print "==CONFIGURATION==========================================="
   print "CFG connections : %d" % (c_conn)
   print "CFG server ports: " + " ".join(svrs)
   print "CFG client ports: " + " ".join(clis)
   print "CFG repeats     : %s" % (s_repeat)
   print "CFG payload size: %d" % (c_len)
   print "CFG duration    : %ds" % (lp.duration_sec())
   print "CFG pkteng      : %d" % (c_pe)
   print "CFG debug       : %d" % (c_debug)
   print

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

   xm.Comment("Logon, reserve and reset ports")
   xm.LogonSetOwner("xena", "s_reqres")
 
   xm.PortReserve(ports)
   xm.PortReset(ports)

   xm.Comment("Configure %d clients - total %d CC" % (c_conn, c_conn))
   xm.PortAddConnGroup(ports, 1, "10.0.1.1 " + str(c_conn) + " 40001 1", "11.0.1.1 1 80 1", 4)
   xm.PortRole(svrs, 1, "server")
   xm.PortRole(clis, 1, "client")
   xm.PortAddLoadProfile(ports, 1, lp.shape(), lp.timescale)

   xm.Comment("Configure application")
   for port in ports:
      xm.SendExpectOK(port + " P4E_ALLOCATE " + str(c_pe))
      xm.SendExpectOK(port + " P4G_TEST_APPLICATION [1] raw")
      xm.SendExpectOK(port + " P4G_RAW_TEST_SCENARIO [1] download")
      xm.SendExpectOK(port + " P4G_RAW_HAS_DOWNLOAD_REQ [1] yes")
      xm.SendExpectOK(port + " P4G_RAW_CLOSE_CONN [1] no")
      xm.SendExpectOK(port + " P4G_RAW_TX_DURING_RAMP [1] no no")
      xm.SendExpectOK(port + " P4G_RAW_TX_TIME_OFFSET [1] 100 100")
      if c_repeat:
         xm.SendExpectOK(port + " P4G_RAW_REQUEST_REPEAT [1] FINITE " + str(c_repeat))
      else:
         xm.SendExpectOK(port + " P4G_RAW_REQUEST_REPEAT [1] INFINITE 1")
      xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TYPE [1] fixed")
      xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TOTAL_LEN [1] FINITE " + str(c_len))
      xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_REPEAT_LEN [1] 1")

   xm.Comment("Configure Request")
   for port in ports:
      #xm.SendExpectOK(port + " p4g_raw_download_request [1] 86 0x474554202F706174682F66696C652E68746D6C20485454502F312E300D0A46726F6D3A20736F6D6575736572406A6D61727368616C6C2E636F6D0D0A557365722D4167656E743A2048545450546F6F6C2F312E300D0A")
      xm.SendExpectOK(port + " p4g_raw_download_request [1] 1 0xCC")

   xm.Comment("Configure Response")
   for port in svrs:
      xm.SendExpectOK(port + " P4G_RAW_PAYLOAD [1] 0 1 0xAA")
      if c_len > 1:
         xm.SendExpectOK(port + " P4G_RAW_PAYLOAD [1] " + str(c_len -1) + " 1 0xBB")

   for port in clis:
      xm.SendExpectOK(port + " P4G_RAW_RX_PAYLOAD_LEN [1] FINITE " + str(c_len))

   xm.Comment("Setup utilization and prepare for testrun")
   for port in clis:
      xm.SendExpectOK(port + " P4G_RAW_UTILIZATION [1] 999900")
   for port in svrs:
      xm.SendExpectOK(port + " P4G_RAW_UTILIZATION [1] 999900")

   xm.Comment("Prepare ports and run tests, start with servers")
   xm.PortPrepare(ports)

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

   xm.PortSetTraffic(svrs, "ON")
   xm.PortWaitState(svrs, "RUNNING")
   xm.PortSetTraffic(clis, "ON")

   waitsec = lp.duration_sec() + 2
   while waitsec != 0:
      acc = 0
      rate = 0
      for port in clis:
         trans = xm.Send(port + " p4g_app_transaction_counters [1] ?").split()
         acc  = int(trans[5])
         rate = int(trans[6])
         print "Port %s: Transactions: %12u, Rate: %12u " % (port, acc, rate)

      time.sleep(1)
      waitsec-=1

   for port in ports:
      xm.Send(port + " P4_TRAFFIC stop")

   #xm.PortRelease(ports)
   print "==DONE==================================================="


   return 0
示例#14
0
def main():

    c_debug = 0
    c_proxy = 0
    c_pe = 1
    c_lp = "0 5000 5000 5000"
    c_conns = 1000000
    c_util = 1000000
    c_tcp_wnd = 65535
    c_tcp_mss = 1460
    c_scenario = "BOTH"
    c_ipver = 4
    c_cap = 0
    c_tx_ramp = 0
    c_fill = "FIXED"
    c_vlan = 0
    c_vlan_tci = 0
    c_arp = 0

    try:
        opts, args = getopt.getopt(
            sys.argv[1:], "6hac:dptv:f:e:l:n:u:w:s:m:",
            ["proxy", "pkteng=", "loadprofile=", "scenario=", "mss="])
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-p", "--proxy"):
            c_proxy = 1
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-a"):
            c_arp = 1
        elif opt in ("-c"):
            c_cap = int(arg)
        elif opt in ("-e", "--pkteng"):
            c_pe = int(arg)
        elif opt in ("-l", "--loadprofile"):
            c_lp = arg
        elif opt in ("-s", "--scenario"):
            c_scenario = arg
        elif opt in ("-m", "--mss"):
            c_tcp_mss = int(arg)
        elif opt in ("-f"):
            c_fill = arg
        elif opt in ("-v"):
            c_vlan = 1
            c_vlan_tci = arg
        elif opt in ("-u"):
            c_util = int(arg)
        elif opt in ("-6"):
            c_ipver = 6
        elif opt in ("-t"):
            c_tx_ramp = 1
        elif opt in ("-n"):
            c_conns = int(arg)
        elif opt in ("-w"):
            c_tcp_wnd = int(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])

    duration = 0
    for dt in c_lp.split():
        duration = duration + int(dt)

    MSSWARN = ""
    if c_ipver == 6 and c_tcp_mss > 1440:
        MSSWARN = " <<< WARNING - MSS too large for IPv6 >>>"
    elif c_ipver == 4 and c_tcp_mss > 1460:
        MSSWARN = "<<< WARNING - MSS too large for IPv4 >>>"

    print
    print "==CONFIGURATION==========================================="
    print "CFG load profile: %s (duration %d)" % (c_lp, duration)
    print "CFG connections : %d" % (c_conns)
    print "CFG server ports: " + " ".join(svrs)
    print "CFG client ports: " + " ".join(clis)
    print "CFG IPversion   : %d" % (c_ipver)
    print "CFG Payload     : %s" % (c_fill)
    print "CFG Arp         : %d" % (c_arp)
    if c_vlan:
        print "CFG VLAN        : %s" % (c_vlan_tci)
    print "CFG proxy       : %d" % (c_proxy)
    print "CFG TCP window  : %d" % (c_tcp_wnd)
    print "CFG TCP MSS     : %s %s" % (c_tcp_mss, MSSWARN)
    print "CFG scenario    : %s" % (c_scenario)
    print "CFG utilization : %d" % (c_util)
    print "CFG pkteng      : %d" % (c_pe)
    if c_cap:
        print "CFG capture     : %d" % (c_cap)
    print "CFG debug       : %d" % (c_debug)

    ports = svrs + clis

    if c_scenario == "DOWNLOAD":
        ports_rx = clis
        ports_tx = svrs
    elif c_scenario == "BOTH":
        ports_rx = ports
        ports_tx = ports
    else:
        ports_rx = ""
        ports_tx = ""

    xm = XenaScriptTools(ip_address)
    if c_debug:
        xm.debugOn()
    xm.haltOn()

    LOADPROFILE = c_lp

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

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

    xm.PortReserve(ports)
    xm.PortReset(ports)

    if c_ipver == 6:
        CLIENT_RANGE = "0xaa01aa02aa03aa04aa05aa06aa07aa08 " + str(
            c_conns) + " 40000 1"
        SERVER_RANGE = "0xbb01bb02bb03bb04bb05bb06bb07bb08 1 50000 1"
    else:
        CLIENT_RANGE = "10.0.0.2 " + str(c_conns) + " 40000 1"
        SERVER_RANGE = "10.0.0.1 1 50000 1"

    xm.PortAddConnGroup(ports, 1, CLIENT_RANGE, SERVER_RANGE, c_ipver)
    xm.PortRole(clis, 1, "client")
    xm.PortRole(svrs, 1, "server")

    if c_proxy:
        for port in svrs:
            xm.SendExpectOK(port + " P4G_PROXY [1] on")

    for port in ports:
        xm.SendExpectOK(port + " P4_CLEAR_COUNTERS")
    nports = 0
    for port in ports:
        nports = nports + 1
        xm.SendExpectOK(port + " P4E_ALLOCATE " + str(c_pe))
        xm.SendExpectOK(port + " P4G_LP_TIME_SCALE [1] msec")
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [1] RAW")
        xm.SendExpectOK(port + " P4G_RAW_TEST_SCENARIO [1] " + c_scenario)
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TYPE [1] " + c_fill)
        xm.SendExpectOK(port + " P4G_RAW_HAS_DOWNLOAD_REQ [1] NO")
        xm.SendExpectOK(port + " P4G_RAW_CLOSE_CONN [1] NO")
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TOTAL_LEN [1] INFINITE 0")
        xm.SendExpectOK(port + " P4G_RAW_UTILIZATION [1] " + str(c_util))
        xm.SendExpectOK(port + " P4G_TCP_WINDOW_SIZE [1] " + str(c_tcp_wnd))
        xm.SendExpectOK(port + " P4G_TCP_MSS_VALUE [1] " + str(c_tcp_mss))
        if c_cap:
            xm.SendExpectOK(port + " P4_CAPTURE ON")

        if c_tx_ramp:
            xm.SendExpectOK(port + " P4G_RAW_TX_DURING_RAMP [1] YES YES")

        if c_vlan:
            xm.SendExpectOK(port + " P4G_VLAN_ENABLE [1] YES")
            xm.SendExpectOK(port + " P4G_VLAN_TCI [1] " + c_vlan_tci)

        if c_arp:
            xm.SendExpectOK(port + " P4G_L2_USE_ARP [1] YES")

    rxports = nports / 2
    txports = nports / 2

    xm.PortAddLoadProfile(ports, 1, LOADPROFILE, "msecs")

    xm.PortPrepare(ports)
    xm.PortSetTraffic(svrs, "on")
    xm.PortWaitState(svrs, "RUNNING")
    xm.PortSetTraffic(clis, "on")
    xm.PortWaitState(clis, "RUNNING")

    waitsec = 2 + int(duration) / 1000
    t0_milli = int(round(time.time() * 1000))
    rxbyte = 0
    txbyte = 0
    rxbps_max = 0
    txbps_max = 0
    while waitsec != 0:
        print "Waitsec: %d" % (waitsec)
        oldrx = rxbyte
        oldtx = txbyte
        rxbyte = 0
        txbyte = 0
        rxbps = 0
        txbps = 0
        for p in ports_rx:
            rx = xm.Send(p + " P4_RX_ETH_COUNTERS ?").split()
            rxbyte = rxbyte + int(rx[6])
            rxbps = rxbps + int(rx[4])
        for p in ports_tx:
            tx = xm.Send(p + " P4_TX_ETH_COUNTERS ?").split()
            txbyte = txbyte + int(tx[6])
            txbps = txbps + int(tx[4])

        if rxbps > rxbps_max:
            rxbps_max = rxbps

        if txbps > txbps_max:
            txbps_max = txbps

        print "Total Rx Bytes: %d [%8.2f GB] (%5.2f Gbps)" % (
            rxbyte, rxbyte / 1000000000.0, rxbps / 1000000000.0)
        print "Total Tx Bytes: %d [%8.2f GB] (%5.2f Gbps)" % (
            txbyte, txbyte / 1000000000.0, txbps / 1000000000.0)
        time.sleep(1)
        waitsec -= 1

    print "Stopping traffic..."
    for p in ports:
        xm.SendExpectOK(port + " P4_TRAFFIC stop")

    print "==STATS==================================================="
    est_conn = 0
    for p in ports:
        res = xm.Send(p + " P4G_TCP_STATE_TOTAL [1] ?")
        est_conn = est_conn + int(res.split()[9])

    # Be careful when changing text, as output is parsed by other scripts
    print "Requested %d connection, established %d" % (
        (rxports) * c_conns, est_conn / 2)

    getrtxstat(xm, ports)

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

    xm.PortRelease(ports)

    # Be careful when changing text, as output is parsed by other scripts
    print "Max average Rx rate %d (%5.2f Gbps)" % (rxbps_max,
                                                   rxbps_max / 1000000000.0)
    print "Max average Tx rate %d (%5.2f Gbps)" % (txbps_max,
                                                   txbps_max / 1000000000.0)
    print "==DONE===================================================="

    return 0
def main():
    c_debug = 0
    c_pe = 2
    c_repeat = 0
    c_conn = 1000

    cg_id = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hde:r:n:s:")
    except getopt.GetoptError:
        helptext()

    for opt, arg in opts:
        if opt == '-h':
            helptext()
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-e"):
            c_pe = int(arg)
        elif opt in ("-r"):
            c_repeat = int(arg)
        elif opt in ("-n"):
            c_conn = int(arg)
        elif opt in ("-s"):
            c_len = int(arg)

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

    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

    xm = XenaScriptTools(ip_address)
    if c_debug:
        xm.debugOn()
    xm.haltOn()

    lp = LoadProfile(0, 1000, 8000, 1000, "msecs")

    s_repeat = str(c_repeat)
    if c_repeat == 0:
        s_repeat = "INFINITE"

    print
    print "==CONFIGURATION==========================================="
    print "CFG connections : %d" % (c_conn)
    print "CFG server ports: " + " ".join(svrs)
    print "CFG client ports: " + " ".join(clis)
    print "CFG repeats     : %s" % (s_repeat)
    print "CFG duration    : %ds" % (lp.duration_sec())
    print "CFG pkteng      : %d" % (c_pe)
    print "CFG debug       : %d" % (c_debug)
    print

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

    xm.Comment("Logon, reserve and reset ports")
    xm.LogonSetOwner("xena", "s_reqres")

    xm.PortReserve(ports)
    xm.PortReset(ports)

    xm.Comment("Configure %d clients - total %d CC" % (c_conn, c_conn))
    xm.PortAddConnGroup(ports, cg_id, "10.0.1.1 " + str(c_conn) + " 40001 1",
                        "11.0.1.1 1 80 1", 4)
    xm.PortRole(svrs, cg_id, "server")
    xm.PortRole(clis, cg_id, "client")
    xm.PortAddLoadProfile(ports, cg_id, lp.shape(), lp.timescale)

    xm.Comment("Configure application")
    for port in ports:
        xm.SendExpectOK(port + " P4E_ALLOCATE " + str(c_pe))
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [{0}] RAW".format(cg_id))
        xm.SendExpectOK(port +
                        " P4G_RAW_TEST_SCENARIO [{0}] DOWNLOAD".format(cg_id))
        xm.SendExpectOK(port +
                        " P4G_RAW_HAS_DOWNLOAD_REQ [{0}] YES".format(cg_id))
        xm.SendExpectOK(port + " P4G_RAW_CLOSE_CONN [{0}] NONE".format(cg_id))
        xm.SendExpectOK(port +
                        " P4G_RAW_TX_DURING_RAMP [{0}] YES YES".format(cg_id))
        if c_repeat:
            xm.SendExpectOK(port +
                            " P4G_RAW_REQUEST_REPEAT [{0}] FINITE {1}".format(
                                cg_id, c_repeat))
        else:
            xm.SendExpectOK(
                port +
                " P4G_RAW_REQUEST_REPEAT [{0}] INFINITE 0".format(cg_id))
        xm.SendExpectOK(port +
                        " P4G_RAW_PAYLOAD_TYPE [{0}] fixed".format(cg_id))
        xm.SendExpectOK(
            port +
            " P4G_RAW_PAYLOAD_TOTAL_LEN [{0}] FINITE {1}".format(cg_id, c_len))
        xm.SendExpectOK(port +
                        " P4G_RAW_PAYLOAD_REPEAT_LEN [{0}] 1".format(cg_id))

    xm.Comment("Configure Request")
    request_content = b"GET / HTTP/1.1\r\nHost: www.myhost.com\r\n\r\n"
    len_req = str(len(request_content))
    request_hex = "0x" + binascii.hexlify(request_content).decode('utf_8')

    for port in ports:
        xm.SendExpectOK(port +
                        " P4G_RAW_DOWNLOAD_REQUEST [{0}] {1} {2}".format(
                            cg_id, len_req, request_hex))

    xm.Comment("Configure Response")
    response_content = b"HTTP/1.1 200 OK\r\nContent-Length: 1\r\nContent-Type: text/plain\r\n\r\nA\r\n"
    len_res = str(len(response_content))
    response_hex = "0x" + binascii.hexlify(response_content).decode('utf_8')
    for port in svrs:
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD [{0}] 0 {1} {2}".format(
            cg_id, len_res, response_hex))

    for port in clis:
        xm.SendExpectOK(
            port +
            " P4G_RAW_RX_PAYLOAD_LEN [{0}] FINITE {1}".format(cg_id, len_res))

    xm.Comment("Setup utilization and prepare for testrun")
    for port in clis:
        xm.SendExpectOK(port +
                        " P4G_RAW_UTILIZATION [{0}] 999900".format(cg_id))
    for port in svrs:
        xm.SendExpectOK(port +
                        " P4G_RAW_UTILIZATION [{0}] 999900".format(cg_id))

    xm.Comment("Prepare ports and run tests, start with servers")
    xm.PortPrepare(ports)

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

    xm.PortSetTraffic(svrs, "ON")
    xm.PortWaitState(svrs, "RUNNING")
    xm.PortSetTraffic(clis, "ON")

    waitsec = lp.duration_sec() + 2
    while waitsec != 0:
        acc = 0
        rate = 0
        for port in clis:
            trans = xm.Send(
                port +
                " p4g_app_transaction_counters [{0}] ?".format(cg_id)).split()
            acc = int(trans[5])
            rate = int(trans[6])
            print "Port %s: Transactions: %12u, Rate: %12u " % (port, acc,
                                                                rate)

        time.sleep(1)
        waitsec -= 1

    for port in ports:
        xm.Send(port + " P4_TRAFFIC stop")

    #xm.PortRelease(ports)
    print "==DONE==================================================="

    return 0
示例#16
0
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============================================"
示例#17
0
def main(argv):
    c_debug = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "dhn")
    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) != 1:
        helptext()

    ip_address = args[0]

    xm = XenaScriptTools(ip_address)

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

    xm.Logon("xena")

    # Start with CHASSIS
    s_serial = xm.Send("C_SERIALNO ?").split()[1]
    versionno = xm.Send("C_VERSIONNO ?").split()
    s_version1 = versionno[1]
    s_version2 = versionno[2]
    r_model = re.search('.*"(.*)"', xm.Send("C_MODEL ?"))
    s_model = r_model.group(1)

    # License stuff
    s_lic_pes = xm.Send("1 M4_LIC_PES ?").split()[2]
    s_lic_p1g = xm.Send("1 M4_LIC_PORTS_1G ?").split()[2]
    s_lic_p10g = xm.Send("1 M4_LIC_PORTS_10G ?").split()[2]
    s_lic_p40g = xm.Send("1 M4_LIC_PORTS_40G ?").split()[2]

    # proceed to MODULE
    r_m_status = re.search('.*"(.*)"', xm.Send(" 1 M4_SYSTEM_STATUS ?"))
    s_m_status = r_m_status.group(1)

    # if module is ok
    if (s_m_status == "OK"):
        s_m_serial = xm.Send("1 M_SERIALNO ?").split()[2]
        s_m_version = xm.Send("1 M_VERSIONNO ?").split()[2]

        r_m_version = re.search('.*"(.*) (.*)"', xm.Send("1 M4_VERSIONNO ?"))
        s_m_verstr = r_m_version.group(1)
        s_m_build = r_m_version.group(2)

        s_m_sysid = xm.Send(" 1 M4_SYSTEMID ?").split()[2]

    print
    print "Date:                   %s" % (datetime.datetime.today())
    print "Chassis ip address:     %s" % (ip_address)
    print "Chassis model:          %s" % (s_model)
    print "Chassis serial number:  %s (0x%08x)" % (s_serial, int(s_serial))

    print "Chassis server version: %s" % (s_version1)
    print "Chassis driver version: %s" % (s_version2)

    print "Module serial number:   %s (0x%08x)" % (s_m_serial, int(s_m_serial))
    print "Module version number:  %s" % (s_m_version)
    print "Module version string:  %s" % (s_m_verstr)
    print "Module status:          %s" % (s_m_status)
    print "Module system id:       %s" % (s_m_sysid)

    print "Licensed PE's:          %s" % (s_lic_pes)
    print "Licensed 1G ports:      %s" % (s_lic_p1g)
    print "Licensed 10G ports:     %s" % (s_lic_p10g)
    print "Licensed 40G ports:     %s" % (s_lic_p40g)
    print "Module build id:        %s" % (s_m_build)
    print

    return 0
示例#18
0
def main():

   c_debug = 0
   c_nat = 0
   c_pe    = 1
   c_lp    = "0 5000 5000 5000"
   c_conns = 1000000
   c_util  = 1000000
   c_tcp_wnd  = 65535
   c_tcp_mss  = 1460
   c_scenario = "BOTH"
   c_ipver = 4
   c_cap = 0
   c_tx_ramp = 0
   c_fill = "FIXED"
   c_vlan = 0
   c_vlan_tci = 0
   c_arp = 0

   try:
      opts, args = getopt.getopt(sys.argv[1:], "6hac:dptv:f:e:l:n:u:w:s:m:", ["nat", "pkteng=", "loadprofile=", "scenario=", "mss="])
   except getopt.GetoptError:
      helptext()
      return

   for opt, arg in opts:
       if opt == '-h':
          helptext()
          return
       elif opt in ("-b", "--nat"):
          c_nat=1
       elif opt in ("-d"):
          c_debug=1
       elif opt in ("-a"):
          c_arp=1
       elif opt in ("-c"):
          c_cap= int(arg)
       elif opt in ("-e", "--pkteng"):
          c_pe = int(arg)
       elif opt in ("-l", "--loadprofile"):
          c_lp = arg
       elif opt in ("-s", "--scenario"):
          c_scenario = arg 
       elif opt in ("-m", "--mss"):
          c_tcp_mss = int(arg)
       elif opt in ("-f"):
          c_fill = arg
       elif opt in ("-v"):
          c_vlan = 1
          c_vlan_tci = arg
       elif opt in ("-u"):
          c_util=int(arg)
       elif opt in ("-6"):
          c_ipver = 6
       elif opt in ("-t"):
          c_tx_ramp = 1
       elif opt in ("-n"):
          c_conns = int(arg)
       elif opt in ("-w"):
          c_tcp_wnd = int(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])

   duration=0
   for dt in c_lp.split():
      duration = duration + int(dt)

   MSSWARN=""
   if c_ipver == 6 and c_tcp_mss > 1440:
      MSSWARN = " <<< WARNING - MSS too large for IPv6 >>>"
   elif c_ipver == 4 and c_tcp_mss > 1460:
      MSSWARN = "<<< WARNING - MSS too large for IPv4 >>>"

   print
   print "==CONFIGURATION==========================================="
   print "CFG load profile: %s (duration %d)" % (c_lp, duration)
   print "CFG connections : %d" % (c_conns)
   print "CFG server ports: " + " ".join(svrs)
   print "CFG client ports: " + " ".join(clis)
   print "CFG IPversion   : %d" % (c_ipver)
   print "CFG Payload     : %s" % (c_fill)
   print "CFG Arp         : %d" % (c_arp)
   if c_vlan:
      print "CFG VLAN        : %s" % (c_vlan_tci)
   print "CFG NAT       : %d" % (c_nat)
   print "CFG TCP window  : %d" % (c_tcp_wnd)
   print "CFG TCP MSS     : %s %s" % (c_tcp_mss, MSSWARN)
   print "CFG scenario    : %s" % (c_scenario)
   print "CFG utilization : %d" % (c_util)
   print "CFG pkteng      : %d" % (c_pe)
   if c_cap:
      print "CFG capture     : %d" % (c_cap)
   print "CFG debug       : %d" % (c_debug)

   ports = svrs + clis

   if c_scenario == "DOWNLOAD":
      ports_rx = clis
      ports_tx = svrs
   elif c_scenario == "BOTH":
      ports_rx = ports
      ports_tx = ports 
   else:
      ports_rx = ""
      ports_tx = ""

   xm    = XenaScriptTools(ip_address)
   if c_debug:
      xm.debugOn()
   xm.haltOn()

   LOADPROFILE = c_lp

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

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

   if c_ipver == 6:
      CLIENT_RANGE = "0xaa01aa02aa03aa04aa05aa06aa07aa08 " + str(c_conns) +" 40000 1 65535"
      SERVER_RANGE = "0xbb01bb02bb03bb04bb05bb06bb07bb08 1 50000 1"
   else:
      CLIENT_RANGE = "10.0.0.2 " + str(c_conns) +" 40000 1 65535"
      SERVER_RANGE = "10.0.0.1 1 50000 1"

   xm.PortAddConnGroup(ports, 1, CLIENT_RANGE, SERVER_RANGE, c_ipver)
   xm.PortRole(clis, 0, "client")
   xm.PortRole(svrs, 0, "server")

   if c_nat:
      for port in svrs:
         xm.SendExpectOK(port + " P4G_NAT [0] on")

   for port in ports:
      xm.SendExpectOK(port + " P4_CLEAR_COUNTERS")
   nports=0
   for port in ports:
      nports = nports + 1
      xm.SendExpectOK(port + " P4E_ALLOCATE " + str(c_pe))
      xm.SendExpectOK(port + " P4G_LP_TIME_SCALE [0] msec")
      xm.SendExpectOK(port + " P4G_TEST_APPLICATION [0] RAW")
      xm.SendExpectOK(port + " P4G_RAW_TEST_SCENARIO [0] " + c_scenario)
      xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TYPE [0] " + c_fill)
      xm.SendExpectOK(port + " P4G_RAW_HAS_DOWNLOAD_REQ [0] NO")
      xm.SendExpectOK(port + " P4G_RAW_CLOSE_CONN [0] NO")
      xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TOTAL_LEN [0] INFINITE 0")
      xm.SendExpectOK(port + " P4G_RAW_UTILIZATION [0] " + str(c_util))
      xm.SendExpectOK(port + " P4G_TCP_WINDOW_SIZE [0] " + str(c_tcp_wnd))
      xm.SendExpectOK(port + " P4G_TCP_MSS_VALUE [0] "   + str(c_tcp_mss))
      if c_cap:
         xm.SendExpectOK(port + " P4_CAPTURE ON")

      if c_tx_ramp:
         xm.SendExpectOK(port + " P4G_RAW_TX_DURING_RAMP [0] YES YES")

      if c_vlan:
         xm.SendExpectOK(port + " P4G_VLAN_ENABLE [0] YES")
         xm.SendExpectOK(port + " P4G_VLAN_TCI [0] " + c_vlan_tci)

      if c_arp:
         xm.SendExpectOK(port + " P4G_L2_USE_ARP [0] YES")

   rxports = nports/2
   txports = nports/2


   xm.PortAddLoadProfile(ports, 1, LOADPROFILE, "msecs")

   xm.PortPrepare(ports)
   xm.PortSetTraffic(svrs, "on")
   xm.PortWaitState(svrs, "RUNNING")
   xm.PortSetTraffic(clis, "on")
   xm.PortWaitState(clis, "RUNNING")

   waitsec = 2 + int(duration)/1000
   t0_milli = int(round(time.time() * 1000))
   rxbyte = 0
   txbyte = 0
   rxbps_max=0
   txbps_max=0
   while waitsec != 0:
      print "Waitsec: %d" % (waitsec)
      oldrx = rxbyte
      oldtx = txbyte
      rxbyte = 0
      txbyte = 0
      rxbps = 0
      txbps = 0
      for p in ports_rx:
         rx = xm.Send(p + " P4_ETH_RX_COUNTERS ?").split()
         rxbyte = rxbyte + int(rx[6])
         rxbps  = rxbps  + int(rx[4])
      for p in ports_tx:
         tx = xm.Send(p + " P4_ETH_TX_COUNTERS ?").split()
         txbyte = txbyte + int(tx[6])
         txbps  = txbps  + int(tx[4])

      if rxbps > rxbps_max:
         rxbps_max = rxbps

      if txbps > txbps_max:
         txbps_max = txbps

      print "Total Rx Bytes: %d [%8.2f GB] (%5.2f Gbps)" % (rxbyte, rxbyte/1000000000.0, rxbps/1000000000.0)
      print "Total Tx Bytes: %d [%8.2f GB] (%5.2f Gbps)" % (txbyte, txbyte/1000000000.0, txbps/1000000000.0)
      time.sleep(1)
      waitsec-=1

   print "Stopping traffic..."
   for p in ports:
      xm.SendExpectOK(port + " P4_TRAFFIC stop")

   print "==STATS==================================================="
   est_conn=0
   for p in ports:
      res = xm.Send(p + " P4G_TCP_STATE_TOTAL [0] ?")
      est_conn = est_conn + int(res.split()[9])

   # Be careful when changing text, as output is parsed by other scripts
   print "Requested %d connection, established %d" % ((rxports)*c_conns, est_conn/2)

   getrtxstat(xm, ports)

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

   xm.PortRelease(ports)

   # Be careful when changing text, as output is parsed by other scripts
   print "Max average Rx rate %d (%5.2f Gbps)" % (rxbps_max, rxbps_max/1000000000.0)
   print "Max average Tx rate %d (%5.2f Gbps)" % (txbps_max, txbps_max/1000000000.0)
   print "==DONE===================================================="


   return 0
示例#19
0
def main(argv):
   c_debug = 0
   c_owner = "s_ipv6"
   c_v4 = 0
   c_conns = "1"
   c_cap = 0
   c_tc = "0x00"
   c_fl = "0x00000000"
   c_gw = 0

   try:
      opts, args = getopt.getopt(sys.argv[1:], "dh4cgn:f:t:")
   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 ("-g"):
         c_gw=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 ("-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]

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

   for port in ports:
     xm.SendExpectOK(port + " P4E_ALLOCATE 2")
     xm.SendExpectOK(port + " P4G_CREATE [0]")
     xm.SendExpectOK(port + " P4G_TEST_APPLICATION [0] NONE")
     if c_cap:
       xm.SendExpectOK(port + "P4_CAPTURE ON")

     if c_v4:
       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")
     else:
       xm.SendExpectOK(port + " P4G_IP_VERSION [0] IPV6")
       xm.SendExpectOK(port + " P4G_IPV6_TRAFFIC_CLASS [0] " + c_tc)
       xm.SendExpectOK(port + " P4G_IPV6_FLOW_LABEL [0] "    + c_fl)
       xm.SendExpectOK(port + " P4G_IPV6_CLIENT_RANGE [0] 0xaa01aa02aa03aa04aa05aa06aa07aa08 " + c_conns + " 40000 1 65535")
       xm.SendExpectOK(port + " P4G_IPV6_SERVER_RANGE [0] 0xbb01bb02bb03bb04bb05bb06bb07bb08 1 50000 1")


   if c_gw:
     xm.SendExpectOK(client + " P4G_L2_USE_GW [0] YES")
     xm.SendExpectOK(server + " P4G_L2_USE_GW [0] YES")
     xm.SendExpectOK(client + " P4G_L2_IPV6_GW [0] 0x00000000000000000000000000000000 0x111111111111")
     xm.SendExpectOK(server + " P4G_L2_IPV6_GW [0] 0x00000000000000000000000000000000 0x222222222222")

   xm.SendExpectOK(server + " P4G_ROLE [0] server")
   xm.PortAddLoadProfile(ports, 0, LOADPROFILE, "msecs")


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

   print "sleeping 8"
   time.sleep(8)

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

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

   print "DONE"
示例#20
0
def main(argv):
   c_debug = 0

   try:
      opts, args = getopt.getopt(sys.argv[1:], "dhn")
   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) != 1:
       helptext()

   ip_address = args[0]

   xm    = XenaScriptTools(ip_address)

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

   xm.Logon("xena")

   # Start with CHASSIS   
   s_serial    = xm.Send("C_SERIALNO ?").split()[1]
   versionno   = xm.Send("C_VERSIONNO ?").split()
   s_version1  = versionno[1]
   s_version2  = versionno[2]
   r_model     = re.search( '.*"(.*)"' , xm.Send("C_MODEL ?") )
   s_model     = r_model.group(1)

   # License stuff
   res = xm.Send("1 M4_LICENSE_INFO ?")
   s_lic_pes   = res.split()[2]
   s_lic_pes_inuse = res.split()[3]
   s_lic_port_type_1   = res.split()[4]
   s_lic_port_type_1_inuse   = res.split()[5]
   s_lic_port_type_2  = res.split()[6]
   s_lic_port_type_2_inuse  = res.split()[7]
   s_lic_port_type_3  = res.split()[8]
   s_lic_port_type_3_inuse  = res.split()[9]
   s_lic_port_type_4  = res.split()[10]
   s_lic_port_type_4_inuse  = res.split()[11]

   # proceed to MODULE
   r_m_status = re.search( '.*"(.*)"', xm.Send(" 1 M4_SYSTEM_STATUS ?") )
   s_m_status = r_m_status.group(1)

   # if module is ok
   if (s_m_status == "OK"):
      s_m_serial  = xm.Send("1 M_SERIALNO ?").split()[2]
      s_m_version = xm.Send("1 M_VERSIONNO ?").split()[2]

      r_m_version = re.search( '.*"(.*) (.*)"', xm.Send("1 M4_VERSIONNO ?") )
      s_m_verstr = r_m_version.group(1)
      s_m_build  = r_m_version.group(2)

      s_m_sysid  = xm.Send(" 1 M4_SYSTEMID ?").split()[2]

   print
   print "Date:                   %s" % (datetime.datetime.today())
   print "Chassis ip address:     %s" % (ip_address)
   print "Chassis model:          %s" % (s_model)
   print "Chassis serial number:  %s (0x%08x)" % (s_serial, int(s_serial))

   print "Chassis server version: %s" % (s_version1)
   print "Chassis driver version: %s" % (s_version2)

   print "Module serial number:   %s (0x%08x)" % (s_m_serial, int(s_m_serial))
   print "Module version number:  %s" % (s_m_version)
   print "Module version string:  %s" % (s_m_verstr)
   print "Module status:          %s" % (s_m_status)
   print "Module system id:       %s" % (s_m_sysid)

   print "Licensed PE's:                  %s (%s in use)" % (s_lic_pes, s_lic_pes_inuse)
   print "Licensed 1G/10G ports:          %s (%s in use)" % (s_lic_port_type_1, s_lic_port_type_1_inuse)
   print "Licensed 1G/2.5G/5G/10G ports:  %s (%s in use)" % (s_lic_port_type_2, s_lic_port_type_2_inuse)
   print "Licensed 1G/10G/25G ports:      %s (%s in use)" % (s_lic_port_type_3, s_lic_port_type_3_inuse)
   print "Licensed 40G ports:             %s (%s in use)" % (s_lic_port_type_4, s_lic_port_type_4_inuse)
   
   print "Module build id:        %s" % (s_m_build)
   print

   return 0
示例#21
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============================================"
示例#22
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============================================"
示例#23
0
def main(argv):
    c_debug = 0
    c_all = 0
    portlist = []

    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) < 1:
        helptext()

    ip_address = args[0]

    if len(args) == 1:
        c_all = 1
    else:
        portlist = args[1:]

    xm = XenaScriptTools(ip_address)
    if c_debug:
        xm.debugOn()
    xm.haltOn()

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

    # Now for Module
    modules = xm.Send("c_remoteportcounts ?").split()

    if c_all:
        for i in range(len(modules) - 1):
            ports = int(modules[i + 1])
            if ports != 0:
                for port in range(ports):
                    portlist.append(str(i) + "/" + str(port))

    print "The following ports will be reset"
    print portlist

    xm.PortReserve(portlist)
    xm.PortReset(portlist)
    xm.PortRelease(portlist)
示例#24
0
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"
示例#25
0
def main():
    c_debug = 0
    c_pe = 2
    c_repeat = 0
    c_conn = 1000
    c_len = 1460

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hde:r:n:s:")
    except getopt.GetoptError:
        helptext()

    for opt, arg in opts:
        if opt == '-h':
            helptext()
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-e"):
            c_pe = int(arg)
        elif opt in ("-r"):
            c_repeat = int(arg)
        elif opt in ("-n"):
            c_conn = int(arg)
        elif opt in ("-s"):
            c_len = int(arg)

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

    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

    xm = XenaScriptTools(ip_address)
    if c_debug:
        xm.debugOn()
    xm.haltOn()

    lp = LoadProfile(0, 1000, 8000, 1000, "msecs")

    s_repeat = str(c_repeat)
    if c_repeat == 0:
        s_repeat = "INFINITE"

    print
    print "==CONFIGURATION==========================================="
    print "CFG connections : %d" % (c_conn)
    print "CFG server ports: " + " ".join(svrs)
    print "CFG client ports: " + " ".join(clis)
    print "CFG repeats     : %s" % (s_repeat)
    print "CFG payload size: %d" % (c_len)
    print "CFG duration    : %ds" % (lp.duration_sec())
    print "CFG pkteng      : %d" % (c_pe)
    print "CFG debug       : %d" % (c_debug)
    print

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

    xm.Comment("Logon, reserve and reset ports")
    xm.LogonSetOwner("xena", "s_reqres")

    xm.PortReserve(ports)
    xm.PortReset(ports)

    xm.Comment("Configure %d clients - total %d CC" % (c_conn, c_conn))
    xm.PortAddConnGroup(ports, 1, "10.0.1.1 " + str(c_conn) + " 40001 1",
                        "11.0.1.1 1 80 1", 4)
    xm.PortRole(svrs, 1, "server")
    xm.PortRole(clis, 1, "client")
    xm.PortAddLoadProfile(ports, 1, lp.shape(), lp.timescale)

    xm.Comment("Configure application")
    for port in ports:
        xm.SendExpectOK(port + " P4E_ALLOCATE " + str(c_pe))
        xm.SendExpectOK(port + " P4G_TEST_APPLICATION [1] raw")
        xm.SendExpectOK(port + " P4G_RAW_TEST_SCENARIO [1] download")
        xm.SendExpectOK(port + " P4G_RAW_HAS_DOWNLOAD_REQ [1] yes")
        xm.SendExpectOK(port + " P4G_RAW_CLOSE_CONN [1] no")
        xm.SendExpectOK(port + " P4G_RAW_TX_DURING_RAMP [1] no no")
        xm.SendExpectOK(port + " P4G_RAW_TX_TIME_OFFSET [1] 100 100")
        if c_repeat:
            xm.SendExpectOK(port + " P4G_RAW_REQUEST_REPEAT [1] FINITE " +
                            str(c_repeat))
        else:
            xm.SendExpectOK(port + " P4G_RAW_REQUEST_REPEAT [1] INFINITE 1")
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TYPE [1] fixed")
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_TOTAL_LEN [1] FINITE " +
                        str(c_len))
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD_REPEAT_LEN [1] 1")

    xm.Comment("Configure Request")
    for port in ports:
        #xm.SendExpectOK(port + " p4g_raw_download_request [1] 86 0x474554202F706174682F66696C652E68746D6C20485454502F312E300D0A46726F6D3A20736F6D6575736572406A6D61727368616C6C2E636F6D0D0A557365722D4167656E743A2048545450546F6F6C2F312E300D0A")
        xm.SendExpectOK(port + " p4g_raw_download_request [1] 1 0xCC")

    xm.Comment("Configure Response")
    for port in svrs:
        xm.SendExpectOK(port + " P4G_RAW_PAYLOAD [1] 0 1 0xAA")
        if c_len > 1:
            xm.SendExpectOK(port + " P4G_RAW_PAYLOAD [1] " + str(c_len - 1) +
                            " 1 0xBB")

    for port in clis:
        xm.SendExpectOK(port + " P4G_RAW_RX_PAYLOAD_LEN [1] FINITE " +
                        str(c_len))

    xm.Comment("Setup utilization and prepare for testrun")
    for port in clis:
        xm.SendExpectOK(port + " P4G_RAW_UTILIZATION [1] 999900")
    for port in svrs:
        xm.SendExpectOK(port + " P4G_RAW_UTILIZATION [1] 999900")

    xm.Comment("Prepare ports and run tests, start with servers")
    xm.PortPrepare(ports)

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

    xm.PortSetTraffic(svrs, "ON")
    xm.PortWaitState(svrs, "RUNNING")
    xm.PortSetTraffic(clis, "ON")

    waitsec = lp.duration_sec() + 2
    while waitsec != 0:
        acc = 0
        rate = 0
        for port in clis:
            trans = xm.Send(port +
                            " p4g_app_transaction_counters [1] ?").split()
            acc = int(trans[5])
            rate = int(trans[6])
            print "Port %s: Transactions: %12u, Rate: %12u " % (port, acc,
                                                                rate)

        time.sleep(1)
        waitsec -= 1

    for port in ports:
        xm.Send(port + " P4_TRAFFIC stop")

    #xm.PortRelease(ports)
    print "==DONE==================================================="

    return 0
示例#26
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)