summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2017-01-22 15:36:20 +0200
committerimarom <imarom@cisco.com>2017-01-22 15:36:20 +0200
commitf5f92b068561dcdf8414494e5daf6d285ea24135 (patch)
tree46925eb424943781e452f1fd9ebb5bd1f1774568 /src
parent641fed03d8e407b6dca94f5280b9a1b4c768f601 (diff)
few tweaks
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp5
-rw-r--r--src/stateless/rx/trex_stateless_capture.cpp19
-rw-r--r--src/stateless/rx/trex_stateless_capture.h24
3 files changed, 35 insertions, 13 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index be261fbb..55249fc8 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -994,8 +994,9 @@ TrexRpcCmdCapture::parse_cmd_fetch(const Json::Value &params, Json::Value &resul
const TrexPktBuffer *pkt_buffer = rc.get_pkt_buffer();
- result["result"]["pending"] = rc.get_pending();
- result["result"]["pkts"] = pkt_buffer->to_json();
+ result["result"]["pending"] = rc.get_pending();
+ result["result"]["start_ts"] = rc.get_start_ts();
+ result["result"]["pkts"] = pkt_buffer->to_json();
/* delete the buffer */
delete pkt_buffer;
diff --git a/src/stateless/rx/trex_stateless_capture.cpp b/src/stateless/rx/trex_stateless_capture.cpp
index 5d43cede..f0d4e806 100644
--- a/src/stateless/rx/trex_stateless_capture.cpp
+++ b/src/stateless/rx/trex_stateless_capture.cpp
@@ -26,6 +26,8 @@ TrexStatelessCapture::TrexStatelessCapture(capture_id_t id, uint64_t limit, cons
m_pkt_buffer = new TrexPktBuffer(limit, TrexPktBuffer::MODE_DROP_TAIL);
m_filter = filter;
m_state = STATE_ACTIVE;
+ m_start_ts = now_sec();
+ m_pkt_index = 0;
}
TrexStatelessCapture::~TrexStatelessCapture() {
@@ -35,7 +37,7 @@ TrexStatelessCapture::~TrexStatelessCapture() {
}
void
-TrexStatelessCapture::handle_pkt_tx(const TrexPkt *pkt) {
+TrexStatelessCapture::handle_pkt_tx(TrexPkt *pkt) {
if (m_state != STATE_ACTIVE) {
delete pkt;
@@ -48,6 +50,12 @@ TrexStatelessCapture::handle_pkt_tx(const TrexPkt *pkt) {
return;
}
+ if (pkt->get_ts() < m_start_ts) {
+ delete pkt;
+ return;
+ }
+
+ pkt->set_index(++m_pkt_index);
m_pkt_buffer->push(pkt);
}
@@ -62,7 +70,7 @@ TrexStatelessCapture::handle_pkt_rx(const rte_mbuf_t *m, int port) {
return;
}
- m_pkt_buffer->push(m, port, TrexPkt::ORIGIN_RX);
+ m_pkt_buffer->push(m, port, TrexPkt::ORIGIN_RX, ++m_pkt_index);
}
@@ -110,7 +118,8 @@ TrexStatelessCapture::fetch(uint32_t pkt_limit, uint32_t &pending) {
partial->push(pkt);
}
- pending = m_pkt_buffer->get_element_count();
+ pending = m_pkt_buffer->get_element_count();
+
return partial;
}
@@ -181,7 +190,7 @@ TrexStatelessCaptureMngr::fetch(capture_id_t capture_id, uint32_t pkt_limit, Tre
uint32_t pending = 0;
TrexPktBuffer *pkt_buffer = capture->fetch(pkt_limit, pending);
- rc.set_pkt_buffer(pkt_buffer, pending);
+ rc.set_pkt_buffer(pkt_buffer, pending, capture->get_start_ts());
}
void
@@ -223,7 +232,7 @@ TrexStatelessCaptureMngr::reset() {
}
void
-TrexStatelessCaptureMngr::handle_pkt_tx(const TrexPkt *pkt) {
+TrexStatelessCaptureMngr::handle_pkt_tx(TrexPkt *pkt) {
for (TrexStatelessCapture *capture : m_captures) {
capture->handle_pkt_tx(pkt);
}
diff --git a/src/stateless/rx/trex_stateless_capture.h b/src/stateless/rx/trex_stateless_capture.h
index 4a9efea7..bc1b88c5 100644
--- a/src/stateless/rx/trex_stateless_capture.h
+++ b/src/stateless/rx/trex_stateless_capture.h
@@ -121,10 +121,11 @@ public:
m_pending = 0;
}
- void set_pkt_buffer(const TrexPktBuffer *pkt_buffer, uint32_t pending) {
- m_pkt_buffer = pkt_buffer;
- m_pending = pending;
- m_rc = RC_OK;
+ void set_pkt_buffer(const TrexPktBuffer *pkt_buffer, uint32_t pending, dsec_t start_ts) {
+ m_pkt_buffer = pkt_buffer;
+ m_pending = pending;
+ m_start_ts = start_ts;
+ m_rc = RC_OK;
}
const TrexPktBuffer *get_pkt_buffer() const {
@@ -135,9 +136,14 @@ public:
return m_pending;
}
+ dsec_t get_start_ts() const {
+ return m_start_ts;
+ }
+
private:
const TrexPktBuffer *m_pkt_buffer;
uint32_t m_pending;
+ dsec_t m_start_ts;
};
class TrexCaptureRCRemove : public TrexCaptureRC {
@@ -245,7 +251,7 @@ public:
TrexStatelessCapture(capture_id_t id, uint64_t limit, const CaptureFilter &filter);
- void handle_pkt_tx(const TrexPkt *pkt);
+ void handle_pkt_tx(TrexPkt *pkt);
void handle_pkt_rx(const rte_mbuf_t *m, int port);
~TrexStatelessCapture();
@@ -274,11 +280,17 @@ public:
return m_pkt_buffer->get_element_count();
}
+ dsec_t get_start_ts() const {
+ return m_start_ts;
+ }
+
private:
state_e m_state;
TrexPktBuffer *m_pkt_buffer;
+ dsec_t m_start_ts;
CaptureFilter m_filter;
uint64_t m_id;
+ uint64_t m_pkt_index;
};
class TrexStatelessCaptureMngr {
@@ -341,7 +353,7 @@ public:
/**
* handle packet from TX
*/
- void handle_pkt_tx(const TrexPkt *pkt);
+ void handle_pkt_tx(TrexPkt *pkt);
/**
* handle packet from RX