* [dts] [PATCH V1] add send a specified number of packages function
@ 2016-11-23 3:11 xu,gang
2016-12-14 7:58 ` Liu, Yong
0 siblings, 1 reply; 2+ messages in thread
From: xu,gang @ 2016-11-23 3:11 UTC (permalink / raw)
To: dts; +Cc: xu,gang
Signed-off-by: xu,gang <gangx.xu@intel.com>
---
framework/packet.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/framework/packet.py b/framework/packet.py
index 05a3d1f..f19a638 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -327,12 +327,12 @@ class scapy(object):
except:
pass
- def send_pcap_pkt(self, crb=None, file='', intf=''):
+ def send_pcap_pkt(self, crb=None, file='', intf='', count=1):
if intf == '' or file == '' or crb is None:
print "Invalid option for send packet by scapy"
return
- content = 'pkts=rdpcap(\"%s\");sendp(pkts, iface=\"%s\");exit()' % (file, intf)
+ content = 'pkts=rdpcap(\"%s\");sendp(pkts, iface=\"%s\", count=\"%s\" );exit()' % (file, intf, count)
cmd_file = '/tmp/scapy_%s.cmd' % intf
crb.create_file(content, cmd_file)
@@ -341,12 +341,12 @@ class scapy(object):
def print_summary(self):
print "Send out pkt %s" % self.pkt.summary()
- def send_pkt(self, intf=''):
+ def send_pkt(self, intf='', count=1):
self.print_summary()
if intf != '':
# fix fortville can't receive packets with 00:00:00:00:00:00
self.pkt.getlayer(0).src = get_if_hwaddr(intf)
- sendp(self.pkt, iface=intf)
+ sendp(self.pkt, iface=intf, count=count)
class Packet(object):
@@ -443,7 +443,7 @@ class Packet(object):
raw_confs['payload'] = payload
self.config_layer('raw', raw_confs)
- def send_pkt(self, crb=None, tx_port='', auto_cfg=True):
+ def send_pkt(self, crb=None, tx_port='', auto_cfg=True, count=1):
if tx_port == '':
print "Invalid Tx interface"
return
@@ -459,9 +459,9 @@ class Packet(object):
crb.session.copy_file_to(self.uni_name)
pcap_file = self.uni_name.split('/')[2]
self.pktgen.send_pcap_pkt(
- crb=crb, file=pcap_file, intf=self.tx_port)
+ crb=crb, file=pcap_file, intf=self.tx_port, count=count)
else:
- self.pktgen.send_pkt(intf=self.tx_port)
+ self.pktgen.send_pkt(intf=self.tx_port, count=count)
def check_layer_config(self, layer, config):
"""
--
1.9.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [PATCH V1] add send a specified number of packages function
2016-11-23 3:11 [dts] [PATCH V1] add send a specified number of packages function xu,gang
@ 2016-12-14 7:58 ` Liu, Yong
0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2016-12-14 7:58 UTC (permalink / raw)
To: xu,gang, dts
Applied, sorry for miss the mail.
On 11/23/2016 11:11 AM, xu,gang wrote:
> Signed-off-by: xu,gang <gangx.xu@intel.com>
> ---
> framework/packet.py | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/framework/packet.py b/framework/packet.py
> index 05a3d1f..f19a638 100755
> --- a/framework/packet.py
> +++ b/framework/packet.py
> @@ -327,12 +327,12 @@ class scapy(object):
> except:
> pass
>
> - def send_pcap_pkt(self, crb=None, file='', intf=''):
> + def send_pcap_pkt(self, crb=None, file='', intf='', count=1):
> if intf == '' or file == '' or crb is None:
> print "Invalid option for send packet by scapy"
> return
>
> - content = 'pkts=rdpcap(\"%s\");sendp(pkts, iface=\"%s\");exit()' % (file, intf)
> + content = 'pkts=rdpcap(\"%s\");sendp(pkts, iface=\"%s\", count=\"%s\" );exit()' % (file, intf, count)
> cmd_file = '/tmp/scapy_%s.cmd' % intf
>
> crb.create_file(content, cmd_file)
> @@ -341,12 +341,12 @@ class scapy(object):
> def print_summary(self):
> print "Send out pkt %s" % self.pkt.summary()
>
> - def send_pkt(self, intf=''):
> + def send_pkt(self, intf='', count=1):
> self.print_summary()
> if intf != '':
> # fix fortville can't receive packets with 00:00:00:00:00:00
> self.pkt.getlayer(0).src = get_if_hwaddr(intf)
> - sendp(self.pkt, iface=intf)
> + sendp(self.pkt, iface=intf, count=count)
>
>
> class Packet(object):
> @@ -443,7 +443,7 @@ class Packet(object):
> raw_confs['payload'] = payload
> self.config_layer('raw', raw_confs)
>
> - def send_pkt(self, crb=None, tx_port='', auto_cfg=True):
> + def send_pkt(self, crb=None, tx_port='', auto_cfg=True, count=1):
> if tx_port == '':
> print "Invalid Tx interface"
> return
> @@ -459,9 +459,9 @@ class Packet(object):
> crb.session.copy_file_to(self.uni_name)
> pcap_file = self.uni_name.split('/')[2]
> self.pktgen.send_pcap_pkt(
> - crb=crb, file=pcap_file, intf=self.tx_port)
> + crb=crb, file=pcap_file, intf=self.tx_port, count=count)
> else:
> - self.pktgen.send_pkt(intf=self.tx_port)
> + self.pktgen.send_pkt(intf=self.tx_port, count=count)
>
> def check_layer_config(self, layer, config):
> """
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-14 8:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-23 3:11 [dts] [PATCH V1] add send a specified number of packages function xu,gang
2016-12-14 7:58 ` Liu, Yong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).