summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2017-02-08 15:21:11 +0200
committerHanoh Haim <hhaim@cisco.com>2017-02-09 09:56:00 +0200
commit2dab8f65015e9fa90df395be6ee1a07e9ac71044 (patch)
treeaabab12f12e50e34f09f092c7f19dc7948de0134 /src
parentc9b62af88eb92ca403e43c34a2279c80d8d6f57b (diff)
move to active flows
Signed-off-by: Hanoh Haim <hhaim@cisco.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bp_sim.cpp31
-rwxr-xr-xsrc/bp_sim.h4
-rwxr-xr-xsrc/gtest/tuple_gen_test.cpp56
-rwxr-xr-xsrc/tuple_gen.cpp33
-rwxr-xr-xsrc/tuple_gen.h19
5 files changed, 82 insertions, 61 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index aa80c475..f540f21b 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -3541,6 +3541,8 @@ bool CFlowGenListPerThread::Create(uint32_t thread_id,
/* split the clients to threads */
CTupleGenYamlInfo * tuple_gen = &m_flow_list->m_yaml_info.m_tuple_gen;
+ double active_flows_per_core = flow_list->get_worse_case_active_flows()/(double)m_max_threads;
+
m_smart_gen.Create(0,m_thread_id);
/* split the clients to threads using the mask */
@@ -3553,8 +3555,7 @@ bool CFlowGenListPerThread::Create(uint32_t thread_id,
m_smart_gen.add_client_pool(tuple_gen->m_client_pool[i].m_dist,
portion.m_ip_start,
portion.m_ip_end,
- get_longest_flow(i,true),
- get_total_kcps(i,true)*1000,
+ active_flows_per_core,
m_flow_list->m_client_config_info,
tuple_gen->m_client_pool[i].m_tcp_aging_sec,
tuple_gen->m_client_pool[i].m_udp_aging_sec
@@ -3567,13 +3568,12 @@ bool CFlowGenListPerThread::Create(uint32_t thread_id,
m_smart_gen.add_server_pool(tuple_gen->m_server_pool[i].m_dist,
portion.m_ip_start,
portion.m_ip_end,
- get_longest_flow(i,false),
- get_total_kcps(i,false)*1000,
+ active_flows_per_core,
tuple_gen->m_server_pool[i].m_is_bundling);
}
- init_from_global(portion);
+ init_from_global();
CMessagingManager * rx_dp=CMsgIns::Ins()->getRxDp();
@@ -3645,7 +3645,7 @@ void CFlowGenListPerThread::defer_client_port_free(CGenNode *p){
/* copy all info from global and div by num of threads */
-void CFlowGenListPerThread::init_from_global(CIpPortion& portion){
+void CFlowGenListPerThread::init_from_global(){
/* copy generator , it is the same */
m_yaml_info =m_flow_list->m_yaml_info;
@@ -5002,6 +5002,25 @@ void CFlowGenList::dump_client_config(FILE *fd) {
m_client_config_info.dump(fd);
}
+/* take the total CPS and multi by the longest flow */
+double CFlowGenList::get_worse_case_active_flows(){
+ CFlowStats sum;
+ CFlowStats stats;
+ int i;
+ double max_duration=-1.0;
+
+ for (i=0; i<(int)m_cap_gen.size(); i++) {
+ CFlowGeneratorRec * lp=m_cap_gen[i];
+ lp->getFlowStats(&stats);
+
+ if ( stats.duration_sec > max_duration){
+ max_duration=stats.duration_sec;
+ }
+ sum.Add(stats);
+ }
+ return (sum.m_cps*max_duration);
+}
+
int CFlowGenList::update_active_flows(uint32_t active_flows){
double d_active_flow=(double)active_flows;
CFlowStats stats;
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 217446ed..a5153792 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -4000,7 +4000,7 @@ private:
void terminate_nat_flows(CGenNode *node);
- void init_from_global(CIpPortion &);
+ void init_from_global();
void defer_client_port_free(CGenNode *p);
void defer_client_port_free(bool is_tcp,uint32_t c_ip,uint16_t port,
uint8_t pool_idx, CTupleGeneratorSmart*gen);
@@ -4142,6 +4142,8 @@ public:
public:
/* update ipg in a way for */
int update_active_flows(uint32_t active_flows);
+ double get_worse_case_active_flows();
+
double get_total_kcps();
double get_total_pps();
double get_total_tx_bps();
diff --git a/src/gtest/tuple_gen_test.cpp b/src/gtest/tuple_gen_test.cpp
index fa760c6d..b350f74a 100755
--- a/src/gtest/tuple_gen_test.cpp
+++ b/src/gtest/tuple_gen_test.cpp
@@ -173,7 +173,7 @@ TEST(CClientInfoLTest, get_new_free_port) {
TEST(tuple_gen,clientPoolL) {
CClientPool gen;
gen.Create(cdSEQ_DIST,
- 0x10000001, 0x10000f01, 64000,1, g_dummy,
+ 0x10000001, 0x10000f01, 64000, g_dummy,
0,0);
CTupleBase result;
uint32_t result_src;
@@ -197,7 +197,7 @@ TEST(tuple_gen,clientPoolL) {
TEST(tuple_gen,clientPool) {
CClientPool gen;
gen.Create(cdSEQ_DIST,
- 0x10000001, 0x10000021, 64000,1000, g_dummy,
+ 0x10000001, 0x10000021, 64000000, g_dummy,
0,0);
CTupleBase result;
uint32_t result_src;
@@ -221,7 +221,7 @@ TEST(tuple_gen,clientPool) {
TEST(tuple_gen,serverPool) {
CServerPool gen;
gen.Create(cdSEQ_DIST,
- 0x30000001, 0x30000ff1, 64000,10);
+ 0x30000001, 0x30000ff1, 6400000);
CTupleBase result;
uint32_t result_dest;
@@ -236,7 +236,7 @@ TEST(tuple_gen,serverPool) {
gen.Delete();
gen.Create(cdSEQ_DIST,
- 0x30000001, 0x30000003, 64000,1000);
+ 0x30000001, 0x30000003, 64000000);
for(int i=0;i<10;i++) {
gen.GenerateTuple(result);
@@ -253,7 +253,7 @@ TEST(tuple_gen,serverPool) {
TEST(tuple_gen,servePoolSim) {
CServerPoolSimple gen;
gen.Create(cdSEQ_DIST,
- 0x30000001, 0x40000001, 64000,10);
+ 0x30000001, 0x40000001, 640000);
CTupleBase result;
uint32_t result_dest;
@@ -268,7 +268,7 @@ TEST(tuple_gen,servePoolSim) {
gen.Delete();
gen.Create(cdSEQ_DIST,
- 0x30000001, 0x30000003, 64000,1000);
+ 0x30000001, 0x30000003, 64000000);
for(int i=0;i<10;i++) {
gen.GenerateTuple(result);
@@ -289,12 +289,12 @@ TEST(tuple_gen,GenerateTuple2) {
CClientPool c_gen;
CClientPool c_gen_2;
c_gen.Create(cdSEQ_DIST,
- 0x10000001, 0x1000000f, 64000,4, g_dummy,
+ 0x10000001, 0x1000000f, 64000*4, g_dummy,
0,0);
CServerPool s_gen;
CServerPool s_gen_2;
s_gen.Create(cdSEQ_DIST,
- 0x30000001, 0x30000ff1, 64000,10);
+ 0x30000001, 0x30000ff1, 640000);
CTupleBase result;
uint32_t result_src;
@@ -318,10 +318,10 @@ TEST(tuple_gen,GenerateTuple2) {
c_gen.Delete();
// EXPECT_EQ((size_t)0, gen.m_clients.size());
c_gen.Create(cdSEQ_DIST,
- 0x10000001, 0x1000000f, 64000,400, g_dummy,
+ 0x10000001, 0x1000000f, 64000*400, g_dummy,
0,0);
s_gen.Create(cdSEQ_DIST,
- 0x30000001, 0x30000001, 64000,10);
+ 0x30000001, 0x30000001, 640000);
for(int i=0;i<200;i++) {
s_gen.GenerateTuple(result);
c_gen.GenerateTuple(result);
@@ -404,8 +404,8 @@ TEST(tuple_gen,split2) {
TEST(tuple_gen,template1) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4, g_dummy, 0, 0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000, g_dummy, 0, 0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
template_1.SetSingleServer(true,0x12121212,0,0);
@@ -429,8 +429,8 @@ TEST(tuple_gen,template1) {
TEST(tuple_gen,template2) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
template_1.SetW(10);
@@ -458,8 +458,8 @@ TEST(tuple_gen,template2) {
TEST(tuple_gen,no_free) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -480,8 +480,8 @@ TEST(tuple_gen,no_free) {
TEST(tuple_gen,try_to_free) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -507,8 +507,8 @@ TEST(tuple_gen,try_to_free) {
TEST(tuple_gen_2,GenerateTuple) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000f01,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000f01,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
CTupleBase result;
@@ -535,8 +535,8 @@ TEST(tuple_gen_2,GenerateTuple) {
TEST(tuple_gen_2,GenerateTuple2) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
CTupleBase result;
@@ -559,8 +559,8 @@ TEST(tuple_gen_2,GenerateTuple2) {
gen.Delete();
// EXPECT_EQ((size_t)0, gen.m_clients.size());
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,false);
template_1.Create(&gen,0,0);
for(int i=0;i<200;i++) {
template_1.GenerateTuple(result);
@@ -582,8 +582,8 @@ TEST(tuple_gen_2,GenerateTuple2) {
TEST(tuple_gen_2,template1) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
template_1.SetSingleServer(true,0x12121212,0,0);
@@ -609,8 +609,8 @@ TEST(tuple_gen_2,template1) {
TEST(tuple_gen_2,template2) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
- gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,g_dummy,0,0);
+ gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
template_1.SetW(10);
diff --git a/src/tuple_gen.cpp b/src/tuple_gen.cpp
index a4509580..14d51c3e 100755
--- a/src/tuple_gen.cpp
+++ b/src/tuple_gen.cpp
@@ -26,17 +26,26 @@ limitations under the License.
#include "bp_sim.h"
#include "tuple_gen.h"
+static bool _enough_ips(uint32_t total_ip,
+ double active_flows){
+ /* Socket utilization is lower than 20% */
+ if ( (active_flows/((double)total_ip*(double)MAX_PORT))>0.10 ) {
+ return(false);
+ }
+ return (true);
+}
+
void CServerPool::Create(IP_DIST_t dist_value,
uint32_t min_ip,
uint32_t max_ip,
- double l_flow,
- double t_cps) {
+ double active_flows
+ ) {
gen = new CIpPool();
gen->set_dist(dist_value);
uint32_t total_ip = max_ip - min_ip +1;
gen->m_ip_info.resize(total_ip);
- if (total_ip > ((l_flow*t_cps/MAX_PORT))) {
+ if ( _enough_ips(total_ip,active_flows) ) {
for(int idx=0;idx<total_ip;idx++){
gen->m_ip_info[idx] = new CServerInfoL();
gen->m_ip_info[idx]->set_ip(min_ip+idx);
@@ -55,8 +64,7 @@ void CServerPool::Create(IP_DIST_t dist_value,
void CClientPool::Create(IP_DIST_t dist_value,
uint32_t min_ip,
uint32_t max_ip,
- double l_flow,
- double t_cps,
+ double active_flows,
ClientCfgDB &client_info,
uint16_t tcp_aging,
uint16_t udp_aging) {
@@ -66,7 +74,7 @@ void CClientPool::Create(IP_DIST_t dist_value,
set_dist(dist_value);
uint32_t total_ip = max_ip - min_ip +1;
- bool is_long_range = total_ip > (l_flow * t_cps / MAX_PORT);
+ bool is_long_range = _enough_ips(total_ip,active_flows);
m_ip_info.resize(total_ip);
@@ -148,8 +156,7 @@ void CClientPool::allocate_configured_clients(uint32_t min_ip,
bool CTupleGeneratorSmart::add_client_pool(IP_DIST_t client_dist,
uint32_t min_client,
uint32_t max_client,
- double l_flow,
- double t_cps,
+ double active_flows,
ClientCfgDB &client_info,
uint16_t tcp_aging,
uint16_t udp_aging) {
@@ -158,8 +165,7 @@ bool CTupleGeneratorSmart::add_client_pool(IP_DIST_t client_dist,
pool->Create(client_dist,
min_client,
max_client,
- l_flow,
- t_cps,
+ active_flows,
client_info,
tcp_aging,
udp_aging);
@@ -171,8 +177,7 @@ bool CTupleGeneratorSmart::add_client_pool(IP_DIST_t client_dist,
bool CTupleGeneratorSmart::add_server_pool(IP_DIST_t server_dist,
uint32_t min_server,
uint32_t max_server,
- double l_flow,
- double t_cps,
+ double active_flows,
bool is_bundling){
assert(max_server>=min_server);
CServerPoolBase* pool;
@@ -181,8 +186,8 @@ bool CTupleGeneratorSmart::add_server_pool(IP_DIST_t server_dist,
else
pool = new CServerPoolSimple();
// we currently only supports mac mapping file for client
- pool->Create(server_dist, min_server, max_server,
- l_flow, t_cps);
+ pool->Create(server_dist, min_server, max_server,active_flows);
+
m_server_pool.push_back(pool);
return(true);
}
diff --git a/src/tuple_gen.h b/src/tuple_gen.h
index e9dc8d4e..59f97587 100755
--- a/src/tuple_gen.h
+++ b/src/tuple_gen.h
@@ -513,8 +513,7 @@ public:
void Create(IP_DIST_t dist_value,
uint32_t min_ip,
uint32_t max_ip,
- double l_flow,
- double t_cps,
+ double active_flows,
ClientCfgDB &client_info,
uint16_t tcp_aging,
uint16_t udp_aging);
@@ -547,8 +546,7 @@ class CServerPoolBase {
virtual void Create(IP_DIST_t dist_value,
uint32_t min_ip,
uint32_t max_ip,
- double l_flow,
- double t_cps) = 0;
+ double active_flows) = 0;
};
@@ -557,8 +555,8 @@ public:
void Create(IP_DIST_t dist_value,
uint32_t min_ip,
uint32_t max_ip,
- double l_flow,
- double t_cps) {
+ double active_flows
+ ) {
m_max_server_ip = max_ip;
m_min_server_ip = min_ip;
m_cur_server_ip = min_ip;
@@ -598,8 +596,7 @@ public:
void Create(IP_DIST_t dist_value,
uint32_t min_ip,
uint32_t max_ip,
- double l_flow,
- double t_cps);
+ double active_flows);
void Delete() {
if (gen!=NULL) {
@@ -690,8 +687,7 @@ public:
bool add_client_pool(IP_DIST_t client_dist,
uint32_t min_client,
uint32_t max_client,
- double l_flow,
- double t_cps,
+ double active_flows,
ClientCfgDB &client_info,
uint16_t tcp_aging,
uint16_t udp_aging);
@@ -699,8 +695,7 @@ public:
bool add_server_pool(IP_DIST_t server_dist,
uint32_t min_server,
uint32_t max_server,
- double l_flow,
- double t_cps,
+ double active_flows,
bool is_bundling);
CClientPool* get_client_pool(uint8_t idx) {