Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is a TCP segment not part of a TCP packet?

Here's what I've read:

A segment is a piece of application data chopped into a transportable size by TCP and wrapped with a TCP header

Isn't the TCP header itself made up of segments?

share|improve this question
This is really unclear. Are you asking if a TCP header is made up of segments? Or if a TCP segment is part of a TCP packet? – viking Jun 16 '11 at 14:51
You are not making things any clearer. TCP does not know packets. – Florenz Kley Jun 16 '11 at 15:13

11 Answers 11

We say TCP segment is the protocol data unit which consists a TCP header and an application data piece (packet) which comes from the (upper) Application Layer. Transport layer data is generally named as segment and network layer data unit is named as datagram but when we use UDP as transport layer protocol we don't say UDP segment, instead, we say UDP datagram. I think this is because we do not segmentate UDP data unit (segmentation is made in transport layer when we use TCP).

Data Encapsulation and the TCP/IP Protocol Stack

share|improve this answer
what's the difference between "package" and "packet"? – Janus Troelsen Mar 5 '13 at 21:19
I meant packet :) I fixed it, thanks. – Ricardo Cristian Ramirez Mar 5 '13 at 21:43
all this explanation applies for TCP/IP model, maintained by IETF. – logoff Jun 7 at 13:10

The original TCP RFC is kind of fuzzy with how it uses the term "segment".

In some cases, the term "segment" refers to just the current piece of the application data stream that's being transmitted, which excludes the TCP headers. For example, the TCP "Maximum Segment Size" (MSS) is the maximum size of the application data chunk in this message, not counting the TCP headers.

But in other cases the term "segment" includes the whole TCP message, including the TCP headers. In fact in at least one case the spec mentions TCP segments with no application data (such as plain Acks).

A single whole IP message is a "datagram".

The original IP RFC refers to link-layer messages as "packets". IP datagrams can be broken into "fragments" to fit into the packet size limits on small-packet networks.

The IEEE 802.3 / Ethernet link layer refers to a single contiguous physical-layer transmission as a "packet". The MAC data-link portion of the packet is called the "frame". The frame begins with the destination MAC address and ends with the Frame Check Sequence. The part of the frame that may contain an IP datagram (or fragment thereof) is called the "MAC Client Data field".

So, technically, there is no such thing as a "TCP packet" or an "IP packet". Packets are terms from the layers below IP. TCP has "segments", and IP has "datagrams".

share|improve this answer

The TCP header, also referred to as "segment header", and the payload, or data, or "segment data" make up the TCP segment, of varying size.

share|improve this answer

A header is not made up of segments. A header always has the same size and must be complete. Otherwise, the packet could not be decoded.

What you refer to as "Segment" is the whole "packet" that is later on combined with others to the TCP stream. See:

Transmission Control Protocol accepts data from a data stream, 'segments' it into chunks, and adds a TCP header creating a TCP segment.

share|improve this answer

A TCP Segment is called a Datagram. Typically,a Segment or a datagram is a Packet. When the datagram or packet is processed by the Network layer, it adds the IP Header to the data and it becomes a IP Packet.

Transport layer segments the data into smaller units called Segments, datagrams or so called packets. But we usually refer them as Segments.

share|improve this answer

A TCP segment IS a packet. A segment is only a part of a TCP connection stream between two computers. A datagram is a "packet" in UDP terms.

share|improve this answer

An IP packet is made up of an IP header with data attached. The data, is a TCP header and a segment of application data, called TCP Segment. TCP Segement is what you usually call a TCP Packet.

share|improve this answer

The "generic" term for things like this is Protocol Data Unit, or PDU.

-------   ------------   ----------------------   --------------------------
Layer 1 - Physical     - Transceiver            - bits, or a physical signal
Layer 2 - Datalink     - Ethernet               - frame
Layer 3 - Network      - IP                     - packet
Layer 4 - Transport    - TCP                    - segment
Layer 5 - Session      - SIP                    - data, request, or response
Layer 6 - Presentation - Encryption/compression - data, request, or response
Layer 7 - Application  - HTTP                   - data, request, or response

