summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-12-26 07:50:05 +0200
committerHanoh Haim <hhaim@cisco.com>2016-12-26 07:50:17 +0200
commit5b7974b82082637c835b181b105fc05193d127bf (patch)
treeb89128bb7d8fc32f1aee3587b69df1e0781a454b
parent82b3ac03ffb239be5ac1fceb01d3f359576edf03 (diff)
add --active-flows option to scale the active flows
Signed-off-by: Hanoh Haim <hhaim@cisco.com>
-rw-r--r--scripts/cap2/cur_flow_single.yaml21
-rwxr-xr-xsrc/bp_sim.cpp71
-rwxr-xr-xsrc/bp_sim.h7
-rw-r--r--src/main_dpdk.cpp17
4 files changed, 110 insertions, 6 deletions
diff --git a/scripts/cap2/cur_flow_single.yaml b/scripts/cap2/cur_flow_single.yaml
new file mode 100644
index 00000000..a5872da0
--- /dev/null
+++ b/scripts/cap2/cur_flow_single.yaml
@@ -0,0 +1,21 @@
+- duration : 0.1
+ generator :
+ distribution : "seq"
+ clients_start : "16.0.0.1"
+ clients_end : "16.0.0.255"
+ servers_start : "48.0.0.1"
+ servers_end : "48.0.255.255"
+ clients_per_gb : 201
+ min_clients : 101
+ dual_port_mask : "1.0.0.0"
+ tcp_aging : 0
+ udp_aging : 0
+ mac : [0x0,0x0,0x0,0x1,0x0,0x00]
+ #cap_ipg : true
+ cap_info :
+ - name: cap2/udp_10_pkts.pcap
+ cps : 100
+ ipg : 200
+ rtt : 200
+ w : 1
+
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index baf891ad..938d8f65 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -2502,6 +2502,33 @@ double CCapFileFlowInfo::get_cap_file_length_sec(){
}
+
+void CCapFileFlowInfo::update_ipg_by_factor(double factor,
+ CFlowYamlInfo * flow_info){
+ int i;
+
+ CCalcIpgDiff dtick_util(BUCKET_TIME_SEC);
+
+ for (i=0; i<(int)Size(); i++) {
+ CFlowPktInfo * lp=GetPacket((uint32_t)i);
+
+ /* update dtick from ipg */
+ double dtime=0;
+
+ if ( likely ( lp->m_pkt_indication.m_desc.IsPcapTiming()) ){
+ dtime = lp->m_pkt_indication.m_cap_ipg ;
+ }else{
+ if ( lp->m_pkt_indication.m_desc.IsRtt() ){
+ dtime = flow_info->m_rtt_sec ;
+ }else{
+ dtime = flow_info->m_ipg_sec;
+ }
+ }
+ lp->m_pkt_indication.m_cap_ipg = dtime*factor;
+ lp->m_pkt_indication.m_ticks = dtick_util.do_calc(dtime*factor);
+ }
+}
+
void CCapFileFlowInfo::update_min_ipg(dsec_t min_ipg,
dsec_t override_ipg){
@@ -3252,6 +3279,12 @@ void CFlowGeneratorRec::Dump(FILE *fd){
}
+void CFlowGeneratorRec::updateIpg(double factor){
+ m_flow_info.update_ipg_by_factor(factor,m_info);
+}
+
+
+
void CFlowGeneratorRec::getFlowStats(CFlowStats * stats){
double t_pkt=(double)m_flow_info.Size();
@@ -3260,13 +3293,9 @@ void CFlowGeneratorRec::getFlowStats(CFlowStats * stats){
double mb_sec = (cps*t_bytes*8.0)/(_1Mb_DOUBLE);
double mB_sec = (cps*t_bytes)/(_1Mb_DOUBLE);
- double c_flow_windows_sec=0.0;
+ double c_flow_windows_sec;
- if (m_info->m_cap_mode) {
- c_flow_windows_sec = m_flow_info.get_cap_file_length_sec();
- }else{
- c_flow_windows_sec = t_pkt * m_info->m_ipg_sec;
- }
+ c_flow_windows_sec = m_flow_info.get_cap_file_length_sec();
m_flow_info.get_total_memory(stats->m_memory);
@@ -4888,6 +4917,36 @@ void CFlowGenList::dump_client_config(FILE *fd) {
m_client_config_info.dump(fd);
}
+int CFlowGenList::update_active_flows(uint32_t active_flows){
+ double d_active_flow=(double)active_flows;
+ CFlowStats stats;
+ CFlowStats sum;
+ int i;
+
+ for (i=0; i<(int)m_cap_gen.size(); i++) {
+ CFlowGeneratorRec * lp=m_cap_gen[i];
+ lp->getFlowStats(&stats);
+ sum.Add(stats);
+ }
+
+ if (sum.m_c_flows <10) {
+ /* nothing to do */
+ return (0);
+ }
+ double ipg_factor = d_active_flow/sum.m_c_flows;
+
+ /* calc it again */
+ sum.Clear();
+ for (i=0; i<(int)m_cap_gen.size(); i++) {
+ CFlowGeneratorRec * lp=m_cap_gen[i];
+ lp->updateIpg(ipg_factor);
+ lp->getFlowStats(&stats);
+ sum.Add(stats);
+ }
+
+ return(0);
+}
+
int CFlowGenList::load_from_yaml(std::string file_name,
uint32_t num_threads){
uint8_t idx;
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 7f48601f..9cdfd30a 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -727,6 +727,7 @@ public:
m_tw_buckets = 1024;
m_tw_levels = 3;
m_tw_bucket_time_sec = (20.0/1000000.0);
+ m_active_flows=0;
}
@@ -734,6 +735,7 @@ public:
CPreviewMode preview;
uint16_t m_tw_buckets;
uint16_t m_tw_levels;
+ uint32_t m_active_flows;
float m_factor;
float m_mbuf_factor;
float m_duration;
@@ -3561,6 +3563,7 @@ public:
public:
void update_min_ipg(dsec_t min_ipg, dsec_t override_ipg);
+ void update_ipg_by_factor(double factor,CFlowYamlInfo * flow_info);
void update_pcap_mode();
void Dump(FILE *fd);
@@ -3712,6 +3715,8 @@ public:
void Dump(FILE *fd);
void getFlowStats(CFlowStats * stats);
+ void updateIpg(double factor);
+
public:
CCapFileFlowInfo m_flow_info;
CFlowYamlInfo * m_info;
@@ -4100,6 +4105,8 @@ public:
double GetCpuUtilRaw();
public:
+ /* update ipg in a way for */
+ int update_active_flows(uint32_t active_flows);
double get_total_kcps();
double get_total_pps();
double get_total_tx_bps();
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 320a21d3..9cc0e612 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -693,6 +693,7 @@ enum { OPT_HELP,
OPT_CLOSE,
OPT_ARP_REF_PER,
OPT_NO_OFED_CHECK,
+ OPT_ACTIVE_FLOW
};
/* these are the argument types:
@@ -748,9 +749,11 @@ static CSimpleOpt::SOption parser_options[] =
{ OPT_NO_WATCHDOG, "--no-watchdog", SO_NONE },
{ OPT_ALLOW_COREDUMP, "--allow-coredump", SO_NONE },
{ OPT_CHECKSUM_OFFLOAD, "--checksum-offload", SO_NONE },
+ { OPT_ACTIVE_FLOW, "--active-flows", SO_REQ_SEP },
{ OPT_CLOSE, "--close-at-end", SO_NONE },
{ OPT_ARP_REF_PER, "--arp-refresh-period", SO_REQ_SEP },
{ OPT_NO_OFED_CHECK, "--no-ofed-check", SO_NONE },
+
SO_END_OF_OPTIONS
};
@@ -818,6 +821,11 @@ static int usage(){
printf(" When configuring flow stat and latency per stream rules, assume all streams uses VLAN \n");
printf(" --vm-sim : Simulate vm with driver of one input queue and one output queue \n");
printf(" -w <num> : Wait num seconds between init of interfaces and sending traffic, default is 1 \n");
+
+ printf(" --active-flows : An experimental switch to scale up or down the number of active flows. \n");
+ printf(" It is not accurate due to the quantization of flow scheduler and in some case does not work. \n");
+ printf(" Example --active-flows 500000 wil set the ballpark of the active flow to be ~0.5M \n");
+
printf("\n");
printf(" Examples: ");
printf(" basic trex run for 20 sec and multiplier of 10 \n");
@@ -876,6 +884,7 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t
po->preview.setFileWrite(true);
po->preview.setRealTime(true);
uint32_t tmp_data;
+ float tmp_double;
po->m_run_mode = CParserOption::RUN_MODE_INVALID;
@@ -1037,6 +1046,10 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t
case OPT_PCAP:
po->preview.set_pcap_mode_enable(true);
break;
+ case OPT_ACTIVE_FLOW:
+ sscanf(args.OptionArg(),"%f", &tmp_double);
+ po->m_active_flows=(uint32_t)tmp_double;
+ break;
case OPT_RX_CHECK :
sscanf(args.OptionArg(),"%d", &tmp_data);
po->m_rx_check_sample=(uint16_t)tmp_data;
@@ -4944,6 +4957,10 @@ int CGlobalTRex::start_master_statefull() {
m_fl.Create();
m_fl.load_from_yaml(CGlobalInfo::m_options.cfg_file,get_cores_tx());
+ if ( CGlobalInfo::m_options.m_active_flows>0 ) {
+ m_fl.update_active_flows(CGlobalInfo::m_options.m_active_flows);
+ }
+
/* client config */
if (CGlobalInfo::m_options.client_cfg_file != "") {
try {