Peer to peer network communication

Methods and apparatus for peer to peer network communication. In one implementation, a method of communicating between a first client system and a second client system includes: discovering first address information for a first client system connected to a first network address translation device; sharing the first address information with a second client system; receiving second address information for the second client system; and establishing communication between the first client system and the second client system using the second address information.

BACKGROUND

One typical type of NAT server (network address translation server) acts as a gateway between a local network and an external network, such as the Internet. This NAT server is a network device that allows one or more machines (e.g., computers) in the local network to share one public or external network address, such as an Internet address. The NAT server maintains a set of unique local or internal network addresses for the machines in the local network. Accordingly, each machine in the local network has a local network address and a public network address. For communication between the local network and the external network, the NAT server translates back and forth between the public network address and the local network addresses for each of the machines. Typically this network address translation is transparent to the individual machines within the local network and so the machines are not aware of the public address used by the NAT server.

SUMMARY

The present disclosure provides methods and apparatus for peer to peer network communication. In one implementation, a network system includes: a first network address translation device, connected to a network and having a first public network address; a first client system, connected to the first network address translation device and having a first local network address established by the first network address translation device; a second network address translation device, connected to the network and having a second public network address; a second client system, connected to the second network address translation device and having a second local network address established by the second network address translation device; an address server, connected to the network; a matching server, connected to the network; where the first network address translation device, the second network address translation device, the address server, and the matching server can send data to each other through the network, where the address server determines a public network address for a client system from data received from the client system and returns the derived public network address to the client system, where the matching server includes a registry table for registering client systems and storing the public network address and local network address for one or more registered client systems, where the first client system includes: a first network address manager for communicating with the address server to determine the first public network address, a first network registration manager for registering the first client system with the matching server, a first network sharing manager for sharing the first public network address and the first local network address with the second client system, where the second client system includes: a second network address manager for communicating with the address server to determine the second public network address, a second network registration manager for registering the second client system with the matching server, a second network sharing manager for sharing the second public network address and the second local network address with the first client system. In another implementation, the network system also includes a mapping maintenance server connected to the network.

In another implementation, a method of communicating between a first client system and a second client system includes: discovering first address information for a first client system connected to a first network address translation device; sharing the first address information with a second client system; receiving second address information for the second client system; and establishing communication between the first client system and the second client system using the second address information.

DETAILED DESCRIPTION

The present invention provides methods and apparatus for peer to peer network communication. The present invention allows two peer or client systems (e.g., network-enabled video game console systems) to communicate with each other across a network (e.g., the Internet) even though one or both client systems are behind respective NAT devices (network address translation devices). As described below, in one implementation, the network communication uses a four part process: (1) discovery—each client system discovers its public address on the network, (2) sharing/distribution—each client system shares its address information with other systems that wish to communicate, (3) communication establishment—the client systems establish communication, and (4) mapping maintenance—each client system maintains its current address mapping in the corresponding NAT device.

FIG. 1shows a network system architecture100. A first client system105is connected to a first NAT device (network address translation device)110, forming a first local or internal network115. The first client system105is a network-enabled system, such as a video game console system including a network adapter or a computer system. As a video game console system, the first client system105includes hardware and/or software providing video game functionality and hardware and/or software providing network communication as described below. In one implementation, the first client system105is a “Playstation 2”™ game console by Sony Computer Entertainment Inc.™ The first NAT device110is a typical NAT box or NAT server, or alternatively is a type of proxy server or part of a gateway, router, or firewall. One or more additional systems or network devices, such as a computer, may also be connected to the first NAT device110and be within the first local network115. Each system in the first local network115has a local network address assigned and maintained by the first NAT device110. In one implementation, a local network address in the first local network115includes an address number and a port number, such as according to UDP/IP (e.g., where the address number is an IP address). In an alternative implementation, the first local network115uses a different communication protocol and so the local network address includes different information to identify a system.