Things kind of get blurry with specific protocols from layer 4 and up (for example, to this day I don't know of anything that's really purely a session protocol, and there really isn't such a thing as a common "presentation" protocol but it's defintely almost separate layer in a lot of software/communication stacks).

Also, as previously mentioned, each one of these PDU's has a header that's distinct from its payload, or data. The header has information about the data and possibly a checksum for verification on the other end.

share|improve this answer
isn't the work TPDU used instead on the upper layers? see – Janus Troelsen Mar 5 '13 at 21:25

TCP receives data from the application layer and 'chops' this data into several data-segments; pieces of the original data with an added TCP header. Part of this header is a sequence-number which is used by the TCP protocol on the receiving-end to put all received segments (minus the headers) in the right order and re-assemble the original data which it then transfers to the application layer.

So, to answer your question; the term 'TCP packet' doesn't really exist. It is called a 'segment' which consists of a header and a data-section. The header itself consists of several 'fields' which contain, among others, a sequence number, checksum and source- and destination port numbers.

share|improve this answer

When you send data thought a TCP connection, the amount of data you send may exceed the maximum size of bytes allowed by the connection in a single packet. This amount "Maximum Segment Size" (also called MSS) is "negotiated"(1) at the connection time between the two TCP end-points (the client and the server). The OSI level 4 protocol TCP is responsible of the scatter/gather. It means that your data stream is split into smaller parts (called the segments) and sent separately through the network. At the other side, the TCP layer is responsible of re-gathering the packet in the correct order to reform the stream just like it was sent. Nothing can tell you that the segments will arrive at the destination in the same order than at the departure. That is also why packets are numbered. More, packets are acknowledged one by one separately(2) by the receiver but sometime packets can be lost. Then no ACK will be returned from the destination of the packet to the emitter. Then the emitter should resend it (that is also the role of TCP). Sometime the packet is received correctly but the ack is not received by the emitter (lost packet again). In such a case, the emitter will resend it, but the receiver sees that it already received it (that is a Dup packet) and eliminate it but resend the ack to the sender.

Also to improve throughput the emitter can send several packets in series and do not have to wait for the previous ack to send the next packet. It is also part of TCP protocol and it is called sliding windows. The number of sent packet pending for an ack is limited.

(1) In facts, there are no negotiation at all, each end-point tells the Maximum Size he is able to deal with. This value do not include the 20 bytes of IP Header, neither the 20 bytes of TCP Header. (2) several packets can also be acknowledged by a single ACK.

Keep in mind that Datagrams are encapsulated data sent on a IP network or using a connection-less protocol like UDP. Packets are encapsulated data for a connexion-oriented protocol like TCP. Segments are portions of a data stream sent on TCP. See W.Richard Stevens "TCP/IP illustrated" to have a far better explanation of all this stuff.

share|improve this answer

tcp segment is only a concept, it's different with ip defragment

when you send data that is bigger than ip mtu, it is put into one ip packet, but the ip layer then find the ip packet is too long to transmit,so it will split big packet into several pieces, each of them have the same Identifier but with different offset and data length. the receive side is responsible for collecting all the pieces, after received all the pieces it will reassemble all the pieces into one whole ip packet and push it to upper protocol layer.

but the tcp layer have different behavior. when you send a data that is big enough, the tcp layer won't put the data into one tcp packet then split them into pieces(but ip does), it retrieve a part of the raw data into one tcp packet and then push the tcp packet to ip layer, the length of the tcp packet is determined by mss, later it will retrieve another part of the rest data into another tcp packet, and repeat the process till all the data are transmitted.

if tcp don't use mss,it is horrible. assume you send a data that is bigger than mss, it will be put into only one tcp packet(data is not split into small pieces due to mss not used), tcp packet is bigger than ip mtu, so the ip will split the tcp packet into pieces. the tcp packet will re-transmit if any one of the pieces is lost, waste time and bandwith

ps: tcp_mss = ip_mtu - tcp_header

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .