How does raknet implement reliable transmission?

Source: Internet
Author: User

Two data transmission mechanisms are used in raknet. The latest UDT is used as the transmission control layer.

The following is a new transmission control mechanism.

In raknet, you can use # DEFINE _ use_raknet_flow_control to determine whether to use the old transmission protocol or the new protocol.

 

Control package:

1 byte flag

4 bytes timestamp, used to calculate RTT for congestion control

3 bytes serial number ack used to view data packets

 

Data Packets:

2 bytes message length

3 bytes current message serial number to avoid repeated transmission

1 byte flag

If (unreliable_sequenced, reliable_sequenced, reliable_ordered)

3 bytes retransmission No.

 

1 byte sequential Channel

If (Message exceeds MTU)

4 bytes number of parts, not compressed to improve work efficiency

2 bytes block ID

4 bytes block index, not compressed to improve work efficiency

 

Send a message from the game. All the data information you send to raknet will put together a control information. Therefore, if you only send one message, it should have one control information and one data information. If you send five messages, it is a control message plus five data messages. However, if it is 10 times larger than MTV, it sends 10 packets, each containing 1 data (data will be split)

 

The old transmission control mechanism is as follows:

 

Control package:

1 byte flag

8 bytes timestamp, used to calculate RTT for congestion control

 

Data Packets:

4 bytes message length

4 bytes current message serial number to avoid repeated transmission

4 bits flag

If (unreliable_sequenced, reliable_sequenced, reliable_ordered)

4 bytes retransmission No.

 

5 bits sequential Channel

If (Message exceeds MTU)

4 bytes number of parts, compressed, with an average of 1-2 bytes

4 bytes block ID

Index in 4 bytes blocks, compressed, with an average of 1-2 bytes

 

 

Raknet packet Reliability

Unreliable

Unreliable packets are directly sent by UDP, which may arrive in sequence or not. The data sent in this way is preferably unimportant, or sent many times. The advantage of this is that the loss of data packets can be compensated.

Advantage-this type of data packet does not need to be notified by the network whether it reaches the destination.

Disadvantage-data packets are not ordered or reach the destination. If the sent memory is full, the data is discarded first.

 

Unreliable_sequenced

Unreliable continuous data packets are roughly the same as unreliable data packets. There is only one difference, that is, old data packets are ignored, and only the latest data packets can be accepted.

Advantage-similar to unreliable data packets, you don't have to worry that old data packets will change your data.

Disadvantage-a large number of data packets may be lost when they never reach the destination, or after they arrive at the destination. When the sending buffer is full, these packets are first lost. Or the latest data packet has never arrived after it is sent.

 

Reliable

Reliable data packets are sent to the destination through a reliable layer package.

Advantage-data packets are completely sent to the destination.

Disadvantage-there is no package order.

 

Reliable_ordered

 

The Reliability ordered packet is sent to the destination in sequence after being packaged by UDP through a reliable layer.

Advantage-this type of data packet will be sent in a certain order. The advantage of doing so is that it is easy to program, because you don't have to worry about how to organize them or the loss of data packets.

Disadvantage-extra network bandwidth may be used. If the network is busy, data packets may arrive very slowly. If a packet arrives late, the arrival of many packets will be delayed. This disadvantage can be mitigated using sequential streams.

 

Reliable_sequenced

Reliability continuous data packets are packaged by UDP using the reliability layer. Its purpose is to ensure that these data packets can arrive at the destination in a continuous order.

Advantage-you can get the reliability and sequence of UDP data packets without worrying about old data packets.

Disadvantage: it still occupies a large amount of network bandwidth. If the package receives ack confirmation, delete the package from the package queue. If ack confirmation is not received, resend the package. If the package to be sent is larger than the default MTU size, split the package and send it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.