开发者

How does Skype work without port forwarding?

I am designing a p2p application which works on port 30000. My router is not UPnP so I required to forward a port to router. But Skype a anot开发者_StackOverflow社区her p2p application works without port forwarding on my pc. When I analyzed it with wireshark I found its using UDP port 48980, 58544. I am using c++.

There is a library in python here which does it for Nat PnP routers. Is it possible to programmatically forward port to router irrespective of type of router and operating system. What should be the approach to do it in c++ or any other language.


Skype works in a very interesting way. From what I've read (and this is a while ago) it works as follows:

  • Skype server maintains a list of all users and IPs.
  • Skype user A wants to speak to user B
  • Skype user A sends a network packet to user B's IP address and waits for a response. (user B never gets this packet).
  • Skype user A notifies server of IP/port combination on which it is waiting for a response
  • Server notifies user B to send a response to user A on the specified port
  • A connection is made.

This is probably over simplified but last I checked, this is how it works. (Someone correct me if I'm wrong).

Edit: fixed bullet issue


UDP hole punching is (one) of ways how to traverse through the NAT.


You have to use an intermediary server, and initiate communication from the client side. As Yossarian mentioned, from that point one possibility is UDP hole punching. Depending on the type of application (and whether it's truly P2P or not) you might keep the go-between server in place the entire time.


Skype uses another peers as intermediate point when direct connection is not possible.

i.e. Peer A wants to connect to peer B, but peer B has all ports closed, then communication is initiated through peer C which has open ports.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