The first NAT device110is connected to an external or public network120, such as the Internet. Each addressable system or device connected to the external network120has a public network address. A “public” network address is used on the external network120and “local” network addresses are used within local networks, such as the first local network115. In one implementation, a public network address includes an address number and a port number, such as according to UDP/IP. In an alternative implementation, the external network120uses a different communication protocol and so the public network address includes different information to identify a system. In one implementation, the local network addresses of the first local network115are not compatible with the external network120(e.g., the local network addresses are not recognizable in the communication protocol of the external network120).

The first NAT device110has a public network address. The first client system105is indirectly connected to the external network120through the first NAT device110and does not have a public network address. The first client system105shares the public network address of the first NAT device110with other systems in the first local network115(if any are present). The first NAT device110assigns a local network address to each system in the first local network115. The first NAT device110translates between the public network address and local network addresses to route data between the external network120and the first local network115. In an alternative implementation, the first NAT device110has a two or more public network addresses to share among systems in the first local network115.

In one implementation, the first NAT device110maps port numbers to systems in the first local network115, such as by using a PAT technique (Port Address Translation). The first NAT device110assigns a port number to a local system in the first local network115when the local system sends data to a destination on the external network120. The first NAT device110stores the port number as a port mapping between the port number and the local system. The first NAT device110assigns and stores a single port number for all outgoing data from a single local system. The first NAT device110includes the assigned port number with the outgoing data and so the recipient can use the port number when responding. The first NAT device110determines which system in the first local network115is the intended recipient of incoming data by comparing the port number attached to the incoming data with the port mappings stored within the first NAT device110.

The first NAT device110establishes and adjusts the port mappings dynamically according to data sent and received using the mapping. If the first NAT device110does not receive data from a local system or from the external network120including a port number for a period of time, the first NAT device110releases the port mapping for that port number (a “timeout”). As described below, the first client system105can prevent this timeout by periodically sending messages out to the external network120.

In one implementation, the first NAT device110screens incoming data (e.g., for security reasons) by comparing the network address of the sender of the incoming data with addresses of recipients of data sent by the local system indicated by the port number. When the first NAT device110sends data from a local system to a recipient on the external network120, the first NAT device110records the destination address along with the port mapping for the local system. The first NAT device110does not forward incoming data to a local system on the first local network115if the local system has not already sent data to a recipient at the same network address as that of the incoming data. The first NAT device110compares the network address of the sender of incoming data with the recorded destination address(es) of outgoing data using the port included with the incoming data. As described above, the first NAT device110records destination addresses along with port mappings, so the first NAT device110can use a port number as an index to find destination addresses to which data has been sent by a local system. If there is not a match, the first NAT device110does not forward the incoming data into the first local network115. As described below, the first client system105uses this security functionality to “approve” a system on the external network120by sending data to that system and so causes the first NAT device110to allow data from that approved system into the first local network115.

For example, when the first client system105sends data to a recipient on the external network120the first NAT device maps a port number to the first client system105. The first NAT device110includes the public network address for the first NAT device110and the mapped port number for the first client system105with the outgoing data. The first NAT device110also records the address of the recipient. When the first NAT device110receives data including that port number, the first NAT device110compares the address of the sender with the recorded address of the destination for the previously sent outgoing data. If the addresses match, the first NAT device110forwards the data to the first client system105using the local network address of the first client system105.

A second client system125is connected to a second NAT device130, forming a second local network135. Similar to the first client system105, the second client system125is a network-enabled system, such as a video game console system including a network adapter. Similar to the first NAT device110, the second NAT device130is a typical NAT box or NAT server, or alternatively is a type of proxy server or part of a gateway or router. The second client system125and the second NAT device130operate similarly to the first client system105and the first NAT device110, respectively (e.g., in terms of port mapping and screening incoming data). One or more additional network devices may also be connected to the second NAT device130and be within the second local network135. Each system or device in the second local network135has a local network address assigned and maintained by the second NAT device130, similar to the first local network115. In one implementation, the first local network115and the second local network135are the same type of network and so use the same communication protocol, however, in alternative implementations, the local networks115,135can be different types.

