Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
TCP/IP Packet Format
Next article icon

TCP/IP Packet Format

Last Updated : 11 Sep, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

TCP/IP's primary function is to transport computer data from one device to another. Different computer networks' protocols include TCP and IP. The primary contrast between TCP (Transmission Control Protocol) and IP (Internet Protocol) is the fundamental method by which it transmits the data. The basic difference in methodology is that IP functions by having only the information about the destination of the email on the other hand TCP needs both the information about the recipient and the sender of the mail. Both protocols have other Packet Formats and they have different approaches to functioning.

TCP Packet Format

TCP (Transmission Control Protocol) is a fundamental protocol in the TCP/IP (Transmission Control Protocol/Internet Protocol) family. It offers a dependable and organized data distribution between applications that are executed on several hosts in a network. The TCP packet format must be understood in order to analyze and resolve network communication issues. The TCP packet format will be thoroughly examined in this article, along with its many fields and their importance.

TCP Packet Format
Diagram Showing the TCP packet Format

TCP Packet format has these fields

  • Source Port(16 bits): It holds the source/transmitting application's port number and helps in determining the application where the data delivery is planned.
  • Destination Port (16 bits): This field has the port number of the transmitting application and helps to send the data to the appropriate application.
  • Sequence Number (32 bits): It ensures that the data is received in proper order by ordered segmenting and reassembling them at the receiving end.
  • Acknowledgment Number (32 bits): This field contains the upcoming sequence number and it acknowledges the feedback up to that.
  • Data Offset (4 bits): The data offset field indicates the starting point of the TCP data payload also storing the size of the TCP header.
  • Control Flags (9 bits): TCP uses a few control flags to regulate communication. Some of the important flags include:
    • SYN (Synchronize): Responsible for connecting the sender and receiver.
    • ACK (Acknowledgment): Its purpose is transfer the acknowledgement of whether the the sender has received data.
    • FIN (Finish): It informs whether the TCP connection is terminated or not.
    • RST (Reset): Mainly used to reset the connection when an error occurs.
  • Window Size (16 bits): The size of the sender's receive window is specified by this property.
  • Checksum (16 bits): It reveals if the header was damaged during transportation.
  • Urgent Pointer (16 bits): This field points to the packet's first byte of urgent data.
  • Options (Variable length): This field represents the different TCP options.
  • Data Payload: This field mainly contains the information which is the actual application data that is being transmitted.

IP Packet Format

IP (Internet Protocol) packet structure is used for data transmission in computer networks. Data units received from the layer above are encapsulated in an IP packet, and additional header data is added. IP Payload is the term used to describe the enclosed data. All the information required to deliver the packet at the other end is in the IP header.

IP Packet
Diagram Showing the IP Packet Format

Key IP Packet Format Fields

  • Version (4 bits): This field contains a value in four bits which is 0100 generally. This value is utilized in distinguishing between IPv4 and IPv6, using four bits.
  • Header Length (4 bits): This value is 4 bits in size and it represents how many 32-bit words are present in the IP header. In short it is also called as HE-LEN.
  • Type of Service (TOS) (8 bits): This field mainly deals with the information about how the quality of the service is being delivered. The first 3 bits provides distinction and prioritization of IP packets depending on certain service needs, such as precedence, delay, throughput, dependability, and cost.
  • Total Length (16 bits): The total length of the IP packet is stored in bytes. This value and the HE-LEN sums up to the value of the Payload.
  • Identification (16 bits): This field gives a specific IP packet a distinctive identity. This helps to identify the fragments of the an IP Datagram Uniquely.
  • Flags (3 bits): Contains control flags for packet fragmentation and reassembly, such as the "Don't Fragment" and "More Fragments" flags.
  • Fragment Offset (13 bits): After a packet is fragmented and put back together, this field contains the location of it inside the original packet. It represents the number of Data Bytes ahead of the particular fragment in the specific Datagram.
  • Time to Live (TTL) (8 bits): This field specifies the total lifetime of the Data packet in the internet system. This field indicates how many hops (routers) an IP packet can make before being terminated. This values goes from 0-255.
  • Protocol (8 bits): This IPv4 headerspecifies the type of transport layer protocol, such as TCP, UDP, or ICMP, to which the IP packet will be routed. For example, TCP is indicated by number 6 and UDP protocol us denoted by number 17.
  • Header Checksum (16 bits): This is an error checking layer which is added to identity errors in the header. By comparing the IP header with its checksum for error detection, it ensures the IP header's integrity.
  • Source IP Address (32 bits): The IPv4 sender's 32-bit address is represented by this value.
  • Destination IP Address (32 bits): This value represents the 32-bit IP address of the intended recipient.
  • Options (variable length): This field has options and parameters for security, record route, time stamp, etc. You can see that the End of Options, or EOL, usually marks the end of the list of options component.

A variety of essential components that each have a specialised function in facilitating efficient and reliable data flow across networks make up the IP packet structure.


Next Article
TCP/IP Packet Format

T

triashabiswas
Improve
Article Tags :
  • Computer Networks

Similar Reads

    ARP Protocol Packet Format
    Pre-requisites: How Address Resolution Protocol (ARP) works? ARP is a communication mechanism that is used to translate a network address, such as an IP address, to a physical (MAC) address on a local network. ARP packets are transmitted and received on a network to achieve this mapping. An ARP pack
    2 min read
    Packet Format Frame in Wireshark
    Pre-requisites: Introduction to Wireshark After capturing some packets or after opening a previously saved captured file and analyzing them, sometimes we need to print the details of the captured packets. To print the packets, click on the "File" menu and then select the “Print” menu item. This will
    2 min read
    What is Fragmentation of a Packet?
    Packet fragmentation is the process of breaking down a large packet into smaller, manageable parts when the network's maximum segment size (MSS) is smaller than the size of the packet. This ensures that the packet can be transmitted across the network without being blocked due to its size.Once fragm
    5 min read
    History of TCP/IP
    The beginning of the RFC(Request for Comments) format happened back in 1969 as part of the ARPANET(Advanced Research Projects Agency Network) project. RFC is the official channel for publication of the IETF, which stands for Internet Engineering Task Force. IETF is the IAB that stands for Internet A
    4 min read
    TCP/IP in Computer Networking
    Introduction : TCP/IP (Transmission Control Protocol/Internet Protocol) is a suite of communication protocols that define the standards for transmitting data over computer networks, including the internet. The TCP/IP protocol is the foundation of the internet and enables devices to communicate with
    8 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences