)
+ def test_simple_mac_default(self):
+
+ pkt = Ether()/IP()/UDP()
+
+
+ pkt_builder = CScapyTRexPktBuilder(pkt = pkt);
+
+ assert_equal( pkt_builder.is_def_src_mac () ,True)
+ assert_equal( pkt_builder.is_def_dst_mac () ,True)
+
+ pkt = Ether(src="00:00:00:00:00:01")/IP()/UDP()
+
+ pkt_builder = CScapyTRexPktBuilder(pkt = pkt);
+
+ assert_equal( pkt_builder.is_def_src_mac (), False)
+ assert_equal( pkt_builder.is_def_dst_mac (), True)
+
+ pkt = Ether(dst="00:00:00:00:00:01")/IP()/UDP()
+
+ pkt_builder = CScapyTRexPktBuilder(pkt = pkt);
+
+ assert_equal( pkt_builder.is_def_src_mac (),True)
+ assert_equal( pkt_builder.is_def_dst_mac (),False)
+
+
+
def test_simple_teredo(self):
else:
raise CTRexPacketBuildException(-14, "bad packet" )
-
+ def is_def_src_mac (self):
+ p = self.pkt
+ if isinstance(p, Packet):
+ if isinstance(p,Ether):
+ if 'src' in p.fields :
+ return False
+ return True
+
+ def is_def_dst_mac (self):
+ p = self.pkt
+ if isinstance(p, Packet):
+ if isinstance(p,Ether):
+ if 'dst' in p.fields :
+ return False
+ return True
def compile (self):
self.vm_low_level=CTRexVmEngine()
def __str__ (self):
return "Multi Burst"
+STLStreamDstMAC_CFG_FILE=0
+STLStreamDstMAC_PKT =1
+STLStreamDstMAC_ARP =2
+
+
class STLStream(object):
isg = 0.0,
rx_stats = None,
next = None,
- stream_id = None):
+ stream_id = None,
+ action_count =0,
+ mac_src_override_by_pkt=None,
+ mac_dst_override_mode=None #see STLStreamDstMAC_xx
+ ):
# type checking
if not isinstance(mode, STLTXMode):
self.set_id(stream_id)
self.set_next_id(None)
+
self.fields = {}
+ int_mac_src_override_by_pkt = 0;
+ int_mac_dst_override_mode = 0;
+
+
+ if mac_src_override_by_pkt == None:
+ int_mac_src_override_by_pkt=0
+ if packet :
+ if packet.is_def_src_mac ()==False:
+ int_mac_src_override_by_pkt=1
+
+ else:
+ int_mac_src_override_by_pkt = int(mac_src_override_by_pkt);
+
+ if mac_dst_override_mode == None:
+ int_mac_dst_override_mode = 0;
+ if packet :
+ if packet.is_def_dst_mac ()==False:
+ int_mac_dst_override_mode=STLStreamDstMAC_PKT
+ else:
+ int_mac_dst_override_mode = int(mac_dst_override_mode);
+
+
+ self.fields['flags'] = (int_mac_src_override_by_pkt&1) + ((int_mac_dst_override_mode&3)<<1)
+
+ self.fields['action_count'] = action_count
+
# basic fields
self.fields['enabled'] = enabled
self.fields['self_start'] = self_start
self_start = s_obj.get('self_start', defaults.fields['self_start']),
isg = s_obj.get('isg', defaults.fields['isg']),
rx_stats = s_obj.get('rx_stats', defaults.fields['rx_stats']),
- next = yaml_object.get('next'))
+ next = yaml_object.get('next'),
+ action_count = s_obj.get('action_count', defaults.fields['action_count']),
+ mac_src_override_by_pkt = s_obj.get('mac_src_override_by_pkt', 0),
+ mac_dst_override_mode = s_obj.get('mac_src_override_by_pkt', 0)
+ )
# hack the VM fields for now
if 'vm' in s_obj:
--- /dev/null
+from trex_stl_lib.api import *
+
+# stream will be sent with src MAC addrees dst="60:60:60:60:60:60" and not from default of trex_cfg.yaml port src mac
+class STLS1(object):
+
+ def create_stream (self):
+ return STLStream( packet = STLPktBuilder(pkt = Ether(dst="60:60:60:60:60:60")/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/(10*'x')),
+ mode = STLTXCont(),
+ #mac_dst_override_mode=STLStreamDstMAC_PKT # another way to explictly take it
+ )
+
+ def get_streams (self, direction = 0):
+ # create 1 stream
+ return [ self.create_stream() ]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
--- /dev/null
+from trex_stl_lib.api import *
+
+# stream will be sent with src MAC addrees dst="60:60:60:60:60:60" and not from default of trex_cfg.yaml port src mac
+class STLS1(object):
+
+ def create_stream (self):
+ return STLStream( packet = STLPktBuilder(pkt = Ether(src="61:61:61:61:61:61",dst="60:60:60:60:60:60")/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/(10*'x')),
+ mode = STLTXCont(),
+ #mac_dst_override_mode=STLStreamDstMAC_PKT # another way to explictly take it
+ )
+
+ def get_streams (self, direction = 0):
+ # create 1 stream
+ return [ self.create_stream() ]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
--- /dev/null
+from trex_stl_lib.api import *
+
+# stream will be sent with src MAC addrees src="60:60:60:60:60:60" and not from default of trex_cfg.yaml port src mac
+class STLS1(object):
+
+ def create_stream (self):
+ return STLStream( packet = STLPktBuilder(pkt = Ether(src="60:60:60:60:60:60")/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/(10*'x')),
+ mode = STLTXCont(),
+ #mac_src_override_by_pkt=True # another way to explictly take it
+ )
+
+ def get_streams (self, direction = 0):
+ # create 1 stream
+ return [ self.create_stream() ]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
/* some fields */
stream->m_enabled = parse_bool(section, "enabled", result);
stream->m_self_start = parse_bool(section, "self_start", result);
+ stream->m_flags = parse_int(section, "flags", result);
+ stream->m_action_count = (uint16_t)parse_int(section, "action_count", result);
/* inter stream gap */
stream->m_isg_usec = parse_double(section, "isg", result);
m_ibg_usec=0.0;
m_vm_dp = NULL;
m_flags=0;
- m_stream_count=0;
+ m_action_count=0;
}
TrexStream::~TrexStream() {
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;
+ dp->m_action_count = m_action_count;
return(dp);
}
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;
+ uint16_t m_action_count;
/* config fields */