FLL - Specifications - FSS-000F (Simple Packet)
Author: Kevin Day
Description: Featurless Linux Library Specifications
Keywords: Featureless, FLL, Kevin Day, Kevux, Linux, Library, Distribution, Open-Source, specification, standard, fss-000f, simple packet

# Featureless Linux Library Specification

## FSS-000F (Simple Packet)

The version date of this specification is `2024/06/05`.

This is a network packet format that often contains `FSS-000e (Payload)` within it.

The Magic Block when containing `FSS-000e (Payload)` in the Payload Block is: `11010010100111101111010000111110`.

The Magic Block when containing unspecified plain text in the Payload Block is: `00101110000001001101110001000010`.

The Magic Block when containing unspecified binary data in the Payload Block is: `00010101101001001111000000001000`.

The Simple Packet structure is described in blocks, of which are structured in bytes.

There are three or four blocks in this format:

1. Control Block.
2. Size Block.
3. Magic Block.
4. Payload Block.

The Control Block is the first block in the packet and is considered endianless. There exists only a single byte within the Control Block (8-bits). Regardless of the endianness of the packet, leftmost bit is always the endianness bit. The second bit following that endianness bit represents the string or binary bit. The third bit following the endiannes bit represents the magic bit.

Control Block Structure:

    [ Endianness Bit ] [ String / Binary Bit ] [ Magic Bit   ] [ Remaining 5 Bits (unused) ]
    [ size: 1 bit    ] [ size: 1 bit         ] [ size: 1 bit ] [ size: 5 bits              ]

The endianness bit designates whether or not the packet is in big endian or little endian format. A bit value of 0 designates that this packet is in little endian and a value of 1 designates that this packet is in big endian format. All binary data within this packet, following the Control Block, must respect this endianness bit (including the Size Block).

The magic bit designates whether or not the packet contains the optional Magic Block. When the magic bit is not set, then there is no Magic Block.

The string or binary bit, a value of 0 designates that the packet is in string format and a value of 1 designates that the packet is in binary format. While the packet might be considered to be in string format, it is technically always in binary format due to the Control Block, the optional Magic Block, and Size Block. This means that the binary bit designating the packet as either a string packet or a binary packet is referring to whether or not the Payload Block is in string or binary format. The Payload Block itself can contain binary data even when in string format as per `FSS-000e (Payload)`.

The remaining bits are not defined by this standard and are expected to be 0. Non-formal or local uses may utilize these remaining 6 bits as desired. However, there may be additional standards that expand upon this and utilize these remaining Control bits. Anything that utilizes these unused Control bits may add or remove additional Blocks after the Control Block as they see fit. One possible use of the remaining bits is to designate a different variation of this Simple Packet standard.

Size Block Structure:

    [ Size Block    ]
    [ size: 32 bits ]

The Size Block is an unsigned 32-bit integer representing the size of the entire packet in bytes, including the Control Block and Size Block. This size must exactly match the packet to be a valid packet. The size represents number of bytes in the file. The Control Block is 1 byte long and the Size Block is 4 bytes long, therefore the maximum available size of the entire Simple Packet structure is `(2^32)-5`. The Magic Block is 4 bytes long, therefore when the magic bit is set, then the maximum available size of the entire Simple Packet structure is `(2^32)-9`.

The reason behind why the size includes both the Control Block and the Size Block in addition to the Payload Block is to avoid the need to perform any calculations for handling the size of the entire packet. The idea here is to optimize the packet for the network hardware transferring the packet. The network device should not need to read the contents of the packet in order to transfer the packet and therefore it only needs the number of the entire packet. Anything that wants to analyze this packet will have to incure the cost of calculating the Payload Block size by performing the appropriate subtraction from the size represented in the Size Block.

Magic Block Structure:

    [ Magic Block   ]
    [ size: 32 bits ]

The Magic Block is an unsigned 32-bit digit used to uniquely identify the packet. The 32-bits are treated as endianless such that the left to right order of the bits is always the same for both big and little endian systems. The Magic Block is required when the magic bit is set and it must not exist when the magic bit is not set.

This offers optimization in identifying the packet and its structure. This is particularly useful for quick identification on the network such as via routers. This is particularly useful for storing the packet as a file. This is particularly unhelpful for security and privacy given that it helps quickly identify the packet.

Payload Block Structure:

    [ Payload Block                                                ]
    [ size: (2^32)-5 bytes (or (2^32)-9 bytes if magic bit is set) ]

The Payload Block is not defined by this standard other than that it exists and is suggested to be in `FSS-000e (Payload)` format. If the Magic Block is present and set to `11010010100111101111010000111110`, then this is expected to be in `FSS-000e (Payload)` format. The `FSS-000e (Payload)` may be represented in either string format or binary format. The `FSS-000e (Payload)` may contain multiple header(s) but may only contain a single payload. With this in mind, it is recommended that only a single header be supported in the Payload Block. The payload Content may be in either a binary or string format regardless of the binary bit in the Simple Packet Header Block.

See the FSS-000e (Payload) specification file for details on the syntax rules for the Payload Block.

Example Packet Structure:

    [ Control Block ] [ Size Block                                  ] [ Payload Block         ]
    [ 0b10000000    ] [ 0b00000000 0b00000000 0b00000100 0b11010010 ] [ size: 1229 (1234 - 5) ]

Example Packet Structure with Magic Bit:

    [ Control Block ] [ Size Block                                  ] [ Magic Block                                 ] [ Payload Block         ]
    [ 0b10100000    ] [ 0b00000000 0b00000000 0b00000100 0b11010010 ] [ 0b11010010 0b10011110 0b11110100 0b00111110 ] [ size: 1225 (1234 - 9) ]