Project

Assignment on layer 2, layer 3 and layer 4 header of OSI with all the important field in them.

INTRODUCTION

The OSI (Open Systems Interconnection) model is a conceptual framework that standardizes and describes the functions of a communication system or network. The OSI model is composed of seven layers, each representing a specific set of functions and services related to data transmission and communication. These layers work together to enable communication between different systems, regardless of their underlying technologies or protocols. Here's a brief introduction to each layer:

  • Physical Layer 1: This is the lowest layer of the OSI model and deals with the physical transmission of data over the network medium. It defines the electrical, mechanical, and procedural aspects of physical connections.

  • Data Link Layer 2: The Data Link Layer is responsible for the reliable transmission of data frames between directly connected nodes. It handles error detection and correction, as well as flow control and access to the physical medium. Ethernet is a commonly used protocol at this layer.

  • Network Layer 3: The Network Layer is responsible for logical addressing and routing of data packets across different networks. It handles packet forwarding, routing decisions, and congestion control. IP (Internet Protocol) is a key protocol at this layer.

  • Transport Layer 4: The Transport Layer provides end-to-end communication between the source and destination hosts. It ensures the reliable and orderly delivery of data by segmenting, sequencing, and reassembling packets. TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are examples of transport layer protocols.

  • Session Layer 5: The Session Layer establishes, manages, and terminates communication sessions between applications. It provides synchronization, check pointing, and recovery mechanisms to support reliable data exchange.

  • Presentation Layer 6: The Presentation Layer is responsible for data representation, translation, and encryption. It ensures that information sent by the application layer of one system can be understood by the application layer of another system.

  • Application Layer 7: The Application Layer is the highest layer in the OSI model and provides services directly to the end-user applications. It includes protocols such as HTTP (Hypertext Transfer Protocol), FTP (File Transfer Protocol), SMTP (Simple Mail Transfer Protocol), and others.

The OSI model serves as a reference framework for understanding and implementing network protocols and architectures. It promotes interoperability and standardization by separating network functions into distinct layers, each with its own well-defined responsibilities and protocols.

Theory

Layer-2

The Layer 2 header, also known as the Data Link Layer header, varies depending on the specific protocol used at this layer. One of the most commonly used protocols at Layer 2 is Ethernet. Let's explore the important fields of the Ethernet II framing, which is widely adopted. Here are the fields in the Ethernet II Layer 2 header:

  • Preamble: The preamble consists of a 7-byte pattern of alternating 1s and 0s. Its purpose is to alert the receiving device to an incoming frame and synchronize the receiver's clock. An example of a preamble is: 10101010 10101010 10101010 10101010 10101010 10101010 10101011.

  • Start Frame Delimiter (SFD): The SFD marks the end of the preamble and indicates the start of the frame. It consists of a single byte with the value 10101011.

  • Destination MAC Address: This field specifies the MAC (Media Access Control) address of the intended recipient of the frame. The MAC address is a unique identifier assigned to the network interface card (NIC) of a device. For example, a Destination MAC Address could be 00:11:22:33:44:55.

  • Source MAC Address: The Source MAC Address field identifies the MAC address of the sender of the frame. It indicates the network interface card that originated the frame. An example Source MAC Address is 66:77:88:99:AA:BB.

  • EtherType or Length: In Ethernet II framing, this field is known as EtherType and indicates the protocol type of the payload carried by the Ethernet frame. It specifies the higher-layer protocol that should receive the frame's payload. For example, the EtherType for an IPv4 packet is 0x0800, while for IPv6 it is 0x86DD. The Length field is used in IEEE 802.3 framing to indicate the length of the data field.

  • Frame Check Sequence (FCS): The FCS is a cyclic redundancy check (CRC) value calculated over the entire frame, including the header and data. It allows the recipient to verify the integrity of the received frame and detect any transmission errors. The FCS field is 4 bytes long.

To illustrate how these fields come together in an Ethernet II frame, consider the following example:

  • Preamble: 10101010 10101010 10101010 10101010 10101010 10101010 10101011

  • Destination MAC: 00:11:22:33:44:55

  • Source MAC: 66:77:88:99:AA:BB

  • Ether Type: 0x0800 (indicating an IPv4 packet)

  • Data: [Payload of the frame]

  • FCS: [Calculated CRC value]

The above fields, combined with the payload and FCS, form an Ethernet II frame that can be transmitted over an Ethernet network for data communication at Layer 2 of the OSI model.

Layer-3

The Layer 3 header, also known as the Network Layer header, is responsible for logical addressing and routing of data packets across different networks. In the context of the OSI model, the most common protocol used at Layer 3 is the Internet Protocol (IP). Let's explore the important fields of an IPv4 header, which is widely used. Here are the fields in the Layer 3 IPv4 header:

  • Version: This field specifies the version of the IP protocol being used. For IPv4, the value is 4.

  • Header Length: The Header Length field indicates the length of the IP header in 32-bit words. It allows variable-length options to be included in the header. The length is specified in 4-byte increments. For example, if the header length is 5, it means the header is 5 * 4 = 20 bytes long.

  • Type of Service (ToS): The Type of Service field provides information about the quality of service (QoS) requested for the packet. It includes subfields such as precedence, delay, throughput, reliability, and congestion control. These subfields help determine the priority and handling of the packet.

  • Total Length: The Total Length field specifies the total length of the IP packet, including both the header and the data payload. It is measured in bytes.

  • Identification: The Identification field is a unique value assigned to a packet by the sender. It aids in the fragmentation and reassembly of IP datagrams, allowing them to be divided into smaller pieces and reconstructed at the receiving end.

  • Flags: The Flags field contains control flags used for IP fragmentation and reassembly. It includes the "Don't Fragment" (DF) flag, which, when set, indicates that the packet should not be fragmented, and the "More Fragments" (MF) flag, which indicates whether more fragments of the original packet follow.

  • Fragment Offset: The Fragment Offset field indicates the position of a fragment within the original IP datagram. It is measured in 8-byte increments.

  • Time to Live (TTL): The Time to Live field specifies the maximum number of hops (routers) that the packet can traverse before being discarded. It helps prevent packets from circulating endlessly in the network by setting an upper limit on their lifetime.

  • Protocol: The Protocol field indicates the protocol carried in the data portion of the IP packet. It specifies the higher-layer protocol to which the packet payload should be delivered, such as TCP (6), UDP (17), or ICMP (1).

  • Header Checksum: The Header Checksum is a 16-bit checksum calculated over the IP header to ensure its integrity during transmission. It allows the recipient to verify if the header has been corrupted in transit.

  • Source IP Address: The Source IP Address field specifies the IP address of the sender, identifying the source of the packet.

  • Destination IP Address: The Destination IP Address field indicates the IP address of the intended recipient, identifying the destination of the packet.

To illustrate these fields, consider the following example of an IPv4 header:

  • Version: 4 Header

  • Length: 20 bytes

  • Type of Service: 0x00

  • Total Length: 576 bytes

  • Identification: 1234

  • Flags: 0 (No fragmentation)

  • Fragment Offset: 0

  • TTL: 64 Protocol: 6 (TCP)

  • Header Checksum: 0xABCD

  • Source IP Address: 192.168.0.1

  • Destination IP Address: 10.0.0.1

These fields, along with the TCP/UDP payload and additional layers, form an IPv4 packet that can be routed and delivered

Layer-4

The Layer 4 header, also known as the Transport Layer header, is responsible for providing end-to-end communication between the source and destination hosts. Two commonly used protocols at this layer are the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). Let's explore the important fields of both TCP and UDP headers. Here are the fields in the Layer 4 headers:

TCP Header:

  • Source Port: This field identifies the port number of the sending application or service. It specifies the source application on the sending host.

  • Destination Port: The Destination Port field indicates the port number of the receiving application or service. It specifies the destination application on the receiving host.

  • Sequence Number: TCP uses sequence numbers to ensure the correct order and delivery of data segments. This field contains the sequence number of the first data octet in the TCP segment.

  • Acknowledgment Number: The Acknowledgment Number field is used by TCP to acknowledge the receipt of data segments. It indicates the next sequence number that the sender of the acknowledgment is expecting to receive.

  • Data Offset: The Data Offset field specifies the length of the TCP header in 32-bit words. It indicates where the data begins in the TCP segment.

  • Flags: The Flags field contains several control flags that provide additional information about the TCP segment. Notable flags include:

    1. SYN: Synchronize sequence numbers to initiate a connection.

    2. ACK: Acknowledge the receipt of a segment.

    3. FIN: Indicate the end of a connection.

    4. RST: Reset the connection.

    5. URG: Indicate the presence of urgent data.

  • Window Size: The Window Size field specifies the number of bytes the sender is willing to accept before receiving an acknowledgment. It helps regulate the flow of data and prevent congestion.

  • Checksum: The Checksum field is a 16-bit checksum calculated over the TCP header, data, and a pseudo-header. It verifies the integrity of the TCP segment during transmission.

  • Urgent Pointer: The Urgent Pointer field is used to indicate the end of urgent data within a TCP segment. It points to the last urgent data byte in the segment.

