summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp/trex_stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stateless/cp/trex_stream.cpp')
-rw-r--r--src/stateless/cp/trex_stream.cpp25
1 files changed, 21 insertions, 4 deletions
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