Search code examples
pythontcpudpipscapy

I try to send UDP package by scapy but failed,Why?


I setup my UDP server by python code below.

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('192.168.8.104', 9999))

print('Bind UDP on 9999...')

while True:
    data, addr = s.recvfrom(1024)
    print('Received from %s ---> %s' % (addr, data.decode("utf-8")))

and then,I try to send UPD package by scapy.

send(IP(src="192.168.8.110",dst="192.168.8.104")/UDP(dport=9999,sport=5678)/"Hello scapy udp")

result is Sent 1 packets.in terminal.But I can't see anything in my udp server logout.

and then,I try to use another way to send UPD package like this:

sr1(IP(src="192.168.8.110",dst="192.168.8.104")/UDP(dport=9999,sport=5678)/"Hello scapy udp")

IT WORKED(I mean that i can see logout in my UDP server)!!!WHY?????Can somebody answer for me.


Solution

  • This is a bug.And the maintainer has fixed it.