×
Community Blog Configuring Client Game Broadcast Mechanism on Alibaba Cloud

Configuring Client Game Broadcast Mechanism on Alibaba Cloud

In this article, we will show you how you can use ECS unicast mode to simulate a multicast mode to meet the multicast and broadcast requirements for a gaming server.

Customer Requirements

For traditional client games, the background server architecture is normally complicated, and in-depth network communication is required between servers. If unicast communication is used, a server needs to know the changes made to other servers at any time, lowering the elasticity of the entire architecture. To achieve flexible development and reduce host computing resources, many client game servers still use UDP broadcast communication.

Basic Principles

In the current classic network and VPC network environments of Alibaba Cloud, L2 multicast and broadcast are not supported because the underlying switches are L3 switches. To meet the customers' multicast and broadcast requirements, you can use the unicast mode to simulate the multicast mode. The basic implementation principle is as follows:

1

Configuration in Windows Environment

In the Windows environment, the multicast tool consists of the server udptopoint and the client udptomulti. The server must be installed on an ECS instance for sending multicast packets, while the client is installed on the ECS for receiving multicast packets.

Installation

Install the Windows multicast agent by using the installation package. Double-click the installers udptopoint-1.3.1.exe and udptomulti-1.1.1.exe. Then, install the server and client as prompted. Their installation directories are C:udptopoint and C:udptomulti, respectively.

2

3

Notes:

  1. During installation, if the system detects that Winpcap is already installed, you can directly cancel the installation or proceed with the installation to overwrite the installed version.
  2. If Winpcap is not installed, click Install to install it, as shown in the following figure:

    4

Configuration

Configuring the Server

After installing the multicast tool successfully, run udptopoint.exe, and the multicast-to-unicast background service automatically runs. Then, Choose Task Manager > Services to check the running status of the current service.

You must configure multicast groups on the server and add multicast members to the groups by using the configuration file named server_cfg.json.txt. The structure of the configuration file is as follows:

Structure of the server configuration file:

 {
  "multi_group_array":[
    {
      "group_ip":"224.2.2.1",
      "group_port":4321,
      "server_port":4322,
      "member_array":[
        "172.16.1.1",
        "172.16.1.2",
        "172.16.1.3"
      ]
    }
  ]
}

Parameters in the configuration file are described as follows.

  1. group_ip: IP address of the multicast group
  2. group_port: Multicast group port, which initiates multicast on the server
  3. server_port: Communication port of the agent, which converts the multicast mode to the unicast mode
  4. member_array: IP addresses of the members in the multicast group
  5. send_reload_point_cfg: is an auxiliary tool for the server:

The currently supported commands are "reload" and "list".

The reload command is used to reload the configuration file. Run this command each time after modifying the configuration file.

The list command is used to display the information about the packets sent or received by the current agent system.

Usage instructions:

Enter the reload or list command on the terminal.

5

Configuring the Client

After the multicast tool is successfully installed, run udptomulti.exe, and the multicast-to-unicast background service automatically runs. Then, choose Task Manager > Services, and you can check the running status of the current service.

On the client, configure the added multicast groups by using the json array in the configuration file, client_cfg.json.txt. The structure of the configuration file is as follows:

Structure of the client configuration file:

{
    "multi_server_info_array":[
    {
    "server_ip":"10.65.251.14",
    "server_port":6000,
        "group_ip":"192.168.1.255",
        "group_port":6001
    }
  ]
}

Description:

  1. server_ip:Source IP address that sends the multicast data.
  2. server_port: Communication port of the agent, namely the unicast port.
  3. group_ip: IP address of the multicast group, namely, the IP address of the multicast group to be simulated after messages are received.
  4. group_port: Communication port of the application, namely, the port of the multicast group to be simulated after messages are received.
  5. send_reload_multi_cfg: is an auxiliary tool for the client:

The currently supported commands are "reload" and "list".

The reload command is used to reload the configuration file. Run this command each time after modifying the configuration file.

The list command is used to display the information about the packets sent or received by the current agent system.

Configuration in Linux Environment

Installation

