Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In some messaging systems, two messaging clients send/receive packets directly from each other in chatting or voice call. I think the basic mechanism is (TCP for example): these client programs open a listening TCP socket and tell the messaging/coordinating server their IP/PORT pair. Then the client programs retrieve IP/PORT of the other side from the messaging/coordinating server. And one of them(let's say A) then initiates a TCP with the other one(let's say B) with the retrieved IP/PORT pair of B.

When the passive client B(who waits for the TCP SYN packet) is not behind NAT or a proxy, this is fine. But if B is behind a NAT or a proxy, then the IP/PORT pair is actually the public network interface of the NAT or the proxy.

So my question is, when a NAT or proxy receives a TCP SYN, what is its reaction? How do they relay the TCP SYN to the corresponding host/process behind it?

share|improve this question

If a TCP Syn is received then the NAT host will inspect the forwarding rules (translation table). If there is a rule that matches the details of the incoming packet (destination source/address) and map it to an inside system, then the packet will be re-written and forwarded to the appropriate inside host. If no entry in the translation table exists for that packet, then it will be either dropped, or a RST will be sent, depending on how the NAT is configured to handle invalid incoming connections.

share|improve this answer
but if a messenger opens a tcp listening socket with port number 3000, then how can it inform the NAT that it is listening on port 3000. do you know how those commercial applications make this viable? – misteryes Apr 2 '13 at 23:25
Most IM clients don't open a listening port. Instead they make an outgoing connection to the the IM server, and they don't close it. The point-to-point traffic of IM clients is almost always UDP based, which is easier to forge, and so you can play some tricks to do hole punching. If your router supports it there is UPnP that can negotiate with some routers to open ports , but this protocol is arguably a big security flaw, instead of a useful protocol, and isn't very common. - – Zoredache Apr 2 '13 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .