summaryrefslogtreecommitdiffstats
path: root/scripts/stl/udp_1pkt_mpls_vm.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/stl/udp_1pkt_mpls_vm.py')
-rw-r--r--scripts/stl/udp_1pkt_mpls_vm.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/stl/udp_1pkt_mpls_vm.py b/scripts/stl/udp_1pkt_mpls_vm.py
new file mode 100644
index 00000000..262a662f
--- /dev/null
+++ b/scripts/stl/udp_1pkt_mpls_vm.py
@@ -0,0 +1,32 @@
+from trex_stl_lib.api import *
+from scapy.contrib.mpls import * # import from contrib folder of scapy
+
+
+class STLS1(object):
+
+ def __init__ (self):
+ pass;
+
+ def create_stream (self):
+ # 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( [ 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
+ ]
+ )
+
+ # burst of 100 packets
+ return STLStream(packet = STLPktBuilder(pkt = pkt ,vm = vm),
+ mode = STLTXSingleBurst( pps = 1, total_pkts = 100) )
+
+
+ def get_streams (self, direction = 0):
+ # create 1 stream
+ return [ self.create_stream() ]
+
+def register():
+ return STLS1()
+
+
+