Similar to the first NAT device110, the second NAT device130is connected to the external network120. Accordingly, the second client system125is indirectly connected to the external network120through the second NAT device130. The NAT devices110,130can send data to each other through the external network120according to the protocols of the external network120.

Three server systems are connected to the external network120as well: an address server140, a matching server145, and a mapping maintenance server150. Each of the server systems140,145,150is a network server system, such as a computer system or a mainframe system. Alternatively, some or all of the server systems140,145,150are included within a single system connected to the external network120. Each of the server systems140,145,150has a respective network address on the external network135. These server network addresses are known to the client systems105,125. The address server140assists the client systems105,125with address discovery. The matching server145assists the client systems105,125with address sharing. The mapping maintenance server150assists the client systems105,125with maintaining the address mapping of the NAT devices110,130, respectively. In an alternative implementation, the maintenance mapping server is omitted.

FIG. 2is a block diagram of one implementation of a client system200, such as first client system105inFIG. 1. The client system200includes four managers: a network address manager205, a network registration manager210, a network sharing manager215, and a network mapping maintenance manager220. Each of the managers205,210,215,220is implemented as a software component of the client system200. Alternatively, some or all of one or more of the mangers205,210,215,220is implemented in hardware. The network address manager205controls communication between the client system200and the address server140to discover a public network address associated with the client system200by a connected NAT device, such as the first NAT device110. The network registration manager210controls communication between the client system200and the matching server145to register the client system200with the matching server145. The network sharing manager215controls communication with the matching server145to determine the public and local network addresses of another client system that has requested communication with the client system200. The mapping maintenance manger220controls communication with the mapping maintenance server150to prevent the NAT device connected to the client system200from timing out the mapping established for the client system200. In an alternative implementation, the client system200does not include a mapping maintenance manager220. The client system200includes a network interface225for connecting to and communicating with the local network of the client system200. The network interface225includes a network communication device, such as a network adapter or modem. The client system200also includes components for general operation, such as a CPU230, memory235, and an I/O interface240. For a game console client system, the client system includes additional video, sound, and application specific software and/or hardware (“game components”). As noted above, in one implementation, a client system200is a “Playstation 2”™ by Sony Computer Entertainment Inc.™ including hardware and software for network communication as described herein.

FIG. 3is a flowchart of establishing and maintaining peer to peer network communication between two client systems, such as the first client system105and the second client system125inFIG. 1. Each client system discovers its address information, block305. A client system, such as the client systems105,125inFIG. 1, has associated address information including a public network address and a local network address. As described below referring toFIG. 4, a client system discovers its public network address by communicating with the address server (recall the address server140inFIG. 1). A client system discovers its local network address by accessing locally stored information or by querying the corresponding NAT device. The client systems share their discovered address information with each other, block310. As described below referring toFIG. 5, one or both of the client systems register with the matching server (recall the matching server145inFIG. 1). One of the client systems requests communication with the other registered client system and the matching server shares the address information between the client systems. The client systems establish communication with each other using the received address information, block315. As described below referring toFIG. 6, each client system sends messages to the other client system using the shared address information so that the NAT devices recognize the incoming messages as “approved.” While the client systems are communicating, the client systems maintain the mapping established by the corresponding NAT devices, block320. As described below referring toFIG. 8, each client system periodically sends messages to the mapping maintenance server (recall the mapping maintenance server150inFIG. 1) so that the corresponding NAT device does not change or timeout the established port mapping for the client system. In an implementation that does not include a mapping maintenance server, the client systems do not maintain this mapping using a mapping maintenance server.

FIG. 4is a flowchart of a client system discovering its local and public network addresses (recall block305ofFIG. 3). As described above, the local network address is the network address of the client system in a local network and is assigned by a NAT device connected to the local network. The public network address is the network address on the external network shared by a NAT device among the systems in the local network connected to the NAT device. In one implementation, a local or public network addresses includes an address number and a port number. The client system uses its network address manager component to discover its public and local network addresses (recall network address manager205inFIG. 2).

