TCP & IP headers,




TCP inserts header fields into the message stream in the order listed above.
    Transmission Control Protocol (TCP) Header
  • Source and destination TCP port numbers are the communication endpoints for sending and receiving devices.
  • Message senders use sequence numbers to mark the ordering of a group of messages. Both senders and receivers use the acknowledgement numbers field to communicate the sequence numbers of messages that are either recently received or expected to be sent.
  • The data offset field stores the total size of a TCP header in multiples of four bytes. A header not using the optional TCP field has a data offset of 5 (representing 20 bytes), while a header using the maximum-sized optional field has a data offset of 15 (representing 60 bytes).
  • Reserved data in TCP headers always has a value of zero. This field serves the purpose of aligning the total header size as a multiple of four bytes (important for efficiency of computer data processing).
  • TCP uses a set of six standard and three extended control flags (each an individual bit representing on or off) to manage data flow in specific situations. One bit flag, for example, initiates TCP connection reset logic. The detailed operation of these fields goes beyond the scope of this article.
  • TCP senders use a number called window size to regulate how much data they send to a receiver before requiring an acknowledgement in return. If the window size becomes too small, network data transfer will be unnecessarily slow, while if the window size becomes too large, the network link can become saturated (unusable for any other applications) or the receiver may not be able to process incoming data quickly enough (also resulting in slow performance). Windowing algorithms built into the protocol dynamically calculate size values and use this field of TCP headers to coordinate changes between senders and receivers.
  • The checksum value inside a TCP header is generated by the protocol sender as a mathematical technique to help the receiver detect messages that are corrupted or tampered with.
  • The urgent pointer field is often set to zero and ignored, but in conjunction with one of the control flags, it can be used as a data offset to mark a subset of a message as requiring priority processing.
  • Usages of optional TCP data go beyond the scope of this article but include support for special acknowledgement and window scaling algorithms.
  • Version IPv4, IPv6 etc.
  • IP Header Length (number of 32 -bit words forming the header, usually five)
  • Type of Service (ToS), now known as Differentiated Services Code Point (DSCP) (usually set to 0, but may indicate particular Quality of Service needs from the network, the DSCP defines the way routers should queue packets while they are waiting to be forwarded).
  • Size of Datagram (in bytes, this is the combined length of the header and the data)
  • Identification ( 16-bit number which together with the source address uniquely identifies this packet – used during reassembly of fragmented datagrams)
  • Flags (a sequence of three flags (one of the 4 bits is unused) used to control whether routers are allowed to fragment a packet (i.e. the Don’t Fragment, DF, flag), and to indicate the parts of a packet to the receiver)
  • Fragmentation Offset (a byte count from the start of the original sent packet, set by any router which performs IP router fragmentation)
  • Time To Live (Number of hops /links which the packet may be routed over, decremented by most routers – used to prevent accidental routing loops)
  • Protocol (Service Access Point (SAP) which indicates the type of transport packet being carried (e.g. 1 = ICMP; 2= IGMP; 6 = TCP; 17= UDP).
  • Header Checksum (A 1’s complement checksum inserted by the sender and updated whenever the packet header is modified by a router – Used to detect processing errors introduced into the packet inside a router or bridge where the packet is not protected by a link layer cyclic redundancy check. Packets with an invalid checksum are discarded by all nodes in an IP network)
  • Source Address (the IP address of the original sender of the packet)
  • Destination Address (the IP address of the final destination of the packet)
  • Options (not normally used, but, when used, the IP header length will be greater than five 32-bit words to indicate the size of the options field)