Search code examples
udpxmppskypegoogle-talk

How can Skype and Google Talk be mostly peer to peer?


I've read a lot on this subject, including a lot on SO. So while not exactly a programming question, hopefully ok to ask here. I am a programmer and building an app that includes voice chat, if that helps.

I'm trying to understand how UDP forwarding works through a NAT, specifically for systems like Skype and Google Talk voice chat (VOIP).

I thought the only way a router could correctly route UDP traffic was if the reply came back from the same IP/port combo that it sent a packet to. Or in other words, the client can't get a UDP packet from a server unless it first sends one, otherwise the router has no idea which client to send the packet to.

So if I understand correctly, services like Skype and Google Talk do some initial setup to help peers locate each other, but after that the communication becomes peer to peer. How can the first packet from a client ever get directly to the other client if the router isn't expecting any traffic from the client's IP?


Solution

  • I'm studying it, because I'm making a game (university work) P2P.

    1 How does NAT? When a client makes a request, the NAT forwards available through a door (note that this port is independent of the port on the computer that sent it), and changes the source ip to your ip (public IP of the router). Now comes the magic: It stores a table in the ip and port associated with that request and the door of the route he used to send the message. So when the router receives a request, it looks and what is the door and the table to see who should send the request, regardless of ip or port that made it.

    2 How do I configure NAT for a "remote client"? Impossible. But the client can set up "your" NAT indirectly. It is necessary a server to mediate the initiation of the connection. * Client1 cliente2 and connects to the server, the server sends to the client1 ip and port (NAT) of cliente2. * The client1 now have the data to connect to cliente2, and so he sends the same connection to the server, receives the data cliente2 identically to the data server.

    Note1: TCP does not work for reasons obvious, ie must be UDP. Note2: How long the data is in the NAT table, how to prevent "timeout"? Good question, as I said I'm studying studying it lol, if anyone knows put at here.

    Felippi CM