Beispiel #1
0
 def test_udp_ranges(self):
     # UDP is not set, expecting ignore of wrong UDP arguments
     STLHltStream(udp_src_port_mode = 'qwerqwer',
                  udp_src_port_count = 'weqwer',
                  udp_src_port = 'qwerqwer',
                  udp_dst_port_mode = 'qwerqwe',
                  udp_dst_port_count = 'sfgsdfg',
                  udp_dst_port = 'sdfgsdfg')
     # UDP is set, expecting fail due to wrong UDP arguments
     with self.assertRaises(Exception):
         STLHltStream(l4_protocol = 'udp',
                      udp_src_port_mode = 'qwerqwer',
                      udp_src_port_count = 'weqwer',
                      udp_src_port = 'qwerqwer',
                      udp_dst_port_mode = 'qwerqwe',
                      udp_dst_port_count = 'sfgsdfg',
                      udp_dst_port = 'sdfgsdfg')
     # generate it already with correct arguments
     test_stream = STLHltStream(l4_protocol = 'udp',
                                udp_src_port_mode = 'decrement',
                                udp_src_port_count = 10,
                                udp_src_port = 1234,
                                udp_dst_port_mode = 'increment',
                                udp_dst_port_count = 10,
                                udp_dst_port = 1234,
                                name = 'test_udp_ranges',
                                rate_percent = 20,)
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #2
0
 def test_pkt_len_by_l3length(self):
     test_stream = STLHltStream(l4_protocol = 'udp',
                                length_mode = 'random',
                                l3_length_min = 100,
                                l3_length_max = 400,
                                name = 'test_pkt_len_by_l3length')
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
 def test_tcp_ranges(self):
     test_stream = STLHltStream(tcp_src_port_mode = 'decrement',
                                tcp_src_port_count = 10,
                                tcp_dst_port_mode = 'random',
                                tcp_dst_port_count = 10,
                                tcp_dst_port = 1234,
                                name = 'stream-0')
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #4
0
 def test_ipv6_src_dst_ranges(self):
     test_stream = STLHltStream(name = 'test_ipv6_src_dst_ranges', l3_protocol = 'ipv6', l3_length = 150, l4_protocol = 'udp',
                                ipv6_src_addr = '1111:2222:3333:4444:5555:6666:7777:8888',
                                ipv6_dst_addr = '1111:1111:1111:1111:1111:1111:1111:1111',
                                ipv6_src_mode = 'increment', ipv6_src_step = 5, ipv6_src_count = 10,
                                ipv6_dst_mode = 'decrement', ipv6_dst_step = '1111:1111:1111:1111:1111:1111:0000:0011', ipv6_dst_count = 150,
                                )
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #5
0
 def test_tcp_ranges(self):
     test_stream = STLHltStream(tcp_src_port_mode = 'decrement',
                                tcp_src_port_count = 10,
                                tcp_dst_port_mode = 'random',
                                tcp_dst_port_count = 10,
                                tcp_dst_port = 1234,
                                name = 'test_tcp_ranges',
                                rate_pps = '2')
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
 def test_ip_ranges(self):
     test_stream = STLHltStream(ip_src_addr = '192.168.1.1',
                                ip_src_mode = 'increment',
                                ip_src_count = 5,
                                ip_dst_addr = '5.5.5.5',
                                ip_dst_count = 2,
                                ip_dst_mode = 'random',
                                name = 'stream-0')
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #7
0
 def test_vlan_multiple(self):
     # default frame size should be not enough
     with self.assertRaises(Exception):
         STLHltStream(vlan_id = [1, 2, 3, 4])
     test_stream = STLHltStream(name = 'test_vlan_multiple', frame_size = 100,
                                vlan_id = [1, 2, 3, 4], # can be either array or string separated by spaces
                                vlan_protocol_tag_id = '8100 0x8100')
     pkt_layers = test_stream.get_pkt_type()
     assert '802.1Q:' * 4 in pkt_layers, 'No four dot1q layers in packet: %s' % pkt_layers
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #8
0
 def test_vlan_vm(self):
     test_stream = STLHltStream(name = 'test_vlan_vm', frame_size = 100,
                                vlan_id = '1 2 1000 4 5',                          # 5 vlans
                                vlan_id_mode = 'increment fixed decrement random', # 5th vlan will be default fixed
                                vlan_id_step = 2,                                  # 1st vlan step will be 2, others - default 1
                                vlan_id_count = [4, 1, 10],                        # 4th independent on count, 5th will be fixed
                                )
     pkt_layers = test_stream.get_pkt_type()
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     assert '802.1Q:' * 5 in pkt_layers, 'No five dot1q layers in packet: %s' % pkt_layers
     self.golden_yaml = '''
 def test_ipv6_basic(self):
     # default frame size should be not enough
     with self.assertRaises(Exception):
         STLHltStream(l3_protocol = 'ipv6')
     # error should not affect
     STLHltStream(ipv6_src_addr = 'asdfasdfasgasdf')
     # error should affect
     with self.assertRaises(Exception):
         STLHltStream(l3_protocol = 'ipv6', ipv6_src_addr = 'asdfasdfasgasdf')
     test_stream = STLHltStream(name = 'test_ipv6_basic', l3_protocol = 'ipv6', length_mode = 'fixed', l3_length = 150, )
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #10
0
 def test_pkt_len_by_framesize(self):
     # just check errors, no compare to golden
     STLHltStream(length_mode = 'increment',
                  frame_size_min = 100,
                  frame_size_max = 3000)
     test_stream = STLHltStream(length_mode = 'decrement',
                                frame_size_min = 100,
                                frame_size_max = 3000,
                                name = 'test_pkt_len_by_framesize',
                                rate_bps = 1000)
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
 def test_hlt_basic(self):
     STLHltStream(mac_src = 'a0:00:01:::01', mac_dst = '0d 00 01 00 00 01',
                  mac_src2 = '{00 b0 01 00 00 01}', mac_dst2 = 'd0.00.01.00.00.01')
     with self.assertRaises(Exception):
         STLHltStream(mac_src2 = '00:00:00:00:00:0k')
     with self.assertRaises(Exception):
         STLHltStream(mac_dst2 = '100:00:00:00:00:00')
     # wrong encap
     with self.assertRaises(Exception):
         STLHltStream(l2_encap = 'ethernet_sdfgsdfg')
     # all default values
     test_stream = STLHltStream()
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
 def test_pkt_len_by_l3length(self):
     # l3_length_step should be 1
     with self.assertRaises(Exception):
         STLHltStream(l4_protocol = 'udp',
                      length_mode = 'random',
                      l3_length_min = 100,
                      l3_length_max = 400,
                      l3_length_step = 20)
     test_stream = STLHltStream(l4_protocol = 'udp',
                                length_mode = 'random',
                                l3_length_min = 100,
                                l3_length_max = 400,
                                name = 'stream-0')
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #13
0
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(
         #enable_auto_detect_instrumentation = '1', # not supported yet
         ip_dst_addr='192.168.3.3',
         ip_dst_count='1',
         ip_dst_mode='increment',
         ip_dst_step='0.0.0.1',
         ip_src_addr='192.168.2.3',
         ip_src_count='1',
         ip_src_step='0.0.0.1',
         l3_imix1_ratio=7,
         l3_imix1_size=68,
         l3_imix2_ratio=4,
         l3_imix2_size=570,
         l3_imix3_ratio=1,
         l3_imix3_size=1518,
         l3_protocol='ipv4',
         length_mode='imix',
         #mac_dst_mode = 'discovery', # not supported yet
         mac_src='00.00.c0.a8.02.03',
         mac_src2='00.00.c0.a8.03.03',
         pkts_per_burst='200000',
         rate_percent='0.75',
         transmit_mode='continuous',
         vlan_id='2',
         direction=direction,
     )
Beispiel #14
0
    def get_streams(self, direction=0, **kwargs):
        ipv4_address_step = '0.0.1.0'
        num_of_sessions_per_spoke = 1000
        ip_tgen_hub = '190.1.0.1'
        pkt_size = 128
        normaltrafficrate = 0.9
        vlan_id = 2
        tgen_dst_mac = '588d.090d.7310'

        return STLHltStream(
            l3_protocol='ipv4',
            l4_protocol='udp',
            transmit_mode='continuous',
            ip_src_addr='200.10.0.1',
            ip_src_mode='increment',
            ip_src_step=ipv4_address_step,
            ip_src_count=num_of_sessions_per_spoke,
            ip_dst_addr=ip_tgen_hub,
            ip_dst_mode='fixed',
            frame_size=pkt_size,
            rate_percent=normaltrafficrate,
            vlan_id=vlan_id,
            vlan_id_mode='increment',
            vlan_id_step=1,
            mac_src='0c00.1110.3101',
            mac_dst=tgen_dst_mac,
        )
Beispiel #15
0
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(
         name="stream_1",
         mode="create",
         port_handle=0,
         frame_size=64,
         l3_protocol="ipv4",
         ip_src_addr="10.0.0.1",
         ip_src_mode="increment",
         ip_src_count=254,
         ip_dst_addr="8.0.0.1",
         ip_dst_mode="increment",
         ip_dst_count=254,
         l4_protocol="udp",
         udp_dst_port=12,
         udp_src_port=1025,
         rate_pps=1339285,
         transmit_mode="multi_burst",
         pkts_per_burst=1,
         vlan_id=10,
         # TODO: fix
         # https://trex-tgn.cisco.com/youtrack/issue/trex-418
         #burst_loop_count = 1339285,
         burst_loop_count=100,
     )
Beispiel #16
0
    def get_streams(self, direction=0, **kwargs):
        ipv6_tgen_rtr = '2005:0:1::1'
        num_of_sessions_per_spoke = 1  # in given example is not passed forward, taking default
        ipv6_address_step = '0:0:0:1:0:0:0:0'
        ipv6_tgen_hub = '2005:10:1::1'
        normaltrafficrate = 0.9
        vlan_id = 0  # in given example is not passed forward, taking default
        tgen_dst_mac_rtr = '0026.cb0c.6040'

        return STLHltStream(
            l3_protocol='ipv6',
            l4_protocol='udp',
            ipv6_next_header=17,
            l3_length=200,
            transmit_mode='continuous',
            ipv6_src_addr=ipv6_tgen_rtr,
            ipv6_src_mode='increment',
            ipv6_src_count=num_of_sessions_per_spoke,
            ipv6_dst_step=ipv6_address_step,
            ipv6_dst_addr=ipv6_tgen_hub,
            ipv6_dst_mode='fixed',
            rate_percent=normaltrafficrate,
            vlan_id=vlan_id,
            vlan_id_mode='increment',
            vlan_id_step=1,
            mac_src='0c00.1110.3101',
            mac_dst=tgen_dst_mac_rtr,
        )
Beispiel #17
0
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(
         l3_protocol='ipv4',
         ip_src_addr='100.1.1.1',
         ip_src_mode='fixed',
         ip_src_count=1,
         ip_src_step='0.0.0.1',
         ip_dst_addr='200.1.1.1',
         ip_dst_mode='fixed',
         ip_dst_step='0.1.0.0',
         ip_dst_count=1,
         l3_length=474,
         ip_dscp=10,
         rate_bps=256000000,
         mac_src_mode='fixed',
         mac_src_step=1,
         mac_src_count=1,
         #mac_dst_mode = discovery  # not supported yet,
         mac_dst_step=1,
         mac_dst_count=1,
         #mac_src = [ip_to_mac 200.1.1.1] # not supported yet,
         #mac_src2 = [ip_to_mac = 100.1.1.1] # not supported yet,
         #mac_dst = [ip_to_mac 100.1.1.1] # not supported yet,
         #mac_dst2 = [ip_to_mac = 200.1.1.1] # not supported yet,
         vlan_id_mode='fixed fixed',
         vlan_id='200 100',
         vlan_id_count='1 1',
         vlan_id_step='1 1',
         vlan_user_priority='3 0',
         vlan_cfi='1 1',
         direction=direction,
     )
Beispiel #18
0
    def create_streams(self, direction=0):
        mac_dst_count = 10
        mac_src_count = 10
        pkts_per_burst = 10
        intf_traffic_dst_ip = '48.0.0.1'
        intf_traffic_src_ip = '16.0.0.1'

        return STLHltStream(
            #enable_auto_detect_instrumentation = 1, # not supported yet
            ip_dst_addr=intf_traffic_dst_ip,
            ip_dst_count=mac_src_count,
            ip_dst_mode='increment',
            ip_dst_step='0.0.1.0',
            ip_src_addr=intf_traffic_src_ip,
            ip_src_count=mac_src_count,
            ip_src_mode='increment',
            ip_src_step='0.0.1.0',
            l3_protocol='ipv4',
            mac_dst_count=mac_dst_count,
            #mac_dst_mode = 'discovery', # not supported yet
            mac_dst_mode='increment',
            mac_dst_step=1,
            mac_src_count=mac_src_count,
            mac_src_mode='increment',
            mac_src_step=1,
            pkts_per_burst=pkts_per_burst,
            transmit_mode='continuous',
            vlan_id='50 50',
            vlan_id_count='2 2',
            vlan_id_mode='increment fixed',
            vlan_id_step='1 1',
            #vlan_protocol_tag_id = '{8100 8100}',
            direction=direction,
        )
 def test_pkt_len_by_framesize(self):
     # frame_size_step should be 1 (as default)
     with self.assertRaises(Exception):
         test_stream = STLHltStream(length_mode = 'decrement',
                                    frame_size_min = 100,
                                    frame_size_max = 3000,
                                    frame_size_step = 20)
     # just check errors, no compare to golden
     STLHltStream(length_mode = 'increment',
                  frame_size_min = 100,
                  frame_size_max = 3000)
     test_stream = STLHltStream(length_mode = 'decrement',
                                frame_size_min = 100,
                                frame_size_max = 3000,
                                name = 'stream-0')
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''
Beispiel #20
0
    def test_ip_ranges(self):
        # running on single core not implemented yet
        with self.assertRaises(Exception):
            test_stream = STLHltStream(split_by_cores = 'single',
                                       ip_src_addr = '192.168.1.1',
                                       ip_src_mode = 'increment',
                                       ip_src_count = 5,)
        # wrong type
        with self.assertRaises(Exception):
            test_stream = STLHltStream(split_by_cores = 12345,
                                       ip_src_addr = '192.168.1.1',
                                       ip_src_mode = 'increment',
                                       ip_src_count = 5,)

        test_stream = STLHltStream(split_by_cores = 'duplicate',
                                   ip_src_addr = '192.168.1.1',
                                   ip_src_mode = 'increment',
                                   ip_src_count = 5,
                                   ip_dst_addr = '5.5.5.5',
                                   ip_dst_count = 2,
                                   ip_dst_mode = 'random',
                                   name = 'test_ip_ranges',
                                   rate_pps = 1)
        self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
        self.golden_yaml = '''
