diff options
author | imarom <imarom@cisco.com> | 2017-02-26 14:21:07 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2017-02-26 14:26:51 +0200 |
commit | f34d418db773ad900a0dfb600d66d4892bb8a341 (patch) | |
tree | 2f5c27957340646643079b059d93e1a25a746b03 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py | |
parent | bed055d35b3ce5be1dd68ea7635dcf2e2da81567 (diff) |
added 'pkt' console command to help with debugging single packets transmit
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py')
-rwxr-xr-x | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py index a3e04ab6..6b5183ba 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py @@ -4412,3 +4412,49 @@ class STLClient(object): self.set_service_mode(ports = opts.ports, enabled = opts.enabled) + @__console + def pkt_line (self, line): + ''' + Sends a Scapy format packet + ''' + + parser = parsing_opts.gen_parser(self, + "pkt", + self.pkt_line.__doc__, + parsing_opts.PORT_LIST_WITH_ALL, + parsing_opts.FORCE, + parsing_opts.COUNT, + parsing_opts.DRY_RUN, + parsing_opts.SCAPY_PKT_CMD) + + opts = parser.parse_args(line.split()) + if not opts: + return opts + + # show layers option + if opts.layers: + self.logger.log(format_text('\nRegistered Layers:\n', 'underline')) + self.logger.log(parsing_opts.ScapyDecoder.formatted_layers()) + return + + # dry run option + if opts.dry: + self.logger.log(format_text('\nPacket (Size: {0}):\n'.format(format_num(len(opts.scapy_pkt), suffix = 'B')), 'bold', 'underline')) + opts.scapy_pkt.show2() + self.logger.log(format_text('\n*** DRY RUN - no traffic was injected ***\n', 'bold')) + return + + + self.logger.pre_cmd("Pushing {0} packet(s) (size: {1}) on port(s) {2}:".format(opts.count if opts.count else 'infinite', + len(opts.scapy_pkt), opts.ports)) + + try: + with self.logger.supress(): + self.push_packets(pkts = bytes(opts.scapy_pkt), ports = opts.ports, force = opts.force, count = opts.count) + except STLError as e: + self.logger.post_cmd(False) + raise + else: + self.logger.post_cmd(RC_OK()) + +
\ No newline at end of file |