Skip to main content

Packets in networking

What a packet is and how it sits in the network stack

Anatomy of a packet

IP header

  • Version: identifies IPv4 or IPv6.
  • Header length (IHL) and total length: size of the IP header plus payload.
  • Identification, Flags, Fragment Offset: used for fragmentation and reassembly.
  • Time to Live (TTL): limits the lifetime of a packet to prevent looping.
  • Protocol: indicates the transport protocol carried inside (for example TCP or UDP).
  • Header checksum: validates header integrity (for IPv4).
  • Source and Destination IP addresses: endpoints of the packet.
  • Options: optional fields used for advanced features or debugging.

Transport header

  • TCP: source port, destination port, sequence number, acknowledgment number, data offset, flags (SYN, ACK, FIN, etc.), window size, checksum, urgent pointer, and options.
  • UDP: source port, destination port, length, checksum.

Payload

The payload is the application data carried by the packet after the headers. This could be anything from a DNS query to a fragment of an HTTP request or a video frame. The receiving end uses the transport header to interpret and pass the payload to the appropriate application.

A concrete, hypothetical example: a packet journey from host to server

Note: the following is a hypothetical example designed to illustrate how the pieces fit together. Values shown are illustrative and not taken from a live capture.

  • Scenario: A client on a LAN sends an HTTP request to a web server.
  • Layer 4 (transport): TCP is used on port 80. The client opens a TCP connection and sends a GET request as a TCP segment.
  • Layer 3 (network): The TCP segment is wrapped in an IPv4 packet. Key header fields might look like:
    • Version: 4
    • IHL: 5 (20 bytes for the IP header)
    • Total length: 60 bytes
    • Identification: 12345
    • Flags: DF (do not fragment)
    • Fragment offset: 0
    • TTL: 64
    • Protocol: 6 (TCP)
    • Source IP: 10.0.0.2
    • Destination IP: 10.0.0.10
    • Header checksum: (computed)
  • Layer 2 (data link): The IPv4 packet is carried in an Ethernet II frame addressed to the first-hop router’s MAC address, with EtherType 0x0800 for IPv4.
  • Layer 1 (physical): The frame is transmitted over the local network segment and is routed toward the destination through one or more hops.
  • Result: The server receives the IP packet, decapsulates the IP header, and passes the TCP segment to the HTTP server process if the connection is established and the payload is appropriate.

MTU, fragmentation, and encapsulation: why size matters

Maximum Transmission Unit (MTU) is the largest payload size that can be transmitted in a single frame on a given link. When a packet exceeds the MTU of a link, IP fragmentation can occur (for IPv4). Fragmentation splits the packet into smaller pieces, each with its own IP header, and the destination reassembles them. Fragmentation saves the need to drop large packets, but it adds overhead and increases the risk of reassembly errors, out-of-order delivery, and inefficiency.

Key concepts to keep in mind:

  • Path MTU: the smallest MTU along the path between source and destination. If any link has a smaller MTU, large packets may be fragmented or dropped.
  • Fragment offset and identification fields allow routers to reconstruct the original packet at the destination.
  • Fragmentation is more costly for performance because each fragment carries its own headers and can complicate reassembly, especially in high-lidelity or real-time traffic.
  • Path MTU Discovery (PMTUD) helps determine the largest packet size that can traverse a path without fragmentation by relying on the DF (do not fragment) bit in IPv4 or the analogous behavior in IPv6.

Practical guidance for engineers

  • Map and document the MTU across critical paths. Start with the standard Ethernet MTU of 1500 bytes and adjust for any tunnels or overlays (VPNs, GRE, IPsec) that add headers and reduce usable payload.
  • Prefer PMTUD over guessing MTU values for paths with VPNs or middleboxes. If PMTUD is not feasible, plan for a conservative MTU on edges to avoid fragmentation.
  • Avoid fragmentation in latency-sensitive or high-throughput paths. Where possible, keep packets within MTU bounds and use large-send optimizations only after validating the path characteristics.
  • In tunnels and encapsulated links, account for the extra header overhead. For example, a tunnel that adds 40 extra bytes reduces the effective MTU for the inner packet, so you may need to lower the outer MTU accordingly.
  • When troubleshooting, differentiate between problems caused by IP fragmentation and those caused by transport-layer behavior or application-level retries. A packet capture that shows fragmented IP fragments or a high rate of retransmissions can point you to MTU or topology issues.

Common mistakes, limitations, and safety considerations

  • Assuming every path supports the same MTU; a smaller link downstream can force fragmentation or drops if DF is not managed correctly.
  • Relying on fragmentation for long-lived, high-throughput traffic. While it preserves delivery, it introduces overhead and potential reassembly delays.
  • Overlooking tunnel overhead when calculating effective MTU. VPNs, NAT, and encapsulation add headers that eat into the usable payload.
  • Ignoring security implications of fragmentation. Some security devices reassemble fragments for inspection, which can impact performance or reveal misconfigurations.

Note: In IPv6, fragmentation is handled differently, and hosts typically perform PMTUD. Some environments still require careful handling of MTU and fragmentation due to tunnels or legacy devices, so treat MTU planning as an explicit design consideration, not an afterthought.

Conclusion

Next step

Next step: select a representative path in your network and perform a path MTU assessment to document the largest non-fragmenting packet size you can safely send across that path, then adjust interface and tunnel configurations accordingly.

Comments

Popular posts from this blog

Car Wash System vb.net

This software consists of a database that save the registration number of every vehicle being wash along side with the date, type of wash made and price Screen Shot Source Code To view records in the database: Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\washRcd.accdb;Persist Security Info=False") Dim sql As String sql = " SELECT * FROM tblwash" conn.Open() Dim dt As New DataTable Dim cmd2 As New OleDb.OleDbDataAdapter(sql, conn) cmd2.Fill(dt) DataGridView1.DataSource = dt DataGridView1.Refresh() conn.Close() To insert new record in the database: Private Sub insert() Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\washRcd.accdb;Persist Security Info=False") Dim updateSql As String = String.Format(...

Face recognition using EmguCV 3.0 and typing pattern recognition

Introduction An MSc project with the title Student Examination System, where the objective is to put the students in an examination condition but instead of having an invigilator in an examination center, the system will cater for the proper ongoing of the exam. the system can be used as an online examination system The system is able to: Recognizing the face shape of a particular student Detect if there is more than one person in the examination room  Analyze the typing pattern of a student and detect if any one person is taking part in the exam voice recognition for the student and detect if there is more than one person speaking in the examination room Setup Download Emgu CV from  http://www.emgu.com/wiki/index.php/Main_Page Download Haarcascade from  https://github.com/opencv/opencv/tree/master/data/haarcascades Create an account at  https://www.keytrac.net/ Face recognition The snippet below illustrates how the Emgu CV is loaded whe...

Google reCAPTCHA implementation - ASP.NET C#, ASP.NET Web API, Android

Google reCAPTCHA implementation ASP.NET C# Steps to implement Google reCAPTCHA in your website using technologies such as ASP.NET C#, ASP.NET web API, HTML and javascript. First you need to use your google account to login to Google reCAPTCHA  to register a new site. Add a label of your choice in the label section and for web implementation select the reCAPTCHA V2 radio button. Next in the domain section you can add several domains, for testing purposes you can add localhost also followed by another domain in the next line. Accept the terms and conditions and click on the button register. After you click register, google will generate a site key and a secret key and  instructions how to integrate it on both client and server side. Create ASP.NET Web API Next step is to open Microsoft Visual Studio and create a new project by selecting File > New from the menu bar and then select Project.  Select ASP.NET Web Application(.NET Framework) in the p...