A client system first discovers its local network address, block405. In one implementation, a client system discovers its local public address by accessing local storage, such as by querying the network stack software used by the client system. The client system establishes the local port number when the client system initiates communication with the NAT device and so the client system is already aware of the port number. Alternatively, the client system can request the local network address from the corresponding NAT device. The client system sends an address request to the address server to discover the public network address, block410. The client system sends the address request to the address server through the NAT device. As part of the NAT device's network address translation functionality, the NAT device adds the public network address to the address request, such as in header information for the address request. If the NAT device has not already assigned a port number to the client system, the NAT device assigns a port number and includes the port number in the public network address in the address request (e.g., in the UDP header). The address server extracts the public network address from the address request and stores the public network address, block415. The public network address is located within the address request at a known location (e.g., within the header) so the address server can find the public network address in the address request. In an alternative implementation, the address server does not store the public network address or only stores the public network address temporarily. The address server returns the public network address to the client system by generating an address report and sending the address report to the client system, block420. The address report includes the extracted public network address as part of the data or payload of the message as well as in the addressing portion of the message (e.g., in the header). The NAT device converts the public network address to the client system's local network address according to the port number and forwards the address report to the client system. For example, the NAT device accesses the port mapping for the client system according to the port number of the public network address and retrieves the local network address. The NAT device then replaces the public network address in the message's header information with the local network address. Accordingly, the NAT device modifies the header by removing the public network address, but does not modify the data portion of the message. The client system receives the address report and stores the included public network address, block425. The client system has now discovered its local and public network addresses.

FIG. 5is a flowchart of two client systems sharing their local and public network addresses (recall block310ofFIG. 3). A first client system registers with the matching server, block505. A client system uses its network registration manager component to manage registering with the matching server (recall network registration manager210inFIG. 2). The first client system sends a registration request to the matching server. The registration request includes the first client system's discovered local and public network addresses. The registration request indicates to the matching server that the sending client system is available for communication using the provided address information. The matching server registers the first client system in a registry table, block510. The matching server maintains a registry table with entries storing address information for registered systems. The matching server creates an entry in the registry table for the first client system and records the provided address information in the entry. The second client system sends a matching request to the matching server, block515. A client system uses its network sharing manager component to manage obtaining the address information for another client system from the matching server (recall network sharing manager215inFIG. 2), both to select a registered client system and to receive address information after registering, as described below. The matching request indicates to the matching server that the second client system is requesting information to establish communication with another client system. The matching server sends registry information to the second client system, block520. In one implementation, the matching server sends the registry table to the second client system. In another implementation, the matching server communicates with the second client system so that the second client system can access the registry table to identify a registered client system with which to communicate, such as by accepting search queries from the second client system. The second client system selects the first client system from among the registered client systems, block525. The second client system stores the address information for the first client system, block530. In one implementation, the registry information sent to the second client system includes address information for the registered client systems. In another implementation, the second client system separately requests the address information for the selected client system from the matching server. The second client system sends a matching selection to the matching server, block535. The matching selection indicates with which of the registered client systems the second client system is to communicate (in this case, the first client system). The matching selection also includes the second client system's address information. In one implementation, the matching selection also serves as a request for the address of the first client system. The matching server sends the second client system's address information to the first client system as the selected client system, block540. The first client system receives and records the second client system's address information, block545. Each of the two client systems have now shared their address information with the other client system through the matching server.

FIG. 6is a flowchart of a first client system establishing communication with a second client system (recall block315ofFIG. 3). The first client system sends one or more test messages to the second client system, block605. The first client system sends some of the test messages to the second client system using the public network address for the second client system (outgoing public address test messages) and some of the test messages using the local network address for the second client system (outgoing local address test messages). As described above, the first client system received the public and local network addresses for the second client system when the two client systems shared address information (recallFIG. 5). In an implementation where the local network addresses of the second client system's local network are not compatible with the external network (e.g., the local network addresses are not recognizable under the communication protocol of the external network), the first client system does not send test messages using the local network address. The first client system continues to send test messages to the second client system until the first client system receives a confirmation message from the second client system in block630, as described below.

