Beispiel #1
0
TEST(tuple_gen,GenerateTupleMac) {
    CFlowGenList  fl;
    fl.Create();
    fl.load_from_mac_file("avl/mac_uit.yaml");

    CClientPool gen;
    gen.Create(cdSEQ_DIST, 
               0x10000001,  0x1000000f, 64000,2, &fl.m_mac_info,true,0,0);

    CTupleBase result;
    uint32_t result_src;
    uint16_t result_port;
    mac_addr_align_t* result_mac;
    for(int i=0;i<10;i++) {
        gen.GenerateTuple(result);
        printf(" C:%x P:%d \n",result.getClient(),result.getClientPort());

        result_src = result.getClient();
        result_port = result.getClientPort();
        result_mac = result.getClientMac();
        EXPECT_EQ(result_src, (uint32_t)(0x10000001+i%2));
        EXPECT_EQ(result_port, 1024+i/2);
        printf("i:%d,mac:%d\n",i,result_mac->mac[3]);
        if (i%2==0)
            EXPECT_EQ(result_mac->mac[3], 5);
        else
            EXPECT_EQ(result_mac->mac[3], 1);
    }

    gen.Delete();
//    EXPECT_EQ((size_t)0, gen.m_clients.size());
}
Beispiel #2
0
void test_load_list_of_cap_files(CParserOption * op){

    CFlowGenList fl;
    CNullIF erf_vif;

    fl.Create();

    #define NUM 1

    fl.load_from_yaml(op->cfg_file,NUM);
    fl.DumpPktSize();
    
    
    fl.generate_p_thread_info(NUM);
    CFlowGenListPerThread   * lpt;

    /* set the ERF file */
    //fl.set_vif_all(&erf_vif);

    int i;
    for (i=0; i<NUM; i++) {
        lpt=fl.m_threads_info[i];
        char buf[100];
        sprintf(buf,"my%d.erf",i);
        lpt->generate_erf(buf,op->preview);
        lpt->m_node_gen.DumpHist(stdout);
    }
    //sprintf(buf,"my%d.erf",7);
    //lpt=fl.m_threads_info[7];

    //fl.Dump(stdout);
    fl.Delete();
}
Beispiel #3
0
int load_list_of_cap_files(CParserOption * op){
    CFlowGenList fl;
    fl.Create();
    fl.load_from_yaml(op->cfg_file,1);
    if ( op->preview.getVMode() >0 ) {
        fl.DumpCsv(stdout);
    }
    uint32_t start=    os_get_time_msec();

    CErfIF erf_vif;
    //CNullIF erf_vif;

    fl.generate_p_thread_info(1);
    CFlowGenListPerThread   * lpt;
    lpt=fl.m_threads_info[0];
    lpt->set_vif(&erf_vif);

    if ( (op->preview.getVMode() >1)  || op->preview.getFileWrite() ) {
        lpt->generate_erf(op->out_file,op->preview);
    }

    lpt->m_node_gen.DumpHist(stdout);

    uint32_t stop=    os_get_time_msec();
    printf(" d time = %ul %ul \n",stop-start,os_get_time_freq());
    fl.Delete();
    return (0);
}
Beispiel #4
0
void test_load_list_of_cap_files_linux(CParserOption * op){

    CFlowGenList fl;
    //CNullIF erf_vif;
    //CErfIF erf_vif;

    fl.Create();

    fl.load_from_yaml(op->cfg_file,cores);
    fl.DumpPktSize();

    
    fl.generate_p_thread_info(cores);
    CFlowGenListPerThread   * lpt;

    /* set the ERF file */
    //fl.set_vif_all(&erf_vif);

    int i;
    for (i=0; i<cores; i++) {
        lpt=fl.m_threads_info[i];
        test_t_info1 * obj = new test_t_info1();
        obj->preview_info =&op->preview;
        obj->thread_info  = fl.m_threads_info[i];
        obj->thread_id    = i;
        CNullIF * erf_vif = new CNullIF();
        //CErfIF  * erf_vif = new CErfIF();

        lpt->set_vif(erf_vif);

        assert(pthread_create( &tr_info[i].tid, NULL, thread_task, obj)==0);
    }

    for (i=0; i<cores; i++) {
        /* wait for all of them to stop */
       assert(pthread_join((pthread_t)tr_info[i].tid,NULL )==0);
    }

    printf("compare files \n");
    for (i=1; i<cores; i++) {

        CErfCmp cmp;
        char buf[100];
        sprintf(buf,"my%d.erf",i);
        char buf1[100];
        sprintf(buf1,"my%d.erf",0);
        if ( cmp.compare(std::string(buf),std::string(buf1)) != true ) {
            printf(" ERROR cap file is not ex !! \n");
            assert(0);
        }
        printf(" thread %d is ok \n",i);
    }

    fl.Delete();
}