diff options
-rw-r--r-- | scripts/automation/trex_control_plane/stl/examples/stl_imix.py | 2 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 129 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py | 6 | ||||
-rw-r--r-- | src/gtest/trex_stateless_gtest.cpp | 96 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_stream.cpp | 45 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmds.h | 2 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.cpp | 25 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.h | 209 | ||||
-rw-r--r-- | src/stateless/cp/trex_streams_compiler.cpp | 36 | ||||
-rw-r--r-- | src/stateless/cp/trex_streams_compiler.h | 16 |
10 files changed, 401 insertions, 165 deletions
diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_imix.py b/scripts/automation/trex_control_plane/stl/examples/stl_imix.py index b9fbbbb6..e3c01ca9 100644 --- a/scripts/automation/trex_control_plane/stl/examples/stl_imix.py +++ b/scripts/automation/trex_control_plane/stl/examples/stl_imix.py @@ -35,7 +35,7 @@ def imix_test (): dir_1 = table['dir'][1] # load IMIX profile - profile = STLProfile.load_py('../../../../stl/profiles/imix.py') + profile = STLProfile.load_py('../../../../stl/imix.py') streams = profile.get_streams() # add both streams to ports diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index b72b5d35..8a39f96e 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -1,6 +1,7 @@ #!/router/bin/python from trex_stl_exceptions import * +from trex_stl_types import verify_exclusive_arg, validate_type from trex_stl_packet_builder_interface import CTrexPktBuilderInterface from trex_stl_packet_builder_scapy import CScapyTRexPktBuilder, Ether, IP, UDP, TCP, RawPcapReader from collections import OrderedDict, namedtuple @@ -11,14 +12,51 @@ import yaml import base64 import string import traceback +from types import NoneType + +# handles TX rate for a stream +class STLTXRate(object): + def __init__ (self, pps = None, bps_L1 = None, bps_L2 = None, percentage = None): + + verify_exclusive_arg([pps, bps_L1, bps_L2, percentage]) + + self.fields = {} + + if pps is not None: + validate_type('pps', pps, [float, int]) + + self.fields['type'] = 'pps' + self.fields['value'] = pps + + elif bps_L1 is not None: + validate_type('bps_L1', bps_L1, [float, int]) + + self.fields['type'] = 'bps_L1' + self.fields['value'] = bps_L1 + + elif bps_L2 is not None: + validate_type('bps_L2', bps_L2, [float, int]) + + self.fields['type'] = 'bps_L2' + self.fields['value'] = bps_L2 + + elif percentage is not None: + validate_type('percentage', percentage, [float, int]) + if not (percentage > 0 and percentage <= 100): + raise STLArgumentError('percentage', percentage) + + self.fields['type'] = 'percentage' + self.fields['value'] = percentage + + def to_json (self): + return self.fields -def random_name (l): - return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(l)) # base class for TX mode class STLTXMode(object): def __init__ (self): + self.fields = {} def to_json (self): @@ -28,15 +66,11 @@ class STLTXMode(object): # continuous mode class STLTXCont(STLTXMode): - def __init__ (self, pps = 1): - - if not isinstance(pps, (int, float)): - raise STLArgumentError('pps', pps) + def __init__ (self): super(STLTXCont, self).__init__() self.fields['type'] = 'continuous' - self.fields['pps'] = pps def __str__ (self): return "Continuous" @@ -44,10 +78,7 @@ class STLTXCont(STLTXMode): # single burst mode class STLTXSingleBurst(STLTXMode): - def __init__ (self, pps = 1, total_pkts = 1): - - if not isinstance(pps, (int, float)): - raise STLArgumentError('pps', pps) + def __init__ (self, total_pkts = 1): if not isinstance(total_pkts, int): raise STLArgumentError('total_pkts', total_pkts) @@ -55,7 +86,6 @@ class STLTXSingleBurst(STLTXMode): super(STLTXSingleBurst, self).__init__() self.fields['type'] = 'single_burst' - self.fields['pps'] = pps self.fields['total_pkts'] = total_pkts def __str__ (self): @@ -65,14 +95,10 @@ class STLTXSingleBurst(STLTXMode): class STLTXMultiBurst(STLTXMode): def __init__ (self, - pps = 1, pkts_per_burst = 1, ibg = 0.0, # usec not SEC count = 1): - if not isinstance(pps, (int, float)): - raise STLArgumentError('pps', pps) - if not isinstance(pkts_per_burst, int): raise STLArgumentError('pkts_per_burst', pkts_per_burst) @@ -85,7 +111,6 @@ class STLTXMultiBurst(STLTXMode): super(STLTXMultiBurst, self).__init__() self.fields['type'] = 'multi_burst' - self.fields['pps'] = pps self.fields['pkts_per_burst'] = pkts_per_burst self.fields['ibg'] = ibg self.fields['count'] = count @@ -104,7 +129,8 @@ class STLStream(object): def __init__ (self, name = None, packet = None, - mode = STLTXCont(1), + mode = STLTXCont(), + rate = STLTXRate(pps = 1), enabled = True, self_start = True, isg = 0.0, @@ -117,20 +143,13 @@ class STLStream(object): ): # type checking - if not isinstance(mode, STLTXMode): - raise STLArgumentError('mode', mode) - - if packet and not isinstance(packet, CTrexPktBuilderInterface): - raise STLArgumentError('packet', packet) - - if not isinstance(enabled, bool): - raise STLArgumentError('enabled', enabled) - - if not isinstance(self_start, bool): - raise STLArgumentError('self_start', self_start) - - if not isinstance(isg, (int, float)): - raise STLArgumentError('isg', isg) + validate_type('mode', mode, STLTXMode) + validate_type('rate', rate, STLTXRate) + validate_type('packet', packet, (NoneType, CTrexPktBuilderInterface)) + validate_type('enabled', enabled, bool) + validate_type('self_start', self_start, bool) + validate_type('isg', isg, (int, float)) + validate_type('stream_id', stream_id, (NoneType, int)) if (type(mode) == STLTXCont) and (next != None): raise STLError("continuous stream cannot have a next stream ID") @@ -181,6 +200,10 @@ class STLStream(object): self.fields['mode'] = mode.to_json() self.mode_desc = str(mode) + # rate + self.fields['rate'] = rate.to_json() + + # packet self.fields['packet'] = {} self.fields['vm'] = {} @@ -249,8 +272,6 @@ class STLStream(object): return pkt_len - def get_pps (self): - return self.fields['mode']['pps'] def get_mode (self): return self.mode_desc @@ -316,18 +337,15 @@ class YAMLLoader(object): mode_type = mode_obj.get('type') if mode_type == 'continuous': - defaults = STLTXCont() - mode = STLTXCont(pps = mode_obj.get('pps', defaults.fields['pps'])) + mode = STLTXCont() elif mode_type == 'single_burst': defaults = STLTXSingleBurst() - mode = STLTXSingleBurst(pps = mode_obj.get('pps', defaults.fields['pps']), - total_pkts = mode_obj.get('total_pkts', defaults.fields['total_pkts'])) + mode = STLTXSingleBurst(total_pkts = mode_obj.get('total_pkts', defaults.fields['total_pkts'])) elif mode_type == 'multi_burst': defaults = STLTXMultiBurst() - mode = STLTXMultiBurst(pps = mode_obj.get('pps', defaults.fields['pps']), - pkts_per_burst = mode_obj.get('pkts_per_burst', defaults.fields['pkts_per_burst']), + mode = STLTXMultiBurst(pkts_per_burst = mode_obj.get('pkts_per_burst', defaults.fields['pkts_per_burst']), ibg = mode_obj.get('ibg', defaults.fields['ibg']), count = mode_obj.get('count', defaults.fields['count'])) @@ -338,6 +356,30 @@ class YAMLLoader(object): return mode + def __parse_rate (self, rate_obj): + rate_type = rate_obj.get('type') + if rate_type is None: + raise STLError("'rate' must contain 'type'") + + value = rate_obj.get('value') + if value is None: + raise STLError("'rate' must contain 'value'") + + if rate_type == 'pps': + rate = STLTXRate(pps = value) + elif rate_type == 'bps_L1': + rate = STLTXRate(bps_L1 = value) + elif rate_type == 'bps_L2': + rate = STLTXRate(bps_L2 = value) + elif rate_type == 'percentage': + rate = STLTXRate(percentage = value) + + else: + raise STLError("rate type can be 'pps', 'bps_L1', 'bps_l2' or 'percentage'") + + return rate + + def __parse_stream (self, yaml_object): s_obj = yaml_object['stream'] @@ -356,6 +398,11 @@ class YAMLLoader(object): mode = self.__parse_mode(mode_obj) + rate_obj = s_obj.get('rate') + if not rate_obj: + rate = STLTXRate(pps = 1) + else: + rate = self.__parse_rate(rate_obj) defaults = STLStream() @@ -363,6 +410,7 @@ class YAMLLoader(object): stream = STLStream(name = yaml_object.get('name'), packet = builder, mode = mode, + rate = rate, enabled = s_obj.get('enabled', defaults.fields['enabled']), self_start = s_obj.get('self_start', defaults.fields['self_start']), isg = s_obj.get('isg', defaults.fields['isg']), @@ -536,3 +584,4 @@ class STLProfile(object): def __len__ (self): return len(self.streams) + diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py index aa09b0a1..d4ad8bd2 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py @@ -111,3 +111,9 @@ def validate_type(arg_name, arg, valid_types): raise STLTypeError(arg_name, type(arg), valid_types) else: raise STLError('validate_type: valid_types should be type or list or tuple of types') + +# throws STLError if not exactly one argument is present +def verify_exclusive_arg (args_list): + if not (len(filter(lambda x: x is not None, args_list)) == 1): + raise STLError('exactly one parameter from {0} should be provided'.format(args_list)) + diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp index 3faaedeb..576f7d6e 100644 --- a/src/gtest/trex_stateless_gtest.cpp +++ b/src/gtest/trex_stateless_gtest.cpp @@ -1874,7 +1874,7 @@ TEST_F(basic_stl, basic_pause_resume0) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -1937,7 +1937,7 @@ void CBBStartStopDelay2::call_after_init(CBasicStl * m_obj){ std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -1985,7 +1985,7 @@ TEST_F(basic_stl, single_pkt_bb_start_stop_delay2) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2063,7 +2063,7 @@ TEST_F(basic_stl, single_pkt_bb_start_stop_delay1) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2114,7 +2114,7 @@ TEST_F(basic_stl, single_pkt_bb_start_stop3) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2165,7 +2165,7 @@ TEST_F(basic_stl, single_pkt_bb_start_stop2) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2218,7 +2218,7 @@ TEST_F(basic_stl, single_pkt_bb_start_stop) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2270,7 +2270,7 @@ TEST_F(basic_stl, simple_prog4) { /* stream0 */ TrexStream * stream0 = new TrexStream(TrexStream::stCONTINUOUS, 0,300); - stream0->set_pps(1.0); + stream0->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream0->m_enabled = true; stream0->m_self_start = true; @@ -2283,7 +2283,7 @@ TEST_F(basic_stl, simple_prog4) { /* stream1 */ TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST, 0,100); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(5); stream1->m_enabled = true; stream1->m_self_start = true; @@ -2299,7 +2299,7 @@ TEST_F(basic_stl, simple_prog4) { /* stream1 */ TrexStream * stream2 = new TrexStream(TrexStream::stMULTI_BURST, 0,200); - stream2->set_pps(1.0); + stream2->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream2->m_isg_usec = 1000000; /*time betwean stream 1 to stream 2 */ stream2->m_enabled = true; stream2->m_self_start = false; @@ -2351,7 +2351,7 @@ TEST_F(basic_stl, simple_prog3) { /* stream1 */ TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST, 0,100); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(5); stream1->m_enabled = true; stream1->m_self_start = true; @@ -2368,7 +2368,7 @@ TEST_F(basic_stl, simple_prog3) { /* stream1 */ TrexStream * stream2 = new TrexStream(TrexStream::stMULTI_BURST, 0,200); - stream2->set_pps(1.0); + stream2->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream2->m_isg_usec = 1000000; /*time betwean stream 1 to stream 2 */ stream2->m_enabled = true; stream2->m_self_start = false; @@ -2418,7 +2418,7 @@ TEST_F(basic_stl, simple_prog2) { /* stream1 */ TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST, 0,100); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(5); stream1->m_enabled = true; stream1->m_self_start = true; @@ -2435,7 +2435,7 @@ TEST_F(basic_stl, simple_prog2) { /* stream1 */ TrexStream * stream2 = new TrexStream(TrexStream::stSINGLE_BURST, 0,200); - stream2->set_pps(1.0); + stream2->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream2->set_single_burst(5); stream2->m_isg_usec = 2000000; /*time betwean stream 1 to stream 2 */ stream2->m_enabled = true; @@ -2478,7 +2478,7 @@ TEST_F(basic_stl, simple_prog1) { /* stream1 */ TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST, 0,100); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(5); stream1->m_enabled = true; stream1->m_self_start = true; @@ -2495,7 +2495,7 @@ TEST_F(basic_stl, simple_prog1) { /* stream1 */ TrexStream * stream2 = new TrexStream(TrexStream::stSINGLE_BURST, 0,200); - stream2->set_pps(1.0); + stream2->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream2->set_single_burst(5); stream2->m_enabled = true; stream2->m_self_start = false; @@ -2538,7 +2538,7 @@ TEST_F(basic_stl, single_pkt_burst1) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST, 0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(5); stream1->m_enabled = true; stream1->m_self_start = true; @@ -2583,7 +2583,7 @@ TEST_F(basic_stl, single_pkt) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2633,7 +2633,7 @@ void test_mac_replace(bool replace_src_by_pkt, stream1->set_override_src_mac_by_pkt_data(replace_src_by_pkt); stream1->set_override_dst_mac_mode((TrexStream::stream_dst_mac_t)replace_dst_mode); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2707,7 +2707,7 @@ TEST_F(basic_stl, multi_pkt1) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2721,7 +2721,7 @@ TEST_F(basic_stl, multi_pkt1) { streams.push_back(stream1); TrexStream * stream2 = new TrexStream(TrexStream::stCONTINUOUS,0,1); - stream2->set_pps(2.0); + stream2->set_rate(TrexStreamRate::RATE_PPS,2.0); stream2->m_enabled = true; stream2->m_self_start = true; @@ -2773,7 +2773,7 @@ void CEnableVm::run(bool full_packet,double duration=10.0){ TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; stream1->m_self_start = true; @@ -2862,7 +2862,7 @@ TEST_F(basic_stl, multi_pkt2) { TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->m_enabled = true; @@ -2877,7 +2877,7 @@ TEST_F(basic_stl, multi_pkt2) { TrexStream * stream2 = new TrexStream(TrexStream::stCONTINUOUS,0,1); - stream2->set_pps(2.0); + stream2->set_rate(TrexStreamRate::RATE_PPS,2.0); stream2->m_enabled = false; stream2->m_self_start = false; @@ -2919,7 +2919,7 @@ TEST_F(basic_stl, multi_burst1) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stMULTI_BURST,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_multi_burst(5, 3, 2000000.0); @@ -2962,7 +2962,7 @@ TEST_F(basic_stl, compile_bad_1) { TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,2); stream1->m_enabled = true; - stream1->set_pps(52.0); + stream1->set_rate(TrexStreamRate::RATE_PPS,52.0); stream1->m_next_stream_id = 3; streams.push_back(stream1); @@ -2987,14 +2987,14 @@ TEST_F(basic_stl, compile_bad_2) { TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST,0,1); stream1->m_enabled = true; - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(200); /* non existant next stream */ stream1->m_next_stream_id = 5; TrexStream * stream2 = new TrexStream(TrexStream::stCONTINUOUS,0,2); - stream1->set_pps(52.0); + stream1->set_rate(TrexStreamRate::RATE_PPS,52.0); streams.push_back(stream1); streams.push_back(stream2); @@ -3026,7 +3026,7 @@ TEST_F(basic_stl, compile_bad_3) { /* stream 1 */ stream = new TrexStream(TrexStream::stSINGLE_BURST, 0, 231); stream->m_enabled = true; - stream->set_pps(1.0); + stream->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream->set_single_burst(200); stream->m_next_stream_id = 5481; @@ -3039,7 +3039,7 @@ TEST_F(basic_stl, compile_bad_3) { stream->m_enabled = true; stream->m_next_stream_id = -1; stream->m_self_start = false; - stream->set_pps(52.0); + stream->set_rate(TrexStreamRate::RATE_PPS,52.0); streams.push_back(stream); @@ -3047,7 +3047,7 @@ TEST_F(basic_stl, compile_bad_3) { stream = new TrexStream(TrexStream::stSINGLE_BURST, 0, 1928); stream->m_enabled = true; - stream->set_pps(1.0); + stream->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream->set_single_burst(200); stream->m_next_stream_id = -1; @@ -3059,7 +3059,7 @@ TEST_F(basic_stl, compile_bad_3) { stream = new TrexStream(TrexStream::stSINGLE_BURST, 0, 41231); stream->m_enabled = true; - stream->set_pps(1.0); + stream->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream->set_single_burst(200); stream->m_next_stream_id = 3928; @@ -3071,7 +3071,7 @@ TEST_F(basic_stl, compile_bad_3) { stream = new TrexStream(TrexStream::stSINGLE_BURST, 0, 3928); stream->m_enabled = true; - stream->set_pps(1.0); + stream->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream->set_single_burst(200); stream->m_next_stream_id = 41231; @@ -3100,7 +3100,7 @@ TEST_F(basic_stl, compile_with_warnings) { /* stream 1 */ stream = new TrexStream(TrexStream::stSINGLE_BURST, 0, 231); stream->m_enabled = true; - stream->set_pps(1.0); + stream->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream->set_single_burst(200); stream->m_next_stream_id = 1928; @@ -3113,7 +3113,7 @@ TEST_F(basic_stl, compile_with_warnings) { stream->m_enabled = true; stream->m_next_stream_id = 1928; stream->m_self_start = true; - stream->set_pps(52.0); + stream->set_rate(TrexStreamRate::RATE_PPS,52.0); streams.push_back(stream); @@ -3121,7 +3121,7 @@ TEST_F(basic_stl, compile_with_warnings) { stream = new TrexStream(TrexStream::stSINGLE_BURST, 0, 1928); stream->m_enabled = true; - stream->set_pps(1.0); + stream->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream->set_single_burst(200); stream->m_next_stream_id = -1; @@ -3154,7 +3154,7 @@ TEST_F(basic_stl, compile_good_stream_id_compres) { TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST,0,700); stream1->m_self_start = true; stream1->m_enabled = true; - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(200); /* non existant next stream */ @@ -3162,7 +3162,7 @@ TEST_F(basic_stl, compile_good_stream_id_compres) { TrexStream * stream2 = new TrexStream(TrexStream::stSINGLE_BURST,0,800); - stream2->set_pps(52.0); + stream2->set_rate(TrexStreamRate::RATE_PPS,52.0); stream2->m_enabled = true; stream2->m_next_stream_id = 700; stream2->set_single_burst(300); @@ -3231,7 +3231,7 @@ TEST_F(basic_stl, dp_stop_event) { std::vector<TrexStream *> streams; TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST,0,0); - stream1->set_pps(1.0); + stream1->set_rate(TrexStreamRate::RATE_PPS, 1.0); stream1->set_single_burst(100); stream1->m_enabled = true; @@ -3277,7 +3277,7 @@ TEST_F(basic_stl, graph_generator1) { stream->m_self_start = true; stream->m_isg_usec = 42; - stream->set_pps(10); + stream->set_rate(TrexStreamRate::RATE_PPS,10); stream->set_single_burst(43281); stream->m_pkt.len = 512; @@ -3291,7 +3291,7 @@ TEST_F(basic_stl, graph_generator1) { stream->m_enabled = true; stream->m_self_start = false; - stream->set_pps(20); + stream->set_rate(TrexStreamRate::RATE_PPS,20); stream->set_multi_burst(4918, 13, 7); stream->m_next_stream_id = -1; stream->m_pkt.len = 64; @@ -3304,7 +3304,7 @@ TEST_F(basic_stl, graph_generator1) { stream->m_self_start = true; stream->m_isg_usec = 50; - stream->set_pps(30); + stream->set_rate(TrexStreamRate::RATE_PPS,30); stream->m_next_stream_id = -1; stream->m_pkt.len = 1512; @@ -3334,7 +3334,7 @@ TEST_F(basic_stl, graph_generator2) { stream->m_self_start = true; - stream->set_pps(1000); + stream->set_rate(TrexStreamRate::RATE_PPS,1000); /* a burst of 2000 packets with a delay of 1 second */ stream->m_isg_usec = 0; @@ -3352,7 +3352,7 @@ TEST_F(basic_stl, graph_generator2) { stream->m_enabled = true; stream->m_self_start = true; - stream->set_pps(1000); + stream->set_rate(TrexStreamRate::RATE_PPS,1000); stream->m_isg_usec = 1000 * 1000 + 1000; stream->set_multi_burst(1000 - 2, 1000, 1000 * 1000 + 2000); stream->m_pkt.len = 128; @@ -3517,7 +3517,7 @@ TEST_F(basic_stl, vm_split_flow_var_inc) { TrexStream stream(TrexStream::stSINGLE_BURST, 0, 0); stream.set_single_burst(1000); - stream.set_pps(100000); + stream.set_rate(TrexStreamRate::RATE_PPS,100000); split.set_stream(&stream); split.run(8, 4); @@ -3530,7 +3530,7 @@ TEST_F(basic_stl, vm_split_flow_var_small_range) { TrexStream stream(TrexStream::stSINGLE_BURST, 0, 0); stream.set_single_burst(1000); - stream.set_pps(100000); + stream.set_rate(TrexStreamRate::RATE_PPS,100000); split.set_stream(&stream); split.set_flow_var_as_split(StreamVmInstructionFlowMan::FLOW_VAR_OP_INC, 0, 1, 0); @@ -3544,7 +3544,7 @@ TEST_F(basic_stl, vm_split_flow_var_big_range) { TrexStream stream(TrexStream::stSINGLE_BURST, 0, 0); stream.set_single_burst(1000); - stream.set_pps(100000); + stream.set_rate(TrexStreamRate::RATE_PPS,100000); split.set_stream(&stream); split.set_flow_var_as_split(StreamVmInstructionFlowMan::FLOW_VAR_OP_DEC, 1, 1000, 1000); @@ -3559,7 +3559,7 @@ TEST_F(basic_stl, vm_split_client_var) { TrexStream stream(TrexStream::stSINGLE_BURST, 0, 0); stream.set_single_burst(1000); - stream.set_pps(100000); + stream.set_rate(TrexStreamRate::RATE_PPS,100000); split.set_stream(&stream); split.set_client_var_as_split(0x10000001, 0x100000fe, 5000, 5050); diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp index 920991e2..bcfa7df1 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp @@ -60,6 +60,10 @@ TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) { stream->m_flags = parse_int(section, "flags", result); stream->m_action_count = parse_uint16(section, "action_count", result); + /* parse the rate of the stream */ + const Json::Value &rate = parse_object(section ,"rate", result); + parse_rate(rate, stream.get(), result); + /* inter stream gap */ stream->m_isg_usec = parse_double(section, "isg", result); @@ -138,35 +142,26 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value §ion, uint8_t por const Json::Value &mode = parse_object(section, "mode", result); std::string type = parse_string(mode, "type", result); + if (type == "continuous") { - double pps = parse_double(mode, "pps", result); stream = new TrexStream( TrexStream::stCONTINUOUS, port_id, stream_id); - stream->set_pps(pps); - - if (stream->m_next_stream_id != -1) { - generate_parse_err(result, "continious stream cannot provide next stream id - only -1 is valid"); - } } else if (type == "single_burst") { uint32_t total_pkts = parse_int(mode, "total_pkts", result); - double pps = parse_double(mode, "pps", result); - stream = new TrexStream(TrexStream::stSINGLE_BURST,port_id, stream_id); - stream->set_pps(pps); + stream = new TrexStream(TrexStream::stSINGLE_BURST, port_id, stream_id); stream->set_single_burst(total_pkts); } else if (type == "multi_burst") { - double pps = parse_double(mode, "pps", result); double ibg_usec = parse_double(mode, "ibg", result); uint32_t num_bursts = parse_int(mode, "count", result); uint32_t pkts_per_burst = parse_int(mode, "pkts_per_burst", result); stream = new TrexStream(TrexStream::stMULTI_BURST,port_id, stream_id ); - stream->set_pps(pps); stream->set_multi_burst(pkts_per_burst,num_bursts,ibg_usec); @@ -174,16 +169,34 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value §ion, uint8_t por generate_parse_err(result, "bad stream type provided: '" + type + "'"); } - /* make sure we were able to allocate the memory */ - if (!stream) { - generate_internal_err(result, "unable to allocate memory"); - } - return (stream); } void +TrexRpcCmdAddStream::parse_rate(const Json::Value &rate, TrexStream *stream, Json::Value &result) { + + double value = parse_double(rate, "value", result); + + auto rate_types = {"pps", "bps_L1", "bps_L2", "percentage"}; + std::string rate_type = parse_choice(rate, "type", rate_types, result); + + if (rate_type == "pps") { + stream->set_rate(TrexStreamRate::RATE_PPS, value); + } else if (rate_type == "bps_L1") { + stream->set_rate(TrexStreamRate::RATE_BPS_L1, value); + } else if (rate_type == "bps_L2") { + stream->set_rate(TrexStreamRate::RATE_BPS_L2, value); + } else if (rate_type == "percentage") { + stream->set_rate(TrexStreamRate::RATE_PERCENTAGE, value); + } else { + /* impossible */ + assert(0); + } + +} + +void TrexRpcCmdAddStream::parse_vm_instr_checksum(const Json::Value &inst, TrexStream *stream, Json::Value &result) { uint16_t pkt_offset = parse_uint16(inst, "pkt_offset", result); diff --git a/src/rpc-server/commands/trex_rpc_cmds.h b/src/rpc-server/commands/trex_rpc_cmds.h index 3dc2ce0a..3da1e4fa 100644 --- a/src/rpc-server/commands/trex_rpc_cmds.h +++ b/src/rpc-server/commands/trex_rpc_cmds.h @@ -98,7 +98,7 @@ void parse_vm_instr_checksum(const Json::Value &inst, TrexStream *stream, Json:: void parse_vm_instr_flow_var(const Json::Value &inst, TrexStream *stream, Json::Value &result); void parse_vm_instr_tuple_flow_var(const Json::Value &inst, TrexStream *stream, Json::Value &result); void parse_vm_instr_trim_pkt_size(const Json::Value &inst, TrexStream *stream, Json::Value &result); - +void parse_rate(const Json::Value &inst, TrexStream *stream, Json::Value &result); void parse_vm_instr_write_flow_var(const Json::Value &inst, TrexStream *stream, Json::Value &result); void parse_vm_instr_write_mask_flow_var(const Json::Value &inst, TrexStream *stream, Json::Value &result); diff --git a/src/stateless/cp/trex_stream.cpp b/src/stateless/cp/trex_stream.cpp index fb0b35d5..f4a8e800 100644 --- a/src/stateless/cp/trex_stream.cpp +++ b/src/stateless/cp/trex_stream.cpp @@ -22,6 +22,7 @@ limitations under the License. #include <cstddef> #include <string.h> #include <assert.h> +#include <trex_stateless.h> /************************************** * stream @@ -91,20 +92,25 @@ void TrexStream::Dump(FILE *fd){ fprintf(fd," type : %s \n",get_stream_type_str(m_type).c_str()); if ( m_type == TrexStream::stCONTINUOUS ) { - fprintf(fd," pps : %f \n",m_pps); } if (m_type == TrexStream::stSINGLE_BURST) { - fprintf(fd," pps : %f \n",m_pps); fprintf(fd," burst : %lu \n",(ulong)m_burst_total_pkts); } if (m_type == TrexStream::stMULTI_BURST) { - fprintf(fd," pps : %f \n",m_pps); fprintf(fd," burst : %lu \n",(ulong)m_burst_total_pkts); fprintf(fd," mburst : %lu \n",(ulong)m_num_bursts); if (m_ibg_usec>0.0) { fprintf(fd," m_ibg_usec : %f \n",m_ibg_usec); } } + + fprintf(fd," rate :\n\n"); + + fprintf(fd," pps : %f\n", get_rate().get_pps()); + fprintf(fd," bps L1 : %f\n", get_rate().get_bps_L1()); + fprintf(fd," bps L2 : %f\n", get_rate().get_bps_L2()); + fprintf(fd," percentage : %f\n", get_rate().get_percentage()); + } @@ -125,7 +131,6 @@ TrexStream::TrexStream(uint8_t type, m_rx_check.m_enable = false; - m_pps=-1.0; m_burst_total_pkts=0; m_num_bursts=1; m_ibg_usec=0.0; @@ -155,6 +160,18 @@ TrexStream::get_stream_json() { return m_stream_json; } +TrexStreamRate & +TrexStream::get_rate() { + + /* lazy calculation of the rate */ + if (!m_rate.is_calculated()) { + TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(m_port_id); + double pkt_size = get_pkt_size(); + m_rate.calculate(pkt_size, port->get_port_speed_bps()); + } + + return m_rate; +} /************************************** * stream table diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index 2ab90c99..f4739569 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -103,6 +103,151 @@ public: } }; +/** + * describes a stream rate + * + * @author imarom (18-Feb-16) + */ +class TrexStreamRate { + + +public: + + enum rate_type_e { + RATE_INVALID, + RATE_PPS, + RATE_BPS_L1, + RATE_BPS_L2, + RATE_PERCENTAGE + }; + + TrexStreamRate() { + m_base_rate_type = RATE_INVALID; + m_is_calculated = false; + } + + /** + * set the base rate + * other values will be dervied from this value + * + */ + void set_base_rate(rate_type_e type, double value) { + m_base_rate_type = type; + m_value = value; + m_is_calculated = false; + } + + + /** + * calculates all the rates from the base rate + * + */ + void calculate(uint16_t pkt_size, uint64_t line_bps) { + + switch (m_base_rate_type) { + + case RATE_PPS: + calculate_from_pps(m_value, pkt_size, line_bps); + break; + + case RATE_BPS_L1: + calculate_from_bps_L1(m_value, pkt_size, line_bps); + break; + + case RATE_BPS_L2: + calculate_from_bps_L2(m_value, pkt_size, line_bps); + break; + + case RATE_PERCENTAGE: + calculate_from_percentage(m_value, pkt_size, line_bps); + break; + + default: + assert(0); + } + + m_is_calculated = true; + } + + + bool is_calculated() const { + return m_is_calculated; + } + + + /* update the rate by a factor */ + void update_factor(double factor) { + assert(m_is_calculated); + + m_pps *= factor; + m_bps_L1 *= factor; + m_bps_L2 *= factor; + m_percentage *= factor; + } + + double get_pps() { + assert(m_is_calculated); + return (m_pps); + } + + double get_bps_L1() { + assert(m_is_calculated); + return (m_bps_L1); + } + + double get_bps_L2() { + assert(m_is_calculated); + return m_bps_L2; + } + + double get_percentage() { + assert(m_is_calculated); + return m_percentage; + } + +private: + + void calculate_from_pps(double pps, uint16_t pkt_size, uint64_t line_bps) { + m_pps = pps; + m_bps_L1 = m_pps * (pkt_size + 24) * 8; + m_bps_L2 = m_pps * (pkt_size + 4) * 8; + m_percentage = (m_bps_L1 / line_bps) * 100.0; + } + + + void calculate_from_bps_L1(double bps_L1, uint16_t pkt_size, uint64_t line_bps) { + m_bps_L1 = bps_L1; + m_bps_L2 = m_bps_L1 * ( (pkt_size + 4.0) / (pkt_size + 24.0) ); + m_pps = m_bps_L2 / (8 * (pkt_size + 4)); + m_percentage = (m_bps_L1 / line_bps) * 100.0; + } + + + void calculate_from_bps_L2(double bps_L2, uint16_t pkt_size, uint64_t line_bps) { + m_bps_L2 = bps_L2; + m_bps_L1 = m_bps_L2 * ( (pkt_size + 24.0) / (pkt_size + 4.0)); + m_pps = m_bps_L2 / (8 * (pkt_size + 4)); + m_percentage = (m_bps_L1 / line_bps) * 100.0; + } + + void calculate_from_percentage(double percentage, uint16_t pkt_size, uint64_t line_bps) { + m_percentage = percentage; + m_bps_L1 = (m_percentage / 100.0) * line_bps; + m_bps_L2 = m_bps_L1 * ( (pkt_size + 4.0) / (pkt_size + 24.0) ); + m_pps = m_bps_L2 / (8 * (pkt_size + 4)); + + } + + rate_type_e m_base_rate_type; + double m_value; + + bool m_is_calculated; + double m_pps; + double m_bps_L1; + double m_bps_L2; + double m_percentage; + +}; /** * Stateless Stream @@ -151,12 +296,29 @@ public: m_next_stream_id = next_stream_id; } - double get_pps() const { - return m_pps; + + double get_pps() { + return get_rate().get_pps(); + } + + double get_bps_L1() { + return get_rate().get_bps_L1(); + } + + double get_bps_L2() { + return get_rate().get_bps_L2(); + } + + double get_bw_percentage() { + return get_rate().get_percentage(); + } + + void set_rate(TrexStreamRate::rate_type_e type, double value) { + m_rate.set_base_rate(type, value); } - void set_pps(double pps){ - m_pps = pps; + void update_rate_factor(double factor) { + get_rate().update_factor(factor); } void set_type(uint8_t type){ @@ -223,13 +385,14 @@ public: dp->m_expected_pkt_len = m_expected_pkt_len; dp->m_rx_check = m_rx_check; - dp->m_pps = m_pps; dp->m_burst_total_pkts = m_burst_total_pkts; dp->m_num_bursts = m_num_bursts; dp->m_ibg_usec = m_ibg_usec; dp->m_flags = m_flags; dp->m_action_count = m_action_count; + dp->m_rate = m_rate; + return(dp); } @@ -241,19 +404,11 @@ public: } } - double get_burst_length_usec() const { - return ( (m_burst_total_pkts / m_pps) * 1000 * 1000); - } - - double get_bps_l2() { - return get_bps(false); - } - - double get_bps_l1() { - return get_bps(true); + double get_burst_length_usec() { + return ( (m_burst_total_pkts / get_pps()) * 1000 * 1000); } - + void Dump(FILE *fd); StreamVmDp * getDpVm(){ @@ -321,8 +476,6 @@ public: } m_rx_check; - double m_pps; - uint32_t m_burst_total_pkts; /* valid in case of burst stSINGLE_BURST,stMULTI_BURST*/ uint32_t m_num_bursts; /* valid in case of stMULTI_BURST */ @@ -334,8 +487,7 @@ public: private: - double get_bps(bool layer1) { - + double get_pkt_size() { /* lazy calculate the expected packet length */ if (m_expected_pkt_len == 0) { /* if we have a VM - it might have changed the packet (even random) */ @@ -345,17 +497,16 @@ private: m_expected_pkt_len = m_vm.calc_expected_pkt_size(m_pkt.len); } } - - /* packet length + 4 CRC bytes to bits and multiplied by PPS */ - - if (layer1) { - /* layer one includes preamble, frame delimiter and interpacket gap */ - return (m_pps * (m_expected_pkt_len + 4 + 8 + 12) * 8); - } else { - return (m_pps * (m_expected_pkt_len + 4) * 8); - } + return m_expected_pkt_len; } + + + /* get (and calculate if need) the rate of the stream */ + TrexStreamRate & get_rate(); + + /* no access to this without a lazy build method */ + TrexStreamRate m_rate; }; diff --git a/src/stateless/cp/trex_streams_compiler.cpp b/src/stateless/cp/trex_streams_compiler.cpp index 9d048dbd..aca74498 100644 --- a/src/stateless/cp/trex_streams_compiler.cpp +++ b/src/stateless/cp/trex_streams_compiler.cpp @@ -459,7 +459,7 @@ TrexStreamsCompiler::compile_internal(uint8_t por * */ void -TrexStreamsCompiler::compile_stream(const TrexStream *stream, +TrexStreamsCompiler::compile_stream(TrexStream *stream, double factor, uint8_t dp_core_count, std::vector<TrexStreamsCompiledObj *> &objs, @@ -500,7 +500,7 @@ TrexStreamsCompiler::compile_stream(const TrexStream *stream, * */ void -TrexStreamsCompiler::compile_stream_on_all_cores(const TrexStream *stream, +TrexStreamsCompiler::compile_stream_on_all_cores(TrexStream *stream, double factor, uint8_t dp_core_count, std::vector<TrexStreamsCompiledObj *> &objs, @@ -509,7 +509,7 @@ TrexStreamsCompiler::compile_stream_on_all_cores(const TrexStream *stream, std::vector<TrexStream *> core_streams(dp_core_count); - double per_core_rate = (stream->m_pps * (factor / dp_core_count)); + double per_core_factor = (factor / dp_core_count); int per_core_burst_total_pkts = (stream->m_burst_total_pkts / dp_core_count); /* for each core - creates its own version of the stream */ @@ -521,7 +521,7 @@ TrexStreamsCompiler::compile_stream_on_all_cores(const TrexStream *stream, /* adjust rate and packets count */ - dp_stream->m_pps = per_core_rate; + dp_stream->update_rate_factor(per_core_factor); dp_stream->m_burst_total_pkts = per_core_burst_total_pkts; core_streams[i] = dp_stream; @@ -547,7 +547,7 @@ TrexStreamsCompiler::compile_stream_on_all_cores(const TrexStream *stream, * */ void -TrexStreamsCompiler::compile_stream_on_single_core(const TrexStream *stream, +TrexStreamsCompiler::compile_stream_on_single_core(TrexStream *stream, double factor, TrexStreamsCompiledObj *obj, int new_id, @@ -560,7 +560,7 @@ TrexStreamsCompiler::compile_stream_on_single_core(const TrexStream *stream, /* compile the VM if exists */ if (!stream->m_vm.is_vm_empty()) { - ((TrexStream *)stream)->vm_compile(); + stream->vm_compile(); dp_stream->m_vm_dp = stream->m_vm_dp->clone(); } @@ -581,7 +581,7 @@ TrexStreamsCompiler::compile_stream_on_single_core(const TrexStream *stream, * @param stream */ void -TrexStreamsGraph::add_rate_events_for_stream(double &offset_usec, const TrexStream *stream) { +TrexStreamsGraph::add_rate_events_for_stream(double &offset_usec, TrexStream *stream) { switch (stream->get_type()) { @@ -604,7 +604,7 @@ TrexStreamsGraph::add_rate_events_for_stream(double &offset_usec, const TrexStre * */ void -TrexStreamsGraph::add_rate_events_for_stream_cont(double &offset_usec, const TrexStream *stream) { +TrexStreamsGraph::add_rate_events_for_stream_cont(double &offset_usec, TrexStream *stream) { TrexStreamsGraphObj::rate_event_st start_event; @@ -613,8 +613,8 @@ TrexStreamsGraph::add_rate_events_for_stream_cont(double &offset_usec, const Tre start_event.time = offset_usec + stream->m_isg_usec; start_event.diff_pps = stream->get_pps(); - start_event.diff_bps_l2 = ((TrexStream *)stream)->get_bps_l2(); - start_event.diff_bps_l1 = ((TrexStream *)stream)->get_bps_l1(); + start_event.diff_bps_l2 = stream->get_bps_L2(); + start_event.diff_bps_l1 = stream->get_bps_L1(); m_graph_obj->add_rate_event(start_event); /* no more events after this stream */ @@ -629,7 +629,7 @@ TrexStreamsGraph::add_rate_events_for_stream_cont(double &offset_usec, const Tre * */ void -TrexStreamsGraph::add_rate_events_for_stream_single_burst(double &offset_usec, const TrexStream *stream) { +TrexStreamsGraph::add_rate_events_for_stream_single_burst(double &offset_usec, TrexStream *stream) { TrexStreamsGraphObj::rate_event_st start_event; TrexStreamsGraphObj::rate_event_st stop_event; @@ -640,9 +640,9 @@ TrexStreamsGraph::add_rate_events_for_stream_single_burst(double &offset_usec, c /* start event */ start_event.time = offset_usec + stream->m_isg_usec; - start_event.diff_pps = stream->get_pps(); - start_event.diff_bps_l2 = ((TrexStream *)stream)->get_bps_l2(); - start_event.diff_bps_l1 = ((TrexStream *)stream)->get_bps_l1(); + start_event.diff_pps = stream->get_pps(); + start_event.diff_bps_l2 = stream->get_bps_L2(); + start_event.diff_bps_l1 = stream->get_bps_L1(); m_graph_obj->add_rate_event(start_event); /* stop event */ @@ -662,7 +662,7 @@ TrexStreamsGraph::add_rate_events_for_stream_single_burst(double &offset_usec, c * */ void -TrexStreamsGraph::add_rate_events_for_stream_multi_burst(double &offset_usec, const TrexStream *stream) { +TrexStreamsGraph::add_rate_events_for_stream_multi_burst(double &offset_usec, TrexStream *stream) { TrexStreamsGraphObj::rate_event_st start_event; TrexStreamsGraphObj::rate_event_st stop_event; @@ -672,8 +672,8 @@ TrexStreamsGraph::add_rate_events_for_stream_multi_burst(double &offset_usec, co /* for debug purposes */ start_event.diff_pps = stream->get_pps(); - start_event.diff_bps_l2 = ((TrexStream *)stream)->get_bps_l2(); - start_event.diff_bps_l1 = ((TrexStream *)stream)->get_bps_l1(); + start_event.diff_bps_l2 = stream->get_bps_L2(); + start_event.diff_bps_l1 = stream->get_bps_L1(); start_event.stream_id = stream->m_stream_id; stop_event.diff_pps = -(start_event.diff_pps); @@ -714,7 +714,7 @@ TrexStreamsGraph::generate_graph_for_one_root(uint32_t root_stream_id) { double offset = 0; while (true) { - const TrexStream *stream; + TrexStream *stream; /* fetch the stream from the hash - if it is not present, report an error */ try { diff --git a/src/stateless/cp/trex_streams_compiler.h b/src/stateless/cp/trex_streams_compiler.h index a3a1f8f7..b8b0be37 100644 --- a/src/stateless/cp/trex_streams_compiler.h +++ b/src/stateless/cp/trex_streams_compiler.h @@ -123,19 +123,19 @@ private: void add_warning(const std::string &warning); void err(const std::string &err); - void compile_stream(const TrexStream *stream, + void compile_stream(TrexStream *stream, double factor, uint8_t dp_core_count, std::vector<TrexStreamsCompiledObj *> &objs, GraphNodeMap &nodes); - void compile_stream_on_single_core(const TrexStream *stream, + void compile_stream_on_single_core(TrexStream *stream, double factor, TrexStreamsCompiledObj *obj, int new_id, int new_next_id); - void compile_stream_on_all_cores(const TrexStream *stream, + void compile_stream_on_all_cores(TrexStream *stream, double factor, uint8_t dp_core_count, std::vector<TrexStreamsCompiledObj *> &objs, @@ -245,13 +245,13 @@ private: void generate_graph_for_one_root(uint32_t root_stream_id); - void add_rate_events_for_stream(double &offset, const TrexStream *stream); - void add_rate_events_for_stream_cont(double &offset_usec, const TrexStream *stream); - void add_rate_events_for_stream_single_burst(double &offset_usec, const TrexStream *stream); - void add_rate_events_for_stream_multi_burst(double &offset_usec, const TrexStream *stream); + void add_rate_events_for_stream(double &offset, TrexStream *stream); + void add_rate_events_for_stream_cont(double &offset_usec, TrexStream *stream); + void add_rate_events_for_stream_single_burst(double &offset_usec, TrexStream *stream); + void add_rate_events_for_stream_multi_burst(double &offset_usec, TrexStream *stream); /* for fast processing of streams */ - std::unordered_map<uint32_t, const TrexStream *> m_streams_hash; + std::unordered_map<uint32_t, TrexStream *> m_streams_hash; /* main object to hold the graph - returned to the user */ TrexStreamsGraphObj *m_graph_obj; |