summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp/trex_stream.h
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-24 08:27:22 -0500
committerimarom <imarom@cisco.com>2016-01-24 08:28:19 -0500
commit7294d7f162e19e0ccd3a37eafbafe22cf63df6a4 (patch)
tree69300aec21fbd1fd6dd93c0ada94fdf4137dfdc5 /src/stateless/cp/trex_stream.h
parent42160bad7056d26b6f5b8c42efc0a8bf5302dfef (diff)
fixed issue trex-172: Console -m 100% is L2 and no L1
http://trex-tgn.cisco.com/youtrack/issue/trex-172
Diffstat (limited to 'src/stateless/cp/trex_stream.h')
-rw-r--r--src/stateless/cp/trex_stream.h44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h
index 0964d39a..6bb30cf9 100644
--- a/src/stateless/cp/trex_stream.h
+++ b/src/stateless/cp/trex_stream.h
@@ -221,23 +221,15 @@ public:
return ( (m_burst_total_pkts / m_pps) * 1000 * 1000);
}
- double get_bps() {
-
- /* 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) */
- if (m_vm.is_vm_empty()) {
- m_expected_pkt_len = m_pkt.len;
- } else {
- m_expected_pkt_len = m_vm.calc_expected_pkt_size(m_pkt.len);
- }
- }
-
+ double get_bps_l2() {
+ return get_bps(false);
+ }
- /* packet length + 4 CRC bytes to bits and multiplied by PPS */
- return (m_pps * (m_expected_pkt_len + 4) * 8);
+ double get_bps_l1() {
+ return get_bps(true);
}
+
void Dump(FILE *fd);
StreamVmDp * getDpVm(){
@@ -296,6 +288,30 @@ public:
/* original template provided by requester */
Json::Value m_stream_json;
+private:
+
+ double get_bps(bool layer1) {
+
+ /* 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) */
+ if (m_vm.is_vm_empty()) {
+ m_expected_pkt_len = m_pkt.len;
+ } else {
+ 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);
+ }
+ }
};