Skip to content

Data definition

Taegyeong Kim edited this page Nov 1, 2016 · 1 revision

Data definition

Haste has a different definition of the data in each layer.

We classify MTU(Transport), Command(Transport), Message(Framework+Application) in each layer.

MTU(Maximum Transmission Unit)

MTU means the received data in Transport layer.

In Transport, receive data through a socket, but this data is a datagram of UDP. (Default MTU is 1500 bytes in Haste (1500 bytes is default MTU of Ethernet))

MTU is a set of Command.

Why do MTU have many commands?

MTU has 19 bytes header. Sending the only one command attaching MTU header is inefficient. Haste doesn't send immediately. Haste sends MTU which has many enqueuing commands per a certain period of time. Because sending a bundle of commands is more efficient than sending a command.

Strucutre of MTU Header

  • Command type : 1 byte
  • Peer Id : 4 bytes
  • Current Sending time : 8 bytes
  • Command Count : 2 bytes
  • CRC : 4 bytes
  • Commands

Command

Command is the minimum unit of processing data in Transport.

Types of command :

  • CONNECT : Command(Client) for connecting.
  • CONNECT_RESPONSE : Response of CONNECT Command(Server).
  • DISCONNECT : Command for disconnecting.
  • ACKNOWLEDGE : Response of a reliable command.
  • PING : Command for keeping connection. This command is reliable.
  • RELIABLE : Command for a reliable data.
  • UNRELIABLE : Command for a unreliable data.
  • FRAGMENTED : Command for a reliable data which is larger than the defined MTU size. This command contains information for combining data.
  • SNTP : Command for time synchronizing.

Message

Message is a payload of a received command, and is used meaningfully in the Framework layer.

And Application developer develops a game server using Message. (Application developer doesn't need to know MTU and Command, just should know Message)

In Haste, Message is defined following messages.

  • InitialRequest : Message that contains information for connection.
  • InitialResponse : Response message for InitialRequest.
  • RequestMessage : Request message that is received from a client.
  • ResponseMessage : Response message for RequestMessage.
  • EventMessage : Event message that is raised from a specific client.

And all messages uses a following data type, called DataObject.

  • DataObject : Data container that contains Key(byte), Value(primitive type(+string), array of primitive type)