Linux socket: set initial sequence number

Hi everyone.

First some background information:
It is possible to directly connect two hosts, both behind a NAT if both initiate a connection to each other.
The connection attempt first made will fail but add an entry with the other hosts adress to the routing table of the NAT which will then allow the other host to successfully connect. I don't know how this method is called (Skype uses it to initiate a p2p connection) but it works well for UDP if there already is an indirect connection through a third party host (to exchange the host adresses and time the connection attempts).
Now, I'm trying to do this using TCP. The Problem there is the sequence number. As it seems, the NATs keep track of the sequence number to associate a connection so the initial sequence number (ISN) of the second, successful connection must be the first connections ISN+1.

Now my question is:
How can I set the ISN of a TCP connection using the Linux/POSIX socket library?

Edit:
After some more reasearch, the only way seems to be to use a raw socket and somehow prevent it from dropping the incoming TCP packets so if there's no other way, I think it won't be of any use.
Last edited on
*push*

No ideas?
What you describe is called "hole punching". Take a look at:

http://www.brynosaurus.com/pub/net/p2pnat/

Note however that many NAT routers won't allow hole punching, as stated in the article.

Thanks but the article doesn't cover the sequence number problem (Does it?).
Topic archived. No new replies allowed.