alexeyteplyj2022-02-11 10:32:22
Computer networks
alexeyteplyj, 2022-02-11 10:32:22

Do I need to add a session to every UDP packet?

Good afternoon!

I study backend game development and make my own test project. It won't go into production, I'm doing it for myself, for training, a simple server for MMORPG.

There are several questions about the network part:

1. Correctly, I understand that if you use UDP, then you need to add data to each packet to determine who this packet is from, i.e. kind of session?
2. How is UDP commonly used in game development?
3. Does everyone use RUDP or is normal UDP suitable for some cases?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
GFX Data, 2022-02-11

1) No, this is done by the framework or library you are using. You can technically send a session ID, but this is usually overkill. It is better to avoid code examples where the socket collects each packet into a string and analyzes the received data for completeness.
2) Usually not, if you have a framework working with UDP (Net socket, SuperSocket), you just prepare a block of data to send and notify the connected socket about it. The responder will receive the message or call the listener method when receiving data. In the case of SuperSocket, you can use one type for the data container, and speed up the transfer as much as possible (avoiding JSON/XML). You choose the format, purpose and type of the block yourself (authorization, position update, game event), it can even be a byte array.
The choice between UDP/TCP may not be significant if there is noticeable network latency. Such delays are solved by motion prediction algorithms. In the case of games like MMO shooters, these can be complex problems due to the complexity of the task, and can be discarded in the test/learning phase.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question