How does Skype work without port forwarding?

旧城冷巷雨未停 提交于 2019-11-26 17:29:47

问题


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 another 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.


回答1:


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




回答2:


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




回答3:


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.




回答4:


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.




回答5:


Have some experience in implementing P2P applications and getting them to work behind NAT routers.

Skype uses UDP hole punching to work behind NAT routers. I have written an article and made a Demo video to help others implement similar applications. Also provided links to useful libraries that does most of the ground work like libutp, here.

>>> UDP hole punching Demo video and useful Libs.



来源:https://stackoverflow.com/questions/1539339/how-does-skype-work-without-port-forwarding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!