-# Copyright (c) 2017 Cisco and/or its affiliates.
+# Copyright (c) 2019 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
import struct
from random import choice
-from string import letters
+from string import ascii_letters
-from trex_stl_lib.api import *
+from trex.stl.api import *
class TrafficStreamsBaseClass(object):
- """Base class for stream profiles for T-rex traffic generator.
- """
-
+ """Base class for stream profiles for T-rex traffic generator."""
STREAM_TABLE = {
'IMIX_v4': [
{'size': 60, 'pps': 28, 'isg': 0},
}
def __init__(self):
-
# Default value of frame size, it will be overwritten by the value of
# "framesize" parameter of "get_streams" method.
self.framesize = 64
:returns: The generated payload.
:rtype: str
"""
-
payload = ""
for _ in range(length):
- payload += choice(letters)
+ payload += choice(ascii_letters)
return payload
:raises: ValueError if start_ip is greater then end_ip.
:raises: socket.error if the IP addresses are not valid IPv6 addresses.
"""
-
try:
ip1 = socket.inet_pton(socket.AF_INET6, start_ip)
ip2 = socket.inet_pton(socket.AF_INET6, end_ip)
:returns: Traffic streams.
:rtype: list
"""
-
base_pkt_a, base_pkt_b, vm1, vm2 = self.define_packets()
# In most cases you will not have to change the code below:
# Direction 0 --> 1
pkt_a = STLPktBuilder(
- pkt=base_pkt_a / self._gen_payload(payload_len),
- vm=vm1)
+ pkt=base_pkt_a / self._gen_payload(payload_len), vm=vm1)
# Direction 1 --> 0
pkt_b = STLPktBuilder(
- pkt=base_pkt_b / self._gen_payload(payload_len),
- vm=vm2)
+ pkt=base_pkt_b / self._gen_payload(payload_len), vm=vm2)
# Packets for latency measurement:
# Direction 0 --> 1
pkt_lat_a = STLPktBuilder(
- pkt=base_pkt_a / self._gen_payload(payload_len))
+ pkt=base_pkt_a / self._gen_payload(payload_len), vm=vm1)
# Direction 1 --> 0
pkt_lat_b = STLPktBuilder(
- pkt=base_pkt_b / self._gen_payload(payload_len))
+ pkt=base_pkt_b / self._gen_payload(payload_len), vm=vm2)
# Create the streams:
# Direction 0 --> 1
:returns: Traffic streams.
:rtype: list
"""
-
self.framesize = kwargs['framesize']
return self.create_streams()