def run_py_profile_path (self, profile, options,silent = False, do_no_remove=False,compare =True):
output_cap = "a.pcap"
- input_file = os.path.join('stl/profiles/', profile)
+ input_file = os.path.join('stl/', profile)
golden_file = os.path.join('exp',os.path.basename(profile).split('.')[0]+'.pcap');
try:
rc = self.run_sim(input_file, output_cap, options, silent)
# VM
STLVmFlowVar = CTRexVmDescFlowVar
-STLVmWriteFlowVar = CTRexVmDescWrFlowVar
+STLVmWrFlowVar = CTRexVmDescWrFlowVar
STLVmFixIpv4 = CTRexVmDescFixIpv4
STLVmTrimPktSize = CTRexVmDescTrimPktSize
STLVmTupleGen = CTRexVmDescTupleGen
+STLVmTrimPktSize = CTRexVmDescTrimPktSize
# simulator
vm =[
# src
STLVmFlowVar(name="src",min_value=src['start'],max_value=src['end'],size=4,op="inc"),
- STLVmWriteFlowVar(fv_name="src",pkt_offset= "IP.src"),
+ STLVmWrFlowVar(fv_name="src",pkt_offset= "IP.src"),
# dst
STLVmFlowVar(name="dst",min_value=dst['start'],max_value=dst['end'],size=4,op="inc"),
- STLVmWriteFlowVar(fv_name="dst",pkt_offset= "IP.dst"),
+ STLVmWrFlowVar(fv_name="dst",pkt_offset= "IP.dst"),
# checksum
STLVmFixIpv4(offset = "IP")
-import sys
-import os
-
-# Should be removed
-# TBD fix this
-CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
-API_PATH = os.path.join(CURRENT_PATH, "../../api/stl")
-sys.path.insert(0, API_PATH)
-
-from scapy.all import *
-from trex_stl_api import *
+from trex_stl_lib.api import *
# 1 clients MAC override the LSB of destination
class STLS1(object):
-import sys
-import os
-
-# Should be removed
-# TBD fix this
-CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
-API_PATH = os.path.join(CURRENT_PATH, "../../api/stl")
-sys.path.insert(0, API_PATH)
-
-from scapy.all import *
-from trex_stl_api import *
+from trex_stl_lib.api import *
# 1 clients MAC override the LSB of destination
# overide the destination mac 00:bb::12:34:56:01 -00:bb::12:34:56:0a
-import sys
-import os
+from trex_stl_lib.api import *
-# Should be removed
-# TBD fix this
-CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
-API_PATH = os.path.join(CURRENT_PATH, "../../api/stl")
-sys.path.insert(0, API_PATH)
-
-from scapy.all import *
-from trex_stl_api import *
# 10 clients override the LSB of destination
class STLS1(object):
-import sys
-import os
-
-# Should be removed
-# TBD fix this
-CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
-API_PATH = os.path.join(CURRENT_PATH, "../../api/stl")
-sys.path.insert(0, API_PATH)
-
-from scapy.all import *
+from trex_stl_lib.api import *
from scapy.contrib.mpls import * # import from contrib folder of scapy
-from trex_stl_api import *
class STLS1(object):
-import sys
-import os
-
-# Should be removed
-# TBD fix this
-CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
-API_PATH = os.path.join(CURRENT_PATH, "../../api/stl")
-sys.path.insert(0, API_PATH)
-
-from scapy.all import *
+from trex_stl_lib.api import *
from scapy.contrib.mpls import * # import from contrib folder of scapy
-from trex_stl_api import *
class STLS1(object):
# 2 MPLS label the internal with s=1 (last one)
pkt = Ether()/MPLS(label=17,cos=1,s=0,ttl=255)/MPLS(label=0,cos=1,s=1,ttl=12)/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/('x'*20)
- vm = CTRexScRaw( [ CTRexVmDescFlowVar(name="mlabel", min_value=1, max_value=2000, size=2, op="inc"), # 2 bytes var
- CTRexVmDescWrFlowVar(fv_name="mlabel", pkt_offset= "MPLS:1.label") # LABEL is 20 bits expected is val*8 as 3 LSB are off, 16,32,64 .. using new instruction it will be possible to write to any bits
+ vm = CTRexScRaw( [ STLVmFlowVar(name="mlabel", min_value=1, max_value=2000, size=2, op="inc"), # 2 bytes var
+ STLVmWrFlowVar(fv_name="mlabel", pkt_offset= "MPLS:1.label") # LABEL is 20 bits expected is val*8 as 3 LSB are off, 16,32,64 .. using new instruction it will be possible to write to any bits
]
)
base_pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
pad = max(0, size - len(base_pkt)) * 'x'
-
- vm = CTRexScRaw( [ CTRexVmDescTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.2",
+
+ vm = CTRexScRaw( [ STLVmTupleGen ( ip_min="16.0.0.1", ip_max="16.0.0.2",
port_min=1025, port_max=65535,
name="tuple"), # define tuple gen
- CTRexVmDescWrFlowVar (fv_name="tuple.ip", pkt_offset= "IP.src" ), # write ip to packet IP.src
- CTRexVmDescFixIpv4(offset = "IP"), # fix checksum
- CTRexVmDescWrFlowVar (fv_name="tuple.port", pkt_offset= "UDP.sport" ) #write udp.port
+ STLVmWrFlowVar (fv_name="tuple.ip", pkt_offset= "IP.src" ), # write ip to packet IP.src
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+ STLVmWrFlowVar (fv_name="tuple.port", pkt_offset= "UDP.sport" ) #write udp.port
]
);
-import sys
-import os
-
-# Should be removed
-# TBD fix this
-CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
-API_PATH = os.path.join(CURRENT_PATH, "../../api/stl")
-sys.path.insert(0, API_PATH)
-
-from scapy.all import *
-from trex_stl_api import *
+from trex_stl_lib.api import *
class STLS1(object):
# vm
- vm = CTRexScRaw( [ CTRexVmDescFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="inc"),
- CTRexVmDescTrimPktSize("fv_rand"), # total packet size
- CTRexVmDescWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix), # fix ip len
- CTRexVmDescFixIpv4(offset = "IP"), # fix checksum
- CTRexVmDescWrFlowVar(fv_name="fv_rand", pkt_offset= "UDP.len", add_val=l4_len_fix) # fix udp len
+ vm = CTRexScRaw( [ STLVmFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="inc"),
+ STLVmTrimPktSize("fv_rand"), # total packet size
+ STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix), # fix ip len
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+ STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "UDP.len", add_val=l4_len_fix) # fix udp len
]
)
-
from trex_stl_lib.api import *
class STLS1(object):
# vm
- vm = CTRexScRaw( [ CTRexVmDescFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="random"),
- CTRexVmDescTrimPktSize("fv_rand"), # total packet size
- CTRexVmDescWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix), # fix ip len
- CTRexVmDescFixIpv4(offset = "IP"), # fix checksum
- CTRexVmDescWrFlowVar(fv_name="fv_rand", pkt_offset= "UDP.len", add_val=l4_len_fix) # fix udp len
+ vm = CTRexScRaw( [ STLVmFlowVar(name="fv_rand", min_value=64, max_value=len(base_pkt), size=2, op="random"),
+ STLVmTrimPktSize("fv_rand"), # total packet size
+ STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "IP.len", add_val=l3_len_fix), # fix ip len
+ STLVmFixIpv4(offset = "IP"), # fix checksum
+ STLVmWrFlowVar(fv_name="fv_rand", pkt_offset= "UDP.len", add_val=l4_len_fix) # fix udp len
]
)