2. NetZ Overview

NetZ provides a rich feature set that includes dead reckoning and duplicated objects that can make the design and implementation of game programs far more efficient. It also includes simple byte data transfer features equivalent to those in the old DWC library.

2.1. Case-by-Case Implementation

Because NetZ provides such a variety of features, game developers must first find an implementation to suit their own game specifications.

For all communication performed by NetZ, either unreliable communications, which has no guarantee of arriving, or reliable communications, which is guaranteed to arrive, can be selected. In reliable communications, multiple substreams can be used selectively.

2.1.1. Data Sharing With Duplicated Objects

If you are developing a new game or a new method of interpolating game object positions, you may want to use NEX duplicated object features (Section 11) and dead reckoning (Section 12). The duplicated object features automatically handle communication for game objects. The application simply changes the parameters of in-game objects, and the library automatically sends and receives the necessary data. Dead reckoning is a feature that interpolates the movements of other players, including their position and orientation, to make them appear more natural. The application simply specifies the interpolation method, update frequency, and other parameters. The system automatically sends and receives the necessary data and performs the required interpolation.

2.1.2. Remote Method Calls

The duplicated object features include a feature that calls other terminal functions on the server, which is called a remote method call (Section 13.1). Consider using when giving notification of a specific event, such as a bullet being discharged. With the application, by simply specifying the data format to send and receive, the library generates a send and receive function and it can be called synchronously or asynchronously.

2.1.3. Direct Streams

Consider using direct streaming (Section 7) to send or receive a series of bytes. Even when using remote method calls, by specifying something such as a variable length array in the data format, any byte series can be sent or received, but direct streaming has better performance. For example, it is suitable for when transitioning from DWC (the communication library for DS or Wii) or another older network library, when using application-specific serialization processing, or when sending a large volume of data.

Note

Consider using VSocket if you already have and want to use a different P2P library for controlling P2P sessions, and you want use the NEX NAT traversal features.(Appendix: VSocket)

2.2. Network Topology

NetZ has three network topologies, shown in the following list. In NetZ, terminals are called stations. A group of stations is called a P2P session and the manager of a P2P session is called the session host.

  • P2P network topology: Direct connections are established between all stations participating in the P2P session.
  • Client-server topology: A star network with the session host acting as the central node. Connections between stations other than the session host always go through the session host.
  • Hybrid network topology: A P2P-based network topology that only communicates through the session host when a direct connection between stations fails.

The default network topology is P2P. You can change the network topology by calling the NetZ::SetNetworkTopology member function before creating a NetZ object.

Choose a network topology based on the characteristics of the game. For the features of each network topology, see Table 2.1.

Table 2.1 Network Topology Features
Network Topology Advantages Disadvantages
P2P network topology Has low latency because it uses a direct connection between stations. Suitable for exchanging large amounts of data. Cannot communicate if direct connection fails.
Client-server topology Connections are less likely to fail because communication takes place through the session host. Increases load on the host and reduces responsiveness because data goes through the session host. Cannot use the host migration extension feature.
Hybrid network topology Clients attempt a direct connection and go through the session host if a direct connection fails. Less likely to fail than P2P network topology. Can have the advantages of P2P network topology if direct connection succeeds. The application must be implemented in a way that handles both direct connections and connections via the session host.

2.2.1. P2P Network Topology

Code 2.1 P2P Network Topology Settings

NetZ::SetNetworkTopology(NetworkTopology::Peer2Peer);

Figure 2.1 shows the default network topology: a P2P network where all stations connect directly to each other as they join a session. A station that attempts to join a session is dropped if it cannot connect to every other station.

There may be a delay in sending and receiving data, depending on the network environment.If the network environment supports multiple regions, and there is P2P communication between the regions, you need to consider the possibility of a round trip time of around 400 ms.

_images/Fig_Overview_PeerToPeer_Network.png

Figure 2.1 NetZ's P2P Network

2.2.2. Client-Server Network Topology

Code 2.2 Client-Server Network Topology Settings

NetZ::SetNetworkTopology(NetworkTopology:: ClientServer);

Figure 2.2 shows the client-server network topology, where the stations use the session host as a router that relays packets to other stations. If the server leaves the game, all connections are lost and the game ends.

With this topology, connectivity between stations is guaranteed as long as the stations can connect to the session host. This means that a NAT traversal failure between client stations does not result in a total loss of the connection. NAT traversal is a feature for establishing P2P communication in an environment that uses network address translation (NAT).

However, the latency between stations other than the session host is more than double that of a P2P network and the session host faces a higher load on its CPU and network.

_images/Fig_Overview_ClientServer_Network.png

Figure 2.2 NetZ's Client-Server Network

2.2.3. Hybrid Network Topology

Code 2.3 Hybrid Network Topology Settings

NetZ::SetNetworkTopology(NetworkTopology:: Hybrid);

The hybrid network topology enables all stations to directly connect to each other like a P2P network by establishing communications between stations. When NAT traversal is impossible (specifically, when two stations cannot connect directly due to incompatible routers), the affected stations communicate through the session host instead. A switch is made to communication through the session host when establishing direct connections between stations after joining a session fails. Stations not directly connected to the new session host are all disconnected when the session host is switched.

Warning

When using the hybrid network topology, you must consider the processing load of communications on the session host because the session host transfers communications between stations. Furthermore, latency increases because all communications go through the session host.

To get the number of communications made through the session host for an entire session, assign a value greater than 0 to RootTransport::SetRoutingHistoryUpdateSpan ahead of time and use Session::GetNumOfRoutingConnections. Get the number of communications made through the session host for any particular station by using Station::GetNumOfRoutingConnections. Both of these functions can only be called by a session host.

Code 2.4 Getting the Number of Communications Made Through the Session Host

// Set the history update interval for communications made through the session host.
RootTransport::SetRoutingHistoryUpdateSpan(2000);
while (1) {
    // Processing by the application.
    SampleAppUpdate();
    // Run NEX processing.
    Scheduler::GetInstance()->DispatchAll();
    // Get the number of communications made through the session host.
    qUnsignedInt32 num = Session::GetNumOfRoutingConnections();
}

Figure 2.3 shows a conceptual image of communications when direct communication is possible between stations other than Station 2 and Station 4, and the session host handles communications between Station 2 and Station 4.

_images/Fig_Overview_Hybrid_Network.png

Figure 2.3 NetZ Hybrid Network Topology


CONFIDENTIAL