diff options
author | Ido Barnea <ibarnea@cisco.com> | 2017-03-22 10:39:16 +0200 |
---|---|---|
committer | Ido Barnea <ibarnea@cisco.com> | 2017-03-22 10:39:16 +0200 |
commit | ce79813cbdf7ccb9db7f3db9aab7a9c71005ecf0 (patch) | |
tree | 67605b7626ad32e950d33221ced20e653ca364ea | |
parent | fa8792d5faeabbd212dd252670bcca8d5b6eb412 (diff) |
Added to flow stat profile qinq example
Signed-off-by: Ido Barnea <ibarnea@cisco.com>
-rw-r--r-- | scripts/stl/flow_stats.py | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/scripts/stl/flow_stats.py b/scripts/stl/flow_stats.py index a50ba848..65956ff5 100644 --- a/scripts/stl/flow_stats.py +++ b/scripts/stl/flow_stats.py @@ -3,26 +3,47 @@ from trex_stl_lib.api import * class STLS1(object): """ Create flow stat stream of UDP packet. - Can specify using tunables the packet length (fsize) and packet group id (pg_id) + Can specify using tunables following params: + Packet length (fsize) + Packet group id (pg_id) + Packet type(pkt_type) + Number of streams (num_streams) """ def __init__ (self): self.fsize = 64 self.pg_id = 0 + self.pkt_type = "ether" + self.num_streams = 1 def _create_stream (self): size = self.fsize - 4; # HW will add 4 bytes ethernet CRC - 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' - pkt = STLPktBuilder(pkt = base_pkt/pad) - return [STLStream(packet = pkt, - mode = STLTXCont(pps=1), - flow_stats = STLFlowStats(pg_id = self.pg_id)) - ] + pkt_types = {"ether" : + Ether() / IP(src = "16.0.0.1", dst = "48.0.0.1") / UDP(dport = 12, sport = 1025) + , "vlan": + Ether() / Dot1Q(vlan=11) / IP(src = "16.0.0.1", dst = "48.0.0.1") / UDP(dport = 12, sport = 1025) + , "qinq": + Ether(type=0x88A8) / Dot1Q(vlan=19) / Dot1Q(vlan=11) / IP(src = "16.0.0.1", dst = "48.0.0.1") / UDP(dport = 12, sport = 1025) + } - def get_streams (self, fsize = 64, pg_id = 7, **kwargs): + if self.pkt_type not in pkt_types.keys(): + print ("Wrong pkt_type given. Allowed values are " + format(pkt_types.keys())) + return [] + + pad = max(0, size - len(self.pkt_type)) * 'x' + pkt = STLPktBuilder(pkt = pkt_types[self.pkt_type]/pad) + + streams = [] + for pg_id_add in range(0, self.num_streams): + streams.append(STLStream(packet = pkt, mode = STLTXCont(pps=1), flow_stats = STLFlowStats(pg_id = self.pg_id + pg_id_add))) + + return streams + + def get_streams (self, fsize = 64, pg_id = 1, pkt_type = "ether", num_streams = 1, **kwargs): self.fsize = fsize self.pg_id = pg_id + self.pkt_type = pkt_type + self.num_streams = num_streams return self._create_stream() # dynamic load - used for trex console or simulator |