user3470464
user3470464

Reputation: 11

Multi Threading in scapy for sending packet

I need to send many packet at the same time in Scapy, for example i need to run this command at the same time:

send(IP(dst="69.69.69.69"),loop=1)

Is there any way to multi-thread this command? Or something to send packet in parallel? Sorry about that, I am not an expert programmer.

Upvotes: 1

Views: 3345

Answers (1)

M. Haris Azfar
M. Haris Azfar

Reputation: 618

import threading
import time
from scapy.all import *
LENGTH = 100 # min
life = 0

a=IP()
a.src="10.0.0.4"
a.dst="10.0.0.5"

def send_pkts():
    global a
    send(a)
    global life
    life = life +1
    if life<LENGTH*60:
        t=threading.Timer(1,send_pkts,())
        t.start()

t=threading.Timer(1,send_pkts,())
t.start()

Upvotes: 1

Related Questions