UDP Header:

  • Source Port: Similar to TCP, the Source Port field identifies the port number of the sending application or service.

  • Destination Port: The Destination Port field specifies the port number of the receiving application or service.

  • Length: The Length field indicates the total length of the UDP datagram, including the header and the data, measured in bytes.

  • Checksum: The Checksum field is a 16-bit checksum calculated over the UDP header, data, and a pseudo-header. It helps verify the integrity of the UDP datagram during transmission.

To illustrate these fields, consider the following examples:

TCP Header:

  • Source Port: 1234

  • Destination Port: 80

  • Sequence Number: 1000

  • Acknowledgment Number: 2000

  • Data Offset: 5 (indicating a 20-byte header length)

  • Flags: SYN, ACK

  • Window Size: 4096

  • Checksum: 0xABCD

  • Urgent Pointer: 0

UDP Header:

  • Source Port: 5000

  • Destination Port: 53

  • Length: 32 bytes

  • Checksum: 0x1234

These fields, along with the data payload and additional layers, form TCP and UDP segments that are used for reliable or connectionless communication respectively, at Layer 4 of the OSI model.

Differences between Layer 2, Layer 3 and Layer 4

The OSI model is a conceptual framework that defines how different functions and services are organized in a network. Here are the differences between Layer 2, Layer 3, and Layer 4 of the OSI model:

Layer 2: Data Link Layer

  • Function: The Data Link Layer is responsible for the reliable transmission of data frames between directly connected nodes (usually within a local network).

  • Protocols: Ethernet, MAC (Media Access Control), PPP (Point-to-Point Protocol), etc.

  • Key features:

    1. Framing: Divides data into frames for transmission.

    2. Physical addressing: Uses MAC addresses to identify devices on the same network.

    3. Error detection: Detects and corrects errors at the link level.

    4. Access control: Controls access to the physical medium, resolves contention, and manages flow control.

Layer 3: Network Layer

  • Function: The Network Layer provides logical addressing and routing of data packets across different networks (inter-network communication).

  • Protocols: IP (Internet Protocol), ICMP (Internet Control Message Protocol), ARP (Address Resolution Protocol), etc.

  • Key features:

    1. Logical addressing: Assigns unique IP addresses to devices.

    2. Routing: Determines the best path for packet delivery across multiple networks.

    3. Fragmentation and reassembly: Divides and reassembles large packets for efficient transmission.

    4. Congestion control: Manages network congestion by regulating packet flow.

    5. Error detection: Uses checksums to ensure packet integrity.

Layer 4: Transport Layer

  • Function: The Transport Layer provides end-to-end communication and ensures reliable, error-free, and orderly delivery of data between source and destination hosts.

  • Protocols: TCP (Transmission Control Protocol), UDP (User Datagram Protocol), SCTP (Stream Control Transmission Protocol), etc.

  • Key features:

    1. Segmenting and reassembling: Divides data into smaller segments and reassembles them at the destination.

    2. Reliability: Provides reliable delivery by ensuring all data is received and retransmitting lost or corrupted segments (TCP).

    3. Connection establishment and termination: Establishes and terminates logical connections between hosts (TCP).

    4. Flow control: Manages the rate of data exchange to prevent overwhelming the receiver.

    5. Multiplexing and demultiplexing: Allows multiple applications or services to share a single network connection.

In summary, Layer 2 focuses on reliable transmission within a local network, Layer 3 handles logical addressing and routing between networks, and Layer 4 ensures end-to-end communication, reliability, and flow control between applications or services. Each layer has its own set of protocols, functions, and responsibilities in the OSI model.

Conclusion

The OSI model is a conceptual framework that defines the functions and services of a network, dividing them into seven layers.

  1. Layer 2, the Data Link Layer, handles the reliable transmission of data frames within a local network. It uses protocols like Ethernet and includes fields such as MAC addresses, Ether-type, and FCS.

  2. Layer 3, the Network Layer, provides logical addressing and routing between different networks. Protocols like IPv4 operate at this layer, and important fields include IP addresses, TTL, protocol, and checksum.

  3. Layer 4, the Transport Layer, ensures reliable and orderly communication between source and destination hosts. Protocols like TCP and UDP are used, with fields such as source/destination ports, sequence/acknowledgment numbers, flags, window size, and checksum.

  4. Layer 2 focuses on local network transmission, Layer 3 handles inter-network communication, and Layer 4 provides end-to-end communication between applications.

Understanding the headers and their fields at each layer is crucial for devices to perform functions like addressing, error detection, flow control, routing, and reliable data delivery.

By studying the OSI model and its associated headers, network professionals can design, troubleshoot, and optimize network infrastructures effectively, ensuring efficient and secure data transmission across various networks.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.