scripts/exp/stl_vm_random_size_64_128.pcap
scripts/automation/regression/reports/unit_test.xml
scripts/automation/regression/unit_tests/functional_tests/test.pcap
+scripts/exp/stl_single_stream_mac0-0.erf
+scripts/exp/stl_single_stream_mac01-0.erf
+scripts/exp/stl_single_stream_mac10-0.erf
+scripts/exp/stl_single_stream_mac11-0.erf
+
#files generated by global
src/GPATH
try:
rc = self.run_sim(input_file, output_cap, options, silent)
assert_equal(rc, True)
+ #s='cp '+output_cap+' '+golden_file;
+ #print s
+ #os.system(s)
+
if compare:
self.compare_caps(output_cap, golden_file)
finally:
os.unlink(output_cap)
-
- # test for IMIX
- def test_imix (self):
- self.golden_run("basic_imix", "imix_3pkt", "-m 50kpps --limit 500 --cores 8", silent = False)
-
-
- def test_vm (self):
- self.golden_run("basic_imix_vm", "imix_3pkt_vm", "-m 50kpps --limit 500 --cores 8", silent = False)
-
-
- def test_tuple_gen (self):
- self.golden_run("basic_tuple_gen", "imix_tuple_gen", "-m 50kpps --limit 500 --cores 8", silent = False)
-
def test_stl_profiles (self):
p = [
["udp_1pkt_tuple_gen_split.py","-m 1 -c 2 -l 100",True],
["udp_1pkt_range_clients_split.py","-m 1 -c 2 -l 100",True],
["udp_1pkt_vxlan.py","-m 1 -c 1 -l 17",True],
- ["udp_1pkt_ipv6_in_ipv4.py","-m 1 -c 1 -l 17",True]
+ ["udp_1pkt_ipv6_in_ipv4.py","-m 1 -c 1 -l 17",True],
+ ["yaml/imix_3pkt.yaml","-m 50kpps --limit 20 --cores 2",True],
+ ["yaml/imix_3pkt_vm.yaml","-m 50kpps --limit 20 --cores 2",True],
+ #["yaml/imix_1pkt_tuple_gen.yaml","-m 50kpps --limit 20 --cores 2",True]
+
+ #imix_1pkt_tuple_gen.yaml
];
- p1 = [ ["udp_1pkt_ipv6_in_ipv4.py","-m 1 -c 1 -l 17",True] ]
+ #self.profiles['imix_3pkt'] = os.path.join(self.profiles_path, "imix_3pkt.yaml")
+ #self.profiles['imix_3pkt_vm'] = os.path.join(self.profiles_path, "imix_3pkt_vm.yaml")
+ #self.profiles['random_size_9k'] = os.path.join(self.profiles_path, "../udp_rand_len_9k.py")
+ #self.profiles['imix_tuple_gen'] = os.path.join(self.profiles_path, "imix_1pkt_tuple_gen.yaml")
+
+
+ p1 = [ ["yaml/imix_1pkt_tuple_gen.yaml","-m 50kpps --limit 20 --cores 2",True] ]
for obj in p:
lpt->m_node_gen.DumpHist(stdout);
cmp.d_sec = m_time_diff;
+ //compare
if ( cmp.compare(std::string(buf),std::string(buf_ex)) != true ) {
res=false;
}
verify_latency_pkt(uint8_t *p, uint8_t proto, uint16_t icmp_seq, uint8_t icmp_type) {
EthernetHeader *eth = (EthernetHeader *)p;
IPHeader *ip = (IPHeader *)(p + 14);
- uint8_t srcmac[]={0,0,0,1,0,0};
- uint8_t dstmac[]={0,0,0,1,0,0};
+ uint8_t srcmac[]={0x10,0x10,0x10,0x10,0x10,0x10};
+ //uint8_t dstmac[]={0x0,0x0,0x0,0x0,0x0,0x0};
latency_header * h;
// eth
EXPECT_EQ_UINT32(eth->getNextProtocol(), 0x0800)<< "Failed ethernet next protocol check";
EXPECT_EQ_UINT32(memcmp(p, srcmac, 6), 0)<< "Failed ethernet source MAC check";
- EXPECT_EQ_UINT32(memcmp(p, dstmac, 6), 0)<< "Failed ethernet dest MAC check";
+ //EXPECT_EQ_UINT32(memcmp(p, dstmac, 6), 0)<< "Failed ethernet dest MAC check";
// IP
EXPECT_EQ_UINT32(ip->getSourceIp(), l_pkt_test_s_ip)<< "Failed IP src check";
EXPECT_EQ_UINT32(ip->getDestIp(), l_pkt_test_d_ip)<< "Failed IP dst check";
}
+pkt_dir_t CErfIFStl::port_id_to_dir(uint8_t port_id) {
+ return ((pkt_dir_t)(port_id&1));
+}
+
+
+int CErfIFStl::update_mac_addr_from_global_cfg(pkt_dir_t dir, uint8_t * p){
+ memcpy(p,CGlobalInfo::m_options.get_dst_src_mac_addr(dir),12);
+ return (0);
+}
+
+
int CErfIFStl::send_node(CGenNode * _no_to_use){
if ( m_preview_mode->getFileWrite() ){
}
+
int CErfIF::send_node(CGenNode * node){
if ( m_preview_mode->getFileWrite() ){
public:
virtual int send_node(CGenNode * node);
+
+ virtual int update_mac_addr_from_global_cfg(pkt_dir_t dir, uint8_t * p);
+
+ virtual pkt_dir_t port_id_to_dir(uint8_t port_id);
+
+
};
/**
}
- virtual int update_mac_addr_from_global_cfg(pkt_dir_t dir, uint8_t * p){
- return (0);
- }
virtual int flush_tx_queue(void){
}
}
+#define CPY_BUFSIZE 1024
+
+bool CErfCmp::cpy(std::string src,std::string dst){
+
+ char mybuf[CPY_BUFSIZE] ;
+ FILE *ifd = NULL;
+ FILE *ofd = NULL;
+ ifd = fopen( src.c_str(), "rb" );
+ ofd = fopen( dst.c_str(), "w+");
+ assert(ifd!=NULL);
+ assert(ofd!=NULL);
+
+ int n;
+ while ( true){
+ n = fread(mybuf, sizeof(char), CPY_BUFSIZE ,ifd);
+ if (n>0) {
+ fwrite(mybuf, sizeof(char),n,ofd);
+ }else{
+ break;
+ }
+ }
+
+ fclose(ifd);
+ fclose(ofd);
+ return true;
+}
+
bool CErfCmp::compare(std::string f1, std::string f2 ){
d_sec=0.001;
}
bool compare(std::string f1, std::string f2 );
+
+ bool cpy(std::string src,std::string dst);
public:
bool dump;
double d_sec;
//lpt->m_node_gen.DumpHist(stdout);
cmp.d_sec = m_time_diff;
+
if ( cmp.compare(std::string(buf),std::string(buf_ex)) != true ) {
res=false;
}
+
TEST_F(basic_stl, single_pkt) {
CBasicStl t1;
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
}
+void test_mac_replace(bool replace_src_by_pkt,
+ int replace_dst_mode,
+ std::string file){
+ CBasicStl t1;
+ CParserOption * po =&CGlobalInfo::m_options;
+ po->preview.setVMode(7);
+ po->preview.setFileWrite(true);
+ po->out_file = file;
+
+ TrexStreamsCompiler compile;
+
+ uint8_t port_id=0;
+
+ std::vector<TrexStream *> streams;
+
+ TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0);
+ stream1->set_override_src_mac_by_pkt_data(replace_src_by_pkt);
+ stream1->set_override_dst_mac_mode((TrexStream::stream_dst_mac_t)replace_dst_mode);
+
+ stream1->set_pps(1.0);
+
+
+ stream1->m_enabled = true;
+ stream1->m_self_start = true;
+ stream1->m_port_id= port_id;
+
+
+ CPcapLoader pcap;
+ pcap.load_pcap_file("cap2/udp_64B.pcap",0);
+ pcap.update_ip_src(0x10000001);
+ pcap.clone_packet_into_stream(stream1);
+
+ streams.push_back(stream1);
+
+ // stream - clean
+
+ std::vector<TrexStreamsCompiledObj *>objs;
+ assert(compile.compile(port_id, streams, objs));
+ TrexStatelessDpStart *lpstart = new TrexStatelessDpStart(port_id, 0, objs[0], 10.0 /*sec */ );
+
+
+ t1.m_msg = lpstart;
+
+ bool res=t1.init();
+
+ delete stream1 ;
+
+ EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
+}
+
+TEST_F(basic_stl, single_pkt_mac0) {
+
+ test_mac_replace(false,
+ TrexStream::stCFG_FILE,
+ "exp/stl_single_stream_mac0");
+}
+
+TEST_F(basic_stl, single_pkt_mac11) {
+
+ test_mac_replace(true,
+ TrexStream::stPKT,
+ "exp/stl_single_stream_mac11");
+}
+
+TEST_F(basic_stl, single_pkt_mac10) {
+
+ test_mac_replace(false,
+ TrexStream::stPKT,
+ "exp/stl_single_stream_mac01");
+}
+
+TEST_F(basic_stl, single_pkt_mac01) {
+
+ test_mac_replace(true,
+ TrexStream::stCFG_FILE,
+ "exp/stl_single_stream_mac10");
+}
+
TEST_F(basic_stl, multi_pkt1) {
return 0;
}
+void set_default_mac_addr(){
+
+ int i;
+ for (i=0; i<4; i++) {
+ memset(CGlobalInfo::m_options.get_dst_src_mac_addr(i),((i+1)<<4),6);
+ memset(CGlobalInfo::m_options.get_src_mac_addr(i),((i+1)<<4)+8,6);
+ }
+}
+
int main(int argc , char * argv[]){
if ( parse_options(argc, argv, &CGlobalInfo::m_options , params) != 0) {
exit(-1);
}
+ set_default_mac_addr();
opt_type_e type = (opt_type_e) params["type"];
m_num_bursts=1;
m_ibg_usec=0.0;
m_vm_dp = NULL;
+ m_flags=0;
+ m_stream_count=0;
}
TrexStream::~TrexStream() {
#include <stdio.h>
#include <string.h>
#include <common/captureFile.h>
+#include <common/bitMan.h>
+
class TrexRpcCmdAddStream;
typedef uint8_t stream_type_t ;
+ enum DST_MAC_TYPE {
+ stCFG_FILE = 0,
+ stPKT = 1,
+ stARP = 2
+ };
+
+ typedef uint8_t stream_dst_mac_t ;
+
+
static std::string get_stream_type_str(stream_type_t stream_type);
public:
return (true);
}
}
-
-
/* can this stream be split ? */
bool is_splitable(uint8_t dp_core_count) const {
dp->m_burst_total_pkts = m_burst_total_pkts;
dp->m_num_bursts = m_num_bursts;
dp->m_ibg_usec = m_ibg_usec;
+ dp->m_flags = m_flags;
+ dp->m_stream_count = m_stream_count;
return(dp);
}
*/
void vm_compile();
+public:
+
+ void set_override_src_mac_by_pkt_data(bool enable){
+ btSetMaskBit16(m_flags,0,0,enable?1:0);
+ }
+
+ bool get_override_src_mac_by_pkt_data(){
+ return (btGetMaskBit16(m_flags,0,0) ?true:false);
+ }
+
+ void set_override_dst_mac_mode(stream_dst_mac_t val){
+ btSetMaskBit16(m_flags,2,1,val&0x3);
+ }
+
+ stream_dst_mac_t get_override_dst_mac_mode(){
+ return ((stream_dst_mac_t)btGetMaskBit16(m_flags,2,1));
+ }
+
public:
/* basic */
uint8_t m_type;
uint8_t m_port_id;
+ uint16_t m_flags;
uint32_t m_stream_id; /* id from RPC can be anything */
+ uint16_t m_stream_count;
/* config fields */
}
+void TrexStatelessDpCore::update_mac_addr(TrexStream * stream,
+ CGenNodeStateless *node,
+ pkt_dir_t dir,
+ char *raw_pkt){
+ bool ov_src = stream->get_override_src_mac_by_pkt_data();
+ TrexStream::stream_dst_mac_t ov_dst = stream->get_override_dst_mac_mode();
+
+
+ if ( (ov_src == true) && (ov_dst == TrexStream::stPKT) ) {
+ /* nothing to do, take from the packet both */
+ return;
+ }
+
+ /* take from cfg_file */
+ if ( (ov_src == false) &&
+ (ov_dst == TrexStream::stCFG_FILE) ){
+
+ m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir,(uint8_t*)raw_pkt);
+ return;
+ }
+
+ /* save the pkt*/
+ char tmp_pkt[12];
+ memcpy(tmp_pkt,raw_pkt,12);
+
+ m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir,(uint8_t*)raw_pkt);
+
+ if ((ov_src == true) && (ov_dst == TrexStream::stCFG_FILE)) {
+ memcpy(raw_pkt+6,tmp_pkt+6,6);
+ }
+
+ if ((ov_src == false) && (ov_dst == TrexStream::stPKT)) {
+ memcpy(raw_pkt,tmp_pkt,6);
+ }
+}
+
+
void
TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port,
TrexStream * stream,
node->m_single_burst=0;
node->m_single_burst_refill=0;
node->m_multi_bursts=0;
- node->m_ibg_sec = 0.0;
break;
case TrexStream::stSINGLE_BURST :
node->m_single_burst = stream->m_burst_total_pkts;
node->m_single_burst_refill = stream->m_burst_total_pkts;
node->m_multi_bursts = 1; /* single burst in multi burst of 1 */
- node->m_ibg_sec = 0.0;
break;
case TrexStream::stMULTI_BURST :
node->m_single_burst = stream->m_burst_total_pkts;
node->m_single_burst_refill = stream->m_burst_total_pkts;
node->m_multi_bursts = stream->m_num_bursts;
- node->m_ibg_sec = usec_to_sec( stream->m_ibg_usec );
break;
default:
/* copy the packet */
memcpy(p,stream_pkt,pkt_size);
- /* TBD repace the mac if req we should add flag */
- m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir,(uint8_t*) p);
+ update_mac_addr(stream,node,dir,p);
/* set the packet as a readonly */
node->set_cache_mbuf(m);
assert(p);
memcpy(p,stream_pkt , header_size);
- /* TBD repace the mac if req we should add flag */
- m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir, p);
+
+ update_mac_addr(stream,node,dir,(char *)p);
}
void add_global_duration(double duration);
+ void update_mac_addr(TrexStream * stream,
+ CGenNodeStateless *node,
+ uint8_t dir,
+ char *raw_pkt);
+
void add_stream(TrexStatelessDpPerPort * lp_port,
TrexStream * stream,
TrexStreamsCompiledObj *comp);
void * m_cache_mbuf;
double m_next_time_offset; /* in sec */
- double m_ibg_sec; /* inter burst time in sec */
-
+ uint32_t m_pad11;
+ uint32_t m_pad12;
stream_state_t m_state;
uint8_t m_port_id;
}
inline double get_multi_ibg_sec(){
- return (m_ibg_sec);
+ return (usec_to_sec(m_ref_stream_info->m_ibg_usec));
}
inline uint32_t get_multi_burst_cnt(){
}
}else{
- m_time += m_ibg_sec;
+ m_time += get_multi_ibg_sec();
m_single_burst = m_single_burst_refill;
thread->m_node_gen.m_p_queue.push( (CGenNode *)this);
}