Hello all,
I know this mailing list it is not about this kind of quastions. but I know
some of you have a good skills in scapy.
I am using the below code to send number of packets to iperf server, but the
procedure takes around 22 seconds becuese of the for loop.
How can I send them in 1 second ?
_____________________________
from scapy.all import *
import time,os
def generatePackets():
# three way handshake and sending packets
os.system("iptables -A OUTPUT -p tcp --sport 20 --tcp-flags RST RST -j
DROP")
#this value to send PA packet after 6 Ack packets
value=7
count=0
#data to be sent
data="scapy packet 123"
increment_sequence=len(data)
ip=IP(src='10.0.0.1', dst='10.0.0.2')
SYN=TCP(sport = 20, dport=80,flags='S', seq=0)
SYNACK=sr1(ip/SYN)
sequence=SYNACK.ack
ackno=SYNACK.seq+1
start_time = time.time()
finish_time = 0
for i in range(350):
if count%7==0:
#sending [PUSH ACK] packet
send(ip/TCP(window=40,dport=80, flags="PA", seq=sequence,
ack=SYNACK.seq+1)/data)
else:
#sending ACK packet
send(ip/TCP(dport=80, flags="A", seq=sequence,
ack=SYNACK.seq+1)/data)
count+=1
sequence+=increment_sequence
#close connection (ports)
packet=ip/TCP(dport=80, flags="FA", seq=sequence, ack=SYNACK.seq+1)
SYNACK = sr1(packet, inter=0.0001)
sequence=SYNACK.ack
ackno=SYNACK.seq+1
packet=ip/TCP(dport=80, flags="A", seq=sequence, ack=SYNACK.seq+1)
send(packet, inter=0.0001)
finish_time = time.time() - start_time
print "finish_time =", finish_time
if __name__ == '__main__':
generatePackets()
M.Sc Abdullah Soliman
Technische Universität Ilmenau
Fakultät für Elektrotechnik und Informationstechnik
Fachgebiet Kommunikationsnetze
Besucheradresse:
Helmholtzplatz 2
98693 Ilmenau
Postadresse:
PF 10 05 65
98684 Ilmenau
Telefon
+49 3677 69-2698
[cid:[email protected]]
[email protected]<mailto:[email protected]>
[cid:[email protected]]
www.tu-ilmenau.de/it-kn<https://www.tu-ilmenau.de/it-kn>
[cid:[email protected]]
[cid:[email protected]]
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel