From 1016c3d481dc9e2eb9ab03332aff441c03239614 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Tue, 25 Oct 2016 16:46:47 +0200 Subject: console: rearrange lines at "stats --ps" in case of start traffic with link down, return error with link state Signed-off-by: Yaroslav Brustinov --- src/stateless/cp/trex_stateless_port.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/stateless/cp') diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 1a92b309..53a225f6 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -252,14 +252,14 @@ TrexStatelessPort::start_traffic(const TrexPortMultiplier &mul, double duration, /* on start - we can only provide absolute values */ assert(mul.m_op == TrexPortMultiplier::OP_ABS); + /* check link state */ + if ( !platform_api->getPortAttrObj()->is_link_up(m_port_id) && !force ) { + throw TrexException("Link state is DOWN."); + } + /* caclulate the effective factor for DP */ double factor = calculate_effective_factor(mul, force); - /* zero factor */ - if (factor == 0) { - throw TrexException("Zero multiplier, nothing to send."); - } - StreamsFeeder feeder(this); /* compiler it */ @@ -690,6 +690,20 @@ TrexStatelessPort::calculate_effective_factor(const TrexPortMultiplier &mul, boo throw TrexException(ss.str()); } + /* L1 BW must be positive */ + if (expected_l1_rate <= 0){ + stringstream ss; + ss << "Effective bandwidth must be positive, got: " << expected_l1_rate; + throw TrexException(ss.str()); + } + + /* factor must be positive */ + if (factor <= 0) { + stringstream ss; + ss << "Factor must be positive, got: " << factor; + throw TrexException(ss.str()); + } + return factor; } -- cgit 1.2.3-korg