summaryrefslogtreecommitdiffstats
path: root/src/bp_sim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bp_sim.cpp')
-rwxr-xr-xsrc/bp_sim.cpp149
1 files changed, 104 insertions, 45 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index c3581c55..72da7089 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -25,7 +25,6 @@ limitations under the License.
#include "msg_manager.h"
#include <common/basic_utils.h>
-
#undef VALG
#ifdef VALG
@@ -279,7 +278,7 @@ void CPlatformSocketInfoConfig::dump(FILE *fd){
fprintf(fd," \n");
fprintf(fd," active sockets : %d \n",max_num_active_sockets());
- fprintf(fd," ports_sockets : \n",max_num_active_sockets());
+ fprintf(fd," ports_sockets : %d \n",max_num_active_sockets());
for (i=0; i<(MAX_LATENCY_PORTS); i++) {
fprintf(fd,"%d,",port_to_socket(i));
@@ -3114,10 +3113,6 @@ int CNodeGenerator::close_file(CFlowGenListPerThread * thread){
return (0);
}
-int CNodeGenerator::flush_one_node_to_file(CGenNode * node){
- BP_ASSERT(m_v_if);
- return (m_v_if->send_node(node));
-}
int CNodeGenerator::update_stats(CGenNode * node){
if ( m_preview_mode.getVMode() >2 ){
@@ -3204,6 +3199,10 @@ bool CFlowGenListPerThread::Create(uint32_t thread_id,
assert(m_ring_from_rx);
assert(m_ring_to_rx);
+
+ /* create the info required for stateless DP core */
+ m_stateless_dp_info = new TrexStatelessDpCore(thread_id, this);
+
return (true);
}
@@ -3351,6 +3350,9 @@ void CFlowGenListPerThread::Delete(){
m_node_gen.Delete();
Clean();
m_cpu_cp_u.Delete();
+
+ delete m_stateless_dp_info;
+ m_stateless_dp_info = NULL;
}
@@ -3455,49 +3457,56 @@ int CNodeGenerator::flush_file(dsec_t max_time,
uint8_t type=node->m_type;
- if ( likely( type == CGenNode::FLOW_PKT ) ) {
- /* PKT */
- if ( !(node->is_repeat_flow()) || (always==false)) {
- flush_one_node_to_file(node);
- #ifdef _DEBUG
- update_stats(node);
- #endif
- }
- m_p_queue.pop();
- if ( node->is_last_in_flow() ) {
- if ((node->is_repeat_flow()) && (always==false)) {
- /* Flow is repeated, reschedule it */
- thread->reschedule_flow( node);
- }else{
- /* Flow will not be repeated, so free node */
- thread->free_last_flow_node( node);
- }
- }else{
- node->update_next_pkt_in_flow();
- m_p_queue.push(node);
- }
+ if ( type == CGenNode::STATELESS_PKT ) {
+ m_p_queue.pop();
+ // TODO: should this be inlined ? with IPO is this important ?
+ thread->m_stateless_dp_info->handle_pkt_event(node);
+
}else{
- if ((type == CGenNode::FLOW_FIF)) {
- /* callback to our method */
+ if ( likely( type == CGenNode::FLOW_PKT ) ) {
+ /* PKT */
+ if ( !(node->is_repeat_flow()) || (always==false)) {
+ flush_one_node_to_file(node);
+ #ifdef _DEBUG
+ update_stats(node);
+ #endif
+ }
m_p_queue.pop();
- if ( always == false) {
- thread->m_cur_time_sec = node->m_time ;
-
- if ( thread->generate_flows_roundrobin(&done) <0){
- break;
+ if ( node->is_last_in_flow() ) {
+ if ((node->is_repeat_flow()) && (always==false)) {
+ /* Flow is repeated, reschedule it */
+ thread->reschedule_flow( node);
+ }else{
+ /* Flow will not be repeated, so free node */
+ thread->free_last_flow_node( node);
}
- if (!done) {
- node->m_time +=d_time;
- m_p_queue.push(node);
+ }else{
+ node->update_next_pkt_in_flow();
+ m_p_queue.push(node);
+ }
+ }else{
+ if ((type == CGenNode::FLOW_FIF)) {
+ /* callback to our method */
+ m_p_queue.pop();
+ if ( always == false) {
+ thread->m_cur_time_sec = node->m_time ;
+
+ if ( thread->generate_flows_roundrobin(&done) <0){
+ break;
+ }
+ if (!done) {
+ node->m_time +=d_time;
+ m_p_queue.push(node);
+ }else{
+ thread->free_node(node);
+ }
}else{
thread->free_node(node);
}
+
}else{
- thread->free_node(node);
+ handle_slow_messages(type,node,thread,always);
}
-
- }else{
- handle_slow_messages(type,node,thread,always);
}
}
}
@@ -3558,9 +3567,12 @@ void CNodeGenerator::handle_slow_messages(uint8_t type,
}else{
if ( type == CGenNode::FLOW_SYNC ){
+
+ m_p_queue.pop();
+
thread->check_msgs(); /* check messages */
m_v_if->flush_tx_queue(); /* flush pkt each timeout */
- m_p_queue.pop();
+
if ( always == false) {
node->m_time += SYNC_TIME_OUT;
m_p_queue.push(node);
@@ -3809,11 +3821,15 @@ void CFlowGenListPerThread::handel_nat_msg(CGenNodeNatInfo * msg){
}
}
+void CFlowGenListPerThread::check_msgs(void) {
-void CFlowGenListPerThread::check_msgs(void){
- if ( likely ( m_ring_from_rx->isEmpty() ) ){
+ /* inlined for performance */
+ m_stateless_dp_info->periodic_check_for_cp_messages();
+
+ if ( likely ( m_ring_from_rx->isEmpty() ) ) {
return;
}
+
#ifdef NAT_TRACE_
printf(" %.03f got message from RX \n",now_sec());
#endif
@@ -3833,9 +3849,11 @@ void CFlowGenListPerThread::check_msgs(void){
case CGenNodeMsgBase::NAT_FIRST:
handel_nat_msg((CGenNodeNatInfo * )msg);
break;
+
case CGenNodeMsgBase::LATENCY_PKT:
handel_latecy_pkt_msg((CGenNodeLatencyPktInfo *) msg);
break;
+
default:
printf("ERROR pkt-thread message type is not valid %d \n",msg_type);
assert(0);
@@ -3845,8 +3863,48 @@ void CFlowGenListPerThread::check_msgs(void){
}
}
+void delay(int msec);
+
+
+const uint8_t test_udp_pkt[]={
+ 0x00,0x00,0x00,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x01,0x00,0x00,
+ 0x08,0x00,
+
+ 0x45,0x00,0x00,0x81,
+ 0xaf,0x7e,0x00,0x00,
+ 0x12,0x11,0xd9,0x23,
+ 0x01,0x01,0x01,0x01,
+ 0x3d,0xad,0x72,0x1b,
+
+ 0x11,0x11,
+ 0x11,0x11,
+
+ 0x00,0x6d,
+ 0x00,0x00,
+
+ 0x64,0x31,0x3a,0x61,
+ 0x64,0x32,0x3a,0x69,0x64,
+ 0x32,0x30,0x3a,0xd0,0x0e,
+ 0xa1,0x4b,0x7b,0xbd,0xbd,
+ 0x16,0xc6,0xdb,0xc4,0xbb,0x43,
+ 0xf9,0x4b,0x51,0x68,0x33,0x72,
+ 0x20,0x39,0x3a,0x69,0x6e,0x66,0x6f,
+ 0x5f,0x68,0x61,0x73,0x68,0x32,0x30,0x3a,0xee,0xc6,0xa3,
+ 0xd3,0x13,0xa8,0x43,0x06,0x03,0xd8,0x9e,0x3f,0x67,0x6f,
+ 0xe7,0x0a,0xfd,0x18,0x13,0x8d,0x65,0x31,0x3a,0x71,0x39,
+ 0x3a,0x67,0x65,0x74,0x5f,0x70,0x65,0x65,0x72,0x73,0x31,
+ 0x3a,0x74,0x38,0x3a,0x3d,0xeb,0x0c,0xbf,0x0d,0x6a,0x0d,
+ 0xa5,0x31,0x3a,0x79,0x31,0x3a,0x71,0x65,0x87,0xa6,0x7d,
+ 0xe7
+};
+
+void CFlowGenListPerThread::start_stateless_daemon(){
+ m_stateless_dp_info->start();
+}
+
-void CFlowGenListPerThread::generate_erf(std::string erf_file_name,
+void CFlowGenListPerThread::start_generate_stateful(std::string erf_file_name,
CPreviewMode & preview){
/* now we are ready to generate*/
if ( m_cap_gen.size()==0 ){
@@ -3963,6 +4021,7 @@ int CFlowGenList::load_from_mac_file(std::string file_name) {
exit(-1);
}
+ return (0);
}