The NAT device connected to the first client system records the destination addresses of the outgoing test messages, block610. The NAT device connected to the first client system (e.g., the first NAT device110inFIG. 1) is a gateway between the local network of the first client system and the external network. Accordingly, the outgoing test messages pass through the NAT device. As described above, the NAT device screens incoming data and does not allow data to enter the NAT device's local network unless the local network destination of the incoming data has already attempted to communicate with the sender of the incoming data. The NAT device records the destination address of outgoing data from the systems on the local network as “approved” addresses for the sender of the outgoing data. The NAT device compares the origin address of the incoming data (i.e., the address of the sender) with recorded “approved” addresses for the intended recipient on the local network. The NAT device only forwards incoming data to the local recipient when the origin address matches one of the “approved” addresses for the local recipient.

Accordingly, the NAT device records the destination addresses of the outgoing test messages as “approved” addresses of systems with which the first client system is attempting to communicate. When the NAT device receives data for the first client system that is from the same address as the destination address of one of the first client system's outgoing test messages, the NAT device forwards the incoming data to the first client system. The first client system is sending test messages to addresses for the second client system, so the NAT device will forward data from the second client system to the first client system.

While the first client system is sending test messages to the second client system, the second client system is sending test messages to the first client system as well, as described below referring toFIG. 7. As described above for the first client system, the second client system sends outgoing public address test messages (and outgoing local address test messages if appropriate) using the address information for the first client system. The NAT device connected to the second client system (e.g., the second NAT device130inFIG. 1) records the destination addresses for the outgoing test messages and so will forward incoming data for the second client system received from the first client system.

The first client system receives a test message from the second client system, block615. As described above, the NAT device connected to the first client system forwards an incoming test message from the second client system to the first client system because the NAT device matches the origin address of the incoming test message with a recorded “approved” address. The first client system records the origin address of the received test message, block620. The first client system sends a confirmation message to the second client system using the recorded origin address, block625. The outgoing confirmation message indicates to the second client system that the first client system has received a test message from the second client system. Similarly, the second client system receives a test message from the first client system and sends a confirmation message to the first client system using the origin address of that test message. The first client system receives a confirmation message from the second client system, block630. When the first client system receives a confirmation message from the second client system, the first client system stops sending test messages to the second client system. The first client system has now established communication with the second client system. After the second client receives the confirmation message from the first client system, the second client system will have established communication with the first client system. The client systems have confirmed an address to which each system can send data and have that data successfully pass through the NAT device of the recipient system.

By first sending test messages addressed to the second client system so that the NAT device will forward messages from the second client system to the first client system, the first client system is “punching holes” in the security features of the NAT device. Accordingly, this technique is referred to as “hole punching.” Using “hole punching” the first and second client systems can establish communication without altering the operation of the NAT devices.

FIG. 7is a flowchart of the second client system establishing communication with the first client system. The actions ofFIG. 7occur in conjunction with those described above referring toFIG. 6. The second client system sends test messages to the first client system using the address information received when the client systems shared address information, block705. As noted above, the second client system sends outgoing public address test messages using the first client system's public network address and also sends outgoing local address test messages if the local network address is compatible with the external network. The second client system continues to send test messages to the first client system until the second client system receives a confirmation message from the first client system in block730, as described below. The NAT device connected to the second client system records the destination addresses for the outgoing test messages as “approved” addresses, block710. As described above, the first client system is also sending test messages to the second client system and the second client system receives a test message from the first client system, block715. The second client system records the origin address of the received test message, block720, and sends a confirmation message to the first client system using the origin message, block725. As described above, the first client system also sends a confirmation message to the second client system after receiving a test message from the second client system and the second client system receives the confirmation message, block730. When the second client system receives a confirmation message from the first client system, the second client system stops sending test messages to the first client system. The second client system has now established communication with the first client system.

