- c.disconnect()
-
-def print_help():
-
- print "args: [-h] -d <duration> -s <size of frame in bytes>"+\
- " [-r] <traffic rate with unit: %, mpps> "+\
- "--p1_src_mac <port1_src_mac> "+\
- "--p1_dst_mac <port1_dst_mac> "+\
- "--p1_src_start_ip <port1_src_start_ip> "+\
- "--p1_src_end_ip <port1_src_end_ip> "+\
- "--p1_dst_start_ip <port1_dst_start_ip> "+\
- "--p1_dst_end_ip <port1_dst_end_ip> "+\
- "--p2_src_mac <port2_src_mac> "+\
- "--p2_dst_mac <port2_dst_mac> "+\
- "--p2_src_start_ip <port2_src_start_ip> "+\
- "--p2_src_end_ip <port2_src_end_ip> "+\
- "--p2_dst_start_ip <port2_dst_start_ip> "+\
- "--p2_dst_end_ip <port2_dst_end_ip>"
-
-
-def main(argv):
-
- _duration = 10
- _frame_size = 64
- _rate = '1mpps'
- _traffic_options = {}
+ if async_start:
+ client.disconnect(stop_traffic=False, release_ports=True)
+ else:
+ client.disconnect()
+ print "rate={0}, totalReceived={1}, totalSent={2}, "\
+ "frameLoss={3}, latencyStream0(usec)={4}, "\
+ "latencyStream1(usec)={5}".format(rate, total_rcvd,\
+ total_sent, lost_a+lost_b, lat_a, lat_b)
+
+
+def print_error(msg):
+ """Print error message on stderr.
+
+ :param msg: Error message to print.
+ :type msg: string
+ :return: nothing
+ """
+
+ sys.stderr.write(msg+'\n')
+
+
+def parse_args():
+ """Parse arguments from cmd line.
+
+ :return: Parsed arguments.
+ :rtype ArgumentParser
+ """
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-d", "--duration", required=True, type=int,
+ help="Duration of traffic run")
+ parser.add_argument("-s", "--frame_size", required=True,
+ help="Size of a Frame without padding and IPG")
+ parser.add_argument("-r", "--rate", required=True,
+ help="Traffic rate with included units (%, pps)")
+ parser.add_argument("-6", "--use_IPv6", action="store_true",
+ default=False,
+ help="Use IPv6 traffic profile instead of IPv4")
+ parser.add_argument("--async", action="store_true",
+ default=False,
+ help="Non-blocking call of the script")
+ parser.add_argument("--latency", action="store_true",
+ default=False,
+ help="Add latency stream")
+ parser.add_argument("-w", "--warmup_time", type=int,
+ default=5,
+ help="Traffic warmup time in seconds, 0 = disable")
+# parser.add_argument("--p1_src_mac",
+# help="Port 1 source MAC address")
+# parser.add_argument("--p1_dst_mac",
+# help="Port 1 destination MAC address")
+ parser.add_argument("--p1_src_start_ip", required=True,
+ help="Port 1 source start IP address")
+ parser.add_argument("--p1_src_end_ip",
+ default=False,
+ help="Port 1 source end IP address")
+ parser.add_argument("--p1_dst_start_ip", required=True,
+ help="Port 1 destination start IP address")
+ parser.add_argument("--p1_dst_end_ip",
+ default=False,
+ help="Port 1 destination end IP address")
+# parser.add_argument("--p2_src_mac",
+# help="Port 2 source MAC address")
+# parser.add_argument("--p2_dst_mac",
+# help="Port 2 destination MAC address")
+ parser.add_argument("--p2_src_start_ip", required=True,
+ help="Port 2 source start IP address")
+ parser.add_argument("--p2_src_end_ip",
+ default=False,
+ help="Port 2 source end IP address")
+ parser.add_argument("--p2_dst_start_ip", required=True,
+ help="Port 2 destination start IP address")
+ parser.add_argument("--p2_dst_end_ip",
+ default=False,
+ help="Port 2 destination end IP address")
+
+ return parser.parse_args()
+
+
+def main():
+ """Main function."""
+
+ args = parse_args()
+
+ _duration = args.duration
+ _latency = args.latency
+ if args.frame_size.isdigit():
+ _frame_size = int(args.frame_size)
+ else:
+ _frame_size = args.frame_size
+ _latency = False
+ _rate = args.rate
+ _use_ipv6 = args.use_IPv6
+ _async_call = args.async
+ _warmup_time = args.warmup_time