Beispiel #21
0
 def get_streams(self, direction=0, **kwargs):
     return [
         STLHltStream(
             l3_protocol='ipv6',
             l3_length=150,
             l4_protocol='udp',
             direction=direction,
         ),
     ]
 def create_streams (self, direction = 0):
     return [STLHltStream(l4_protocol = 'udp',
                          udp_src_port_mode = 'random',
                          udp_dst_port_mode = 'random',
                          direction = direction,
                          rate_pps = 1000,
                          consistent_random = True,
                          ),
            ]
Beispiel #23
0
 def get_streams (self, direction = 0, **kwargs):
     return [STLHltStream(length_mode = 'increment',
                          l3_length_min = 100,
                          l3_length_max = 3000,
                          l3_protocol = 'ipv4',
                          l4_protocol = 'udp',
                          rate_bps = 1000000,
                          direction = direction,
                          ),
             STLHltStream(length_mode = 'decrement',
                          l3_length_min = 100,
                          l3_length_max = 3000,
                          l3_protocol = 'ipv4',
                          l4_protocol = 'udp',
                          rate_bps = 1000000,
                          direction = direction,
                          )
            ]
Beispiel #24
0
    def test_vlan_basic(self):
        with self.assertRaises(Exception):
            STLHltStream(l2_encap = 'ethernet_ii',
                         vlan_id = 'sdfgsdgf')
        test_stream = STLHltStream(l2_encap = 'ethernet_ii')
        assert ':802.1Q:' not in test_stream.get_pkt_type(), 'Default packet should not include dot1q'

        test_stream = STLHltStream(name = 'test_vlan_basic', l2_encap = 'ethernet_ii_vlan')
        assert ':802.1Q:' in test_stream.get_pkt_type(), 'No dot1q in packet with encap ethernet_ii_vlan'
        self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
        self.golden_yaml = '''
Beispiel #25
0
 def get_streams (self, direction = 0, **kwargs):
     return STLHltStream(length_mode = 'imix', rate_pps = 2,
                         l3_imix1_size = 60, l3_imix1_ratio = 4,
                         l3_imix2_size = 400, l3_imix2_ratio = 3,
                         l3_imix3_size = 2000, l3_imix3_ratio = 2,
                         l3_imix4_size = 8000, l3_imix4_ratio = 1,
                         l3_protocol = 'ipv4',
                         l4_protocol = 'udp',
                         direction = direction,
                         )
Beispiel #26
0
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(
         frame_size=100,
         vlan_id=[1, 2, 3,
                  4],  # can be either array or string separated by spaces
         vlan_protocol_tag_id='8100 0x8100',  # hex with optional prefix '0x'
         vlan_user_priority='4 3 2',  # forth will be default
         l3_protocol='ipv6',
         l4_protocol='tcp',
         direction=direction)
Beispiel #27
0
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(split_by_cores='duplicate',
                         l3_protocol='ipv4',
                         ip_src_addr='192.168.1.1',
                         ip_src_mode='increment',
                         ip_src_count=5,
                         ip_dst_addr='5.5.5.5',
                         ip_dst_mode='random',
                         consistent_random=True,
                         direction=direction,
                         rate_pps=1)
 def create_streams(self):
     return [
         STLHltStream(
             length_mode='increment',
             frame_size_max=9 * 1024,
             ip_src_addr='16.0.0.1',
             ip_dst_addr='48.0.0.1',
             l4_protocol='udp',
             udp_src_port=1025,
             udp_dst_port=12,
         ),
         STLHltStream(
             length_mode='decrement',
             frame_size_max=9 * 1024,
             ip_src_addr='16.0.0.1',
             ip_dst_addr='48.0.0.1',
             l4_protocol='udp',
             udp_src_port=1025,
             udp_dst_port=12,
         )
     ]
Beispiel #29
0
 def create_streams (self, direction = 0):
     return [STLHltStream(tcp_src_port_mode = 'decrement',
                          tcp_src_port_count = 10,
                          tcp_src_port = 1234,
                          tcp_dst_port_mode = 'increment',
                          tcp_dst_port_count = 10,
                          tcp_dst_port = 1234,
                          name = 'test_tcp_ranges',
                          direction = direction,
                          rate_pps = 1,
                          ),
            ]
 def get_streams(self, direction=0, **kwargs):
     return [
         STLHltStream(
             l3_protocol='ipv4',
             l4_protocol='udp',
             udp_src_port_mode='random',
             udp_dst_port_mode='random',
             direction=direction,
             rate_pps=1000,
             consistent_random=True,
         ),
     ]
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(
         frame_size=100,
         vlan_id='1 2 1000 4 5',  # 5 vlans
         vlan_id_mode=
         'increment fixed decrement random',  # 5th vlan will be default fixed
         vlan_id_step=2,  # 1st vlan step will be 2, others - default 1
         vlan_id_count=[4, 1,
                        10],  # 4th independent on count, 5th will be fixed
         l3_protocol='ipv4',
         l4_protocol='udp',
         direction=direction,
     )
Beispiel #32
0
 def get_streams (self, direction = 0, **kwargs):
     max_size = 9*1024
     return [STLHltStream(length_mode = 'increment',
                          frame_size_max = max_size,
                          l3_protocol = 'ipv4',
                          ip_src_addr = '16.0.0.1',
                          ip_dst_addr = '48.0.0.1',
                          l4_protocol = 'udp',
                          udp_src_port = 1025,
                          udp_dst_port = 12,
                          rate_pps = 1,
                          ),
             STLHltStream(length_mode = 'decrement',
                          frame_size_max = max_size,
                          l3_protocol = 'ipv4',
                          ip_src_addr = '16.0.0.1',
                          ip_dst_addr = '48.0.0.1',
                          l4_protocol = 'udp',
                          udp_src_port = 1025,
                          udp_dst_port = 12,
                          rate_pps = 1,
                          )
            ]
Beispiel #33
0
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(
         l3_protocol='ipv4',
         l4_protocol='tcp',
         tcp_src_port_mode='decrement',
         tcp_src_port_count=10,
         tcp_src_port=1234,
         tcp_dst_port_mode='increment',
         tcp_dst_port_count=10,
         tcp_dst_port=1234,
         name='test_tcp_ranges',
         direction=direction,
         rate_pps=1,
     )
Beispiel #34
0
 def get_streams(self, direction=0, **kwargs):
     return STLHltStream(
         l3_protocol='ipv6',
         l3_length=150,
         l4_protocol='udp',
         ipv6_src_addr='1111:2222:3333:4444:5555:6666:7777:8888',
         ipv6_dst_addr='1111:1111:1111:1111:1111:1111:1111:1111',
         ipv6_src_mode='increment',
         ipv6_src_step=5,
         ipv6_src_count=10,
         ipv6_dst_mode='decrement',
         ipv6_dst_step='1111:1111:1111:1111:1111:0000:0000:0011',
         ipv6_dst_count=150,
     )
 def create_streams (self, direction = 0):
     return [STLHltStream(l4_protocol = 'udp',
                          udp_src_port_mode = 'decrement',
                          udp_src_port_count = 45,
                          udp_src_port_step = 20,
                          udp_src_port = 123,
                          udp_dst_port_mode = 'increment',
                          udp_dst_port_count = 100,
                          udp_dst_port_step = 300,
                          udp_dst_port = 65000,
                          direction = direction,
                          rate_pps = 1000,
                          ),
            ]
Beispiel #36
0
 def get_streams (self, direction = 0, **kwargs):
     return STLHltStream(l3_protocol = 'ipv4',
                         l4_protocol = 'udp',
                         udp_src_port_mode = 'decrement',
                         udp_src_port_count = 45,
                         udp_src_port_step = 20,
                         udp_src_port = 123,
                         udp_dst_port_mode = 'increment',
                         udp_dst_port_count = 100,
                         udp_dst_port_step = 300,
                         udp_dst_port = 65000,
                         direction = direction,
                         rate_pps = 1000,
                         )
 def test_macs_vm(self):
     test_stream = STLHltStream(name = 'stream-0', )
     self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location())
     self.golden_yaml = '''