FIG. 8is a flowchart of a client system maintaining the mapping assigned by a connected NAT device (recall block315ofFIG. 3). A client system uses its network mapping maintenance manager component to manage maintaining the address mapping of a connected NAT device with the mapping maintenance server (recall network mapping maintenance manager220inFIG. 2). As described above, in one implementation, a NAT device assigns local network addresses to the systems on the local network of the NAT device. The NAT device also assigns port numbers for the public network address used by local systems. When a local system sends data to the external network, the NAT device assigns a port number to the local system and stores the port number. When the NAT device receives incoming data, the NAT device checks the port number in the target address for the incoming data (e.g., in the header information) to determine which local system is the intended recipient. As described above the NAT device also uses the port number to confirm that the sender of the incoming data is “approved” before forwarding the data to the local system. Once the NAT device has assigned a port number to a local system, the NAT device begins counting down a timer. If the local system sends more data to the external network, the NAT device uses the same port number and resets the timer. Similarly, if the NAT device receives incoming data using the port number, the NAT device resets the timer. If the timer reaches zero, the NAT device frees the port number (a “timeout”) because the port number has not been used recently. To prevent this “timeout” a client system periodically sends mapping maintenance messages to the mapping maintenance server while the client system is communicating or attempting to communicate with another client system. As described above, in one implementation, the mapping maintenance server is included within the address server or the matching server and so the client system sends mapping maintenance messages to the appropriate server. In one implementation not including a mapping maintenance server, the client system does not send mapping maintenance messages.

The client system sends a mapping maintenance message to the mapping maintenance server through the connected NAT device, block805. Referring toFIG. 1, the first client system105sends a mapping maintenance message through the first NAT device110to the mapping maintenance server150. The NAT device receives the mapping maintenance message and resets the timer for the port number assigned to the client system, block810. The NAT device sends the mapping maintenance message to the mapping maintenance server, block815. After a predetermined period, the client system evaluates whether to maintain the current address, block820. If the client system is communicating with another client system or attempting to communicate with another client system, the client system sends another mapping maintenance to the mapping maintenance server to preserve the current port mapping, returning to block805. If the client system is done communicating, the client system does not send another mapping maintenance message and allows the port mapping to timeout, block825. In one implementation, the mapping maintenance server does not respond to the client system. Alternatively, the mapping maintenance server sends a mapping maintenance confirmation message to the client system.

While the description above focuses on a network configuration where two client systems are behind respective NAT devices (recallFIG. 1), the operation of the two client systems and the server systems are independent of the presence of NAT devices.FIGS. 9A-9Cshow alternative network configurations. InFIG. 9A, a first client system905is behind a NAT device910while a second client system915is not connected to a NAT device. InFIG. 9B, both client systems930,935are not connected to NAT devices. InFIG. 9C, both client systems970,975are behind the same NAT device980in the same local network985. In each of these alternative configurations, as well as other variations, the client systems and server systems can interact in substantially the same way as described above.

The various implementations of the invention are realized in electronic hardware, computer software, or combinations of these technologies. Most implementations include one or more computer programs executed by a programmable computer. For example, referring toFIG. 1, in one implementation, each client system105,125and server system140,145,150includes one or more programmable computers implementing the respective aspects of the network system described above. In general, each computer includes one or more processors, one or more data-storage components (e.g., volatile or non-volatile memory modules and persistent optical and magnetic storage devices, such as hard and floppy disk drives, CD-ROM drives, and magnetic tape drives), one or more input devices (e.g., mice and keyboards), and one or more output devices (e.g., display consoles and printers).

The computer programs include executable code that is usually stored in a persistent storage medium and then copied into memory at run-time. The processor executes the code by retrieving program instructions from memory in a prescribed order. When executing the program code, the computer receives data from the input and/or storage devices, performs operations on the data, and then delivers the resulting data to the output and/or storage devices.

Various illustrative implementations of the present invention have been described. However, one of ordinary skill in the art will see that additional implementations are also possible and within the scope of the present invention. Accordingly, the present invention is not limited to only those implementations described above.