Patent ID: 9369523
Filing Date: 2016-06-14
CPC Classification: H04L

Claim Text:
1. A method for exchanging network messages in a distributed manner, the method being applicable to a peer-to-peer (P2P) network system comprising a first network terminal, a second network terminal, a third network terminal, a tracker/coordinator, and a protocol server, the first network terminal comprising a first network device and a first Network Address Translator (NAT) router through which the first network device is connectable to the Internet, the second network terminal comprising a second network device and a second NAT router through which the second network device is connectable to the Internet, the third network terminal comprising a third network device and a third NAT router through which the third network device is connectable to the Internet, the tracker/coordinator and the protocol server being located in a public network, the first NAT router being incapable of forwarding messages, the second NAT router being capable of forwarding messages, the method comprising the steps, to be performed by the tracker/coordinator, of: receiving through the Internet a server address query request sent by the first or the second network device; providing an address of the protocol server to the first or the second network device according to the server address query request, for enabling the first or the second network device to connect to and communicate with the protocol server through the Internet and conduct NAT behavior tests on the first or the second NAT router through the protocol server; receiving a first registration request sent by the first network device after the first network device has determined, according to responses of the protocol server, that the first NAT router is incapable of forwarding messages and after the first network device has opened a first device port; recording a first mapped address of the first device port as a first service port according to the first registration request, wherein the first mapped address corresponds to the first NAT router; and recording that the first NAT router is incapable of forwarding messages; receiving a second registration request sent by the second network device after the second network device has determined, according to responses of the protocol server, that the second NAT router is capable of forwarding messages and after the second network device has opened a second device port; recording a second mapped address of the second device port as a second service port according to the second registration request, wherein the second mapped address corresponds to the second NAT router; and recording that the second NAT router is capable of forwarding messages; receiving a forwarding request of the first network terminal; sending a first assignment message to the first network device according to the forwarding request, the first assignment message including identification information of the second network device for enabling the first network device to send an assignment confirmation request to the second network device through the second NAT router according to the first assignment message; sending a second assignment message to the second network device according to the forwarding request, the second assignment message including identification information of the first network device for enabling the second network device to send, after receiving the assignment confirmation request, an assignment confirmation reply to the first network device through the first NAT router according to the second assignment message, thereby establishing a direct connection between the first and the second network terminals; recording an assignment relationship between the first network device and the second network device according to the forwarding request; receiving a service port query request of the third network device and determining which said network device corresponds to the service port query request; providing the second service port of the second network device to the third network device according to the assignment relationship if it is determined that the first network device corresponds to the service port query request, for enabling the third network device to send a message to the second network device through the second service port, and for the second network device to forward the message to the first network device; and providing the second service port of the second network device to the third network device according to the second registration request if it is determined that the second network device corresponds to the service port query request, for enabling the third network device to directly connect to the second network device through the second service port.