[BangPypers] UDP Hole Punching using python

kunal ghosh kunal.t2 at gmail.com
Fri Feb 25 16:12:31 CET 2011


Hi all, i am working on UDP hole punching to allow communication between two
computers hidden
behind their respective NATs (Home Router).

I have been able to achieve the same using netcat and hping3 , as described
here:
http://www.cyberciti.biz/tips/howto-linux-iptables-bypass-firewall-restriction.html

<http://www.cyberciti.biz/tips/howto-linux-iptables-bypass-firewall-restriction.html>in
short:
1. Register a SYN flag with the receiving router using hping.(punch a hole
in the NAT)
2. start listening for udp packets at the receiving computer.
3. send a udp packet from the sender to the receiver.

Now i try to do the same thing using python and sockets,
step 1: holepunch , send UDP packet from receiver to sender
from socket import *
s = socket(AF_INET,SOCK_DGRAM)
host = "<receiver ip>"
port = <receiver port>
s.bind((host,port))
s.sendto("Message",("<sender ip>",<sender port>))

here i get the following error
*error: [Errno 22] Invalid argument*
i dunno how to resolve this issue.

Also can someone plese help me out with the holepunching. Am i doing
something wrong ?
-- 
regards
-------
Kunal Ghosh
Dept of Computer Sc. & Engineering.
Sir MVIT
Bangalore,India

permalink: member.acm.org/~kunal.t2
Blog:kunalghosh.wordpress.com
Website:www.kunalghosh.net46.net


More information about the BangPypers mailing list