There are two common ways to format data in a computer network: the fixed-length field and type-length-value. The following sections consider each of these.
Fixed-Length Fields
How should a host interpret the bits shown in Figure 15-1?
Figure 15-1 A Series of Bits Received
What the host needs is
• Context describing what these bits contain, or a grammar.
• Translations from sets of bits to data, or a dictionary.
For instance, applying the IPv6 header specific to the string of bits shown in Figure 15-1 results in Figure 15-2.
Figure 15-2 Using Fixed-Length Fields to Interpret Bit Received Overlaying the IPv6 header fields, the host can interpret these bits as
• Class: 0
• Flow label: 0
• Payload length: 1500
• Next header (type): 6
• Hope limit: 16
• Source (1): 2001
• Source (2): db8
• Source (3): 3e8
• Source (4): 0
• Source (5): 0
• Source (6): 100
• Source (7): 101
This IPv6 packet, containing a TCP segment, can be forwarded through 16 more routers, sourced from 2001:db8:3e8::100:101.
The host knows where each field is in this string of bits because the contents and length of each field are described in a standard protocol specification. Each field in the protocol is described with a fixed length, so this kind of encoding is called fixed-length encoding, or fixed-length fields.
If the transmitter and receiver use the same standard to encode or marshal the data into a stream of bits, they can transfer data across the network. Figure 15-3 illustrates the relationship between the sender, receiver, and specification.
Figure 15-3 Relationship Between Transmitter, Receiver, and Specification
• An external organization, developer, etc., creates a specification for a protocol.
• A coder develops an application that encodes and decodes data using the specification.
• This software is installed on host A, where it is used to encode data using the specification.
• This software is installed on host B, where it is used to decode data using the specification.
The protocol specification provides the grammar and dictionary required to build the application that encodes and decodes data carried across the network.