Both the server and client of the Linux multicast tool are packed into a primary RPM package. The currently available RPM package is multicast_usr_tool-1.0.1-1.x86_64.rpm (version 1.0.1). The installation process is as follows:

sudo rpm -ivh multicast_usr_tool-1.0.3-1.el6.x86_64.rpm

You can run rpm-Q multicast_usr_tool-1.0.3-1.el6.x86_64 to check whether the RPM package has been successfully installed. After the RPM package is successfully installed, the server and client programs for the user-state multicast tool are automatically installed to the system.

Configuration

After the multicast tool is successfully installed, the client installation directory is /usr/local/bin, and the configuration file directory is /etc/multicast/.

Run the cd /usr/local/bin command to access the directory where the client is located.

Run the source ~/.bashrc command.

Start the client and server as follows:

For the client: Run the following command with root permissions to manually start the client: nohup multic_admin -R > /dev/null &

For the server: Run the following command with root permissions to start the server: service multis_monitord start

Stop the client or server as follows:

To manually stop the client, run the ps aux|grep multic_admin command to locate the PID of the process, and then run the kill pid command.

To stop the server, run the service multis_monitord stop command with root permissions.

Check the running status using service multis_monitord status

Use Cases

6

As shown in the preceding figure, ECS1 is the multicast source, while ECS2, ECS3, and ECS4 are the multicast members. The multicast IP address is 224.1.2.3 and the multicast port is port 7134. The multicast server must be installed on ECS1, and the multicast clients must be installed on ECS2, ECS3, and ECS4. To do this, perform the following procedure:

Modifying the Server Configuration File

For Windows, modify the server_cfg.json.txt file in the udptopoint directory. For Linux, modify the /etc/multicast/server_cfg.json.txt file. The modified configuration is as follows:

{
    "multi_group_array": [
        {
"group_ip": "224.1.2.3",
"server_port": 7134,
            "group_port": 7134,
            "member_array": [
                "192.168.1.1",
                "192.168.1.2",
                "192.168.1.3"
            ],
        }
    ]
}

After completing the modification, you must use the reload tool to load the modified configuration file to the running server program:

For Linux, run the following command: server_reload_list and input the reload command.

For Windows, run the following command: send_reload_point_cfg and input the reload command.

If the prompt "connection refused" is displayed, check whether the udptopoint service is running properly.

Modify the Client Configuration File

The following uses ECS2 as an example to explain how to modify the client configuration file. For Windows, modify the client_cfg.json.txt file in the udptopoint directory. For Linux, modify the /etc/multicast/client_cfg.json.txt file. The modified configuration is as follows:

client_cfg.json.txt

{
    "multi_server_info_array": [
        {
            "group_ip": "224.1.2.3",
            "group_port": 7134,
            "server_ip": "192.168.0.1",
            "server_port": 7134
        }
    ]
}

After completing the modification, you must use the reload tool to load the modified configuration file to the running server program:

For Linux, run the following command: client_reload_list and input the reload command.

For Windows, run the following command: send_reload_multi_cfg and input the reload command.

If the prompt "connection refused" is displayed, check whether the udptomulti service is running properly.

Additional Notes

Precaution: Server_port must be consistent on both the client and server. Otherwise, no packets can be received.

The system generates log files. For Windows, client_log.txt in the C:udptomulti directory and server_log.txt in the C:udptopoint directory will be generated. For Linux, client_log.txt and server_log.txt both in the /etc/multicast/ directory will be generated.

After completing the service configuration, you can use the packet capturing tool to test the service. We recommend that you use Wireshark for Windows systems and the tcpdump command for Linux systems.

If communication fails, perform troubleshooting by completing the following steps:

  1. On the server, check whether multicast packets are correctly converted to unicast packets and are sent successfully.
  2. On the client, check whether unicast packets are correctly received and whether the network connection is normal.
  3. Check whether the client can properly restore unicast packets to multicast packets.

Confirmation of Results

After the transformation of the multicast tool, ECS instances on the customer's classic network can communicate with each other in broadcast mode.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 764 followers

You may also like

Comments