diff options
author | 2016-04-10 12:52:59 +0300 | |
---|---|---|
committer | 2016-04-10 12:52:59 +0300 | |
commit | 7a3be366c6473203bf9f6d75b945aba75ac3f53a (patch) | |
tree | e3809ff89be55a0ca7a9dcc4aca0c309388b7119 | |
parent | 9823cf0a2acfa3eed27613bf357d82c241889cba (diff) |
some refinements and few refactors
-rw-r--r-- | scripts/stl/tests/many_streams.py | 2 | ||||
-rwxr-xr-x | src/bp_sim.h | 6 | ||||
-rwxr-xr-x | src/os_time.h | 5 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.h | 23 | ||||
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.cpp | 2 | ||||
-rw-r--r-- | src/stateless/dp/trex_stream_node.h | 4 |
6 files changed, 29 insertions, 13 deletions
diff --git a/scripts/stl/tests/many_streams.py b/scripts/stl/tests/many_streams.py index eace7640..a8713a26 100644 --- a/scripts/stl/tests/many_streams.py +++ b/scripts/stl/tests/many_streams.py @@ -20,7 +20,7 @@ class STLS1(object): s3 = STLStream(name = 's3', self_start = False, packet = STLPktBuilder(pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.3")/UDP(dport=12,sport=1025)/(10*'x')), - mode = STLTXMultiBurst(pps = 57, pkts_per_burst = 9, count = 5, ibg = 12), + mode = STLTXMultiBurst(pps = 57, pkts_per_burst = 3, count = 5, ibg = 12), next = 's4' ) diff --git a/src/bp_sim.h b/src/bp_sim.h index 583aba82..7d77fdd8 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -63,12 +63,6 @@ limitations under the License. #undef NAT_TRACE_ -static inline double -usec_to_sec(double usec) { - return (usec / (1000 * 1000)); -} - - #define FORCE_NO_INLINE __attribute__ ((noinline)) /* IP address, last 32-bits of IPv6 remaps IPv4 */ diff --git a/src/os_time.h b/src/os_time.h index 0e732abf..42be576f 100755 --- a/src/os_time.h +++ b/src/os_time.h @@ -31,6 +31,11 @@ typedef double dsec_t; //time in sec double uint32_t os_get_time_msec(); uint32_t os_get_time_freq(); +static inline double +usec_to_sec(double usec) { + return (usec / (1000 * 1000)); +} + #ifdef LINUX diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index eba5fed0..c5bfdb98 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -22,6 +22,9 @@ limitations under the License. #ifndef __TREX_STREAM_H__ #define __TREX_STREAM_H__ +#include <stdio.h> +#include <string.h> + #include <unordered_map> #include <vector> #include <stdint.h> @@ -29,9 +32,8 @@ limitations under the License. #include <json/json.h> -#include <trex_stream_vm.h> -#include <stdio.h> -#include <string.h> +#include "os_time.h" +#include "trex_stream_vm.h" #include <common/captureFile.h> #include <common/bitMan.h> @@ -462,6 +464,21 @@ public: return (1.0 / get_pps()); } + /* return the delay before starting a stream */ + inline double get_start_delay_sec() { + return usec_to_sec(m_isg_usec) + m_mc_phase_pre_sec; + } + + /* return the delay before starting the next stream */ + inline double get_next_stream_delay_sec() { + return m_mc_phase_post_sec; + } + + /* return the delay between scheduling a new burst in a multi burst stream */ + inline double get_next_burst_delay_sec() { + return usec_to_sec(m_ibg_usec) + m_mc_phase_post_sec + m_mc_phase_pre_sec; + } + void Dump(FILE *fd); StreamVmDp * getDpVm(){ diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index 2a4a384b..d3d49a34 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -602,7 +602,7 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port, node->m_state =CGenNodeStateless::ss_INACTIVE; } - node->m_time = m_core->m_cur_time_sec + usec_to_sec(stream->m_isg_usec) + stream->m_mc_phase_pre_sec; + node->m_time = m_core->m_cur_time_sec + stream->get_start_delay_sec(); pkt_dir_t dir = m_core->m_node_gen.m_v_if->port_id_to_dir(stream->m_port_id); node->m_flags = 0; diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h index 19a27350..c85bf8b5 100644 --- a/src/stateless/dp/trex_stream_node.h +++ b/src/stateless/dp/trex_stream_node.h @@ -232,7 +232,7 @@ public: set_state(CGenNodeStateless::ss_INACTIVE); if ( thread->set_stateless_next_node(this,m_next_stream) ){ /* update the next stream time using isg and post phase */ - m_next_stream->update_refresh_time(m_time + m_ref_stream_info->m_mc_phase_post_sec); + m_next_stream->update_refresh_time(m_time + m_ref_stream_info->get_next_stream_delay_sec()); thread->m_node_gen.m_p_queue.push( (CGenNode *)m_next_stream); }else{ @@ -242,7 +242,7 @@ public: }else{ /* next burst is like starting a new stream - add pre and post phase */ - m_time += get_multi_ibg_sec() + m_ref_stream_info->m_mc_phase_post_sec + m_ref_stream_info->m_mc_phase_pre_sec; + m_time += m_ref_stream_info->get_next_burst_delay_sec(); m_single_burst = m_single_burst_refill; thread->m_node_gen.m_p_queue.push( (CGenNode *)this); } |