diff options
author | 2016-05-03 16:09:00 +0300 | |
---|---|---|
committer | 2016-05-03 16:09:00 +0300 | |
commit | f27bfbab72f9221b221a7f36f4063e9ff8e9d307 (patch) | |
tree | a8775aa1c5063b5ed02fd13fbb94d541b696e91b /scripts/stl/udp_1pkt_simple.py | |
parent | dbe44f64ec7cff8d55400327e5f6994ac1fc87bb (diff) | |
parent | 737d92948a1bfd9f94fd31a4e207d0f9e6f028c0 (diff) |
Merge trex-204
Diffstat (limited to 'scripts/stl/udp_1pkt_simple.py')
-rw-r--r-- | scripts/stl/udp_1pkt_simple.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/scripts/stl/udp_1pkt_simple.py b/scripts/stl/udp_1pkt_simple.py index 0407f9c9..b84626a1 100644 --- a/scripts/stl/udp_1pkt_simple.py +++ b/scripts/stl/udp_1pkt_simple.py @@ -2,18 +2,21 @@ from trex_stl_lib.api import * class STLS1(object): - def create_stream (self): - return STLStream( - packet = - STLPktBuilder( - pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/ - UDP(dport=12,sport=1025)/(10*'x') - ), - mode = STLTXCont()) - - def get_streams (self, direction = 0, **kwargs): + def create_stream (self, packet_len, packet_count): + base_pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025) + base_pkt_len = len(base_pkt) + base_pkt /= 'x' * max(0, packet_len - base_pkt_len) + packets = [] + for i in range(packet_count): + packets.append(STLStream( + packet = STLPktBuilder(pkt = base_pkt), + mode = STLTXCont() + )) + return packets + + def get_streams (self, direction = 0, packet_len = 64, packet_count = 1, **kwargs): # create 1 stream - return [ self.create_stream() ] + return self.create_stream(packet_len - 4, packet_count) # dynamic load - used for trex console or simulator |