Question

Is it true that upon receiving a segment from Transport Layer(TCP) towards Network Layer(IP) the resulting data unit will be a packet. Whereas when receiving a user datagram from Transport Layer(UDP) the resulting data unit will be a datagram?

Was it helpful?

Solution

You are getting caught up in the details ... packet and datagram are not exactly well defined terms. I also think that you are also looking at things backwards. In a conventional network:

  1. the link layer (e.g., 802.3 "Ethernet" or 802.11 "Wi-Fi") presents frames to the network layer (e.g., IP, ICMP)
  2. The network layer assembles the frames into packets which are passed on to the next layer in the stack - the transport layer
  3. The transport layer, in turn, passes the bytes on to the application layer. The application layer API is really what distinguishes between data streams in TCP and datagrams in UDP

The OSI stack isn't really used in practice any longer. In most cases, it has been replaced by the Internet Protocol Suite. The easiest way to understand how network stacks work is to buy a copy of "TCP/IP Illustrated: Volume 1", download a nice network capture utility, and watch some Internet traffic. You can see how the packets are assembled from the physical layer upward.

OTHER TIPS

The term datagram is often considered synonymous to packet but there are some nuances. The term datagram is generally reserved for packets of an unreliable service, which cannot notify the sender if delivery fails, while the term packet applies to any packet, reliable or not. Datagrams are the IP packets that provide a quick and unreliable service like UDP, and all IP packets are datagrams;[4] however, at the TCP layer, what is termed a TCP segment is the sometimes necessary IP fragmentation of a datagram,[5] but those are referred to as "packets".[6]

[Emphasys added]

Wiki source

You absolutely need to familiarize yourself with the "7 layer network stack".

It doesn't perfectly apply to TCP/IP, but it's an excellent basis for understanding any "networking" protocol - including TCP/IP:

Short answer:

  • "packets" are something that are sent over the network.

  • For TCP/IP, the receiving hosts assembles the packets into a "stream".

  • For UDP, on the other hand, the receiving host assembles the same packet (or, actually packet(s)) into a "datagram".

"Packets" are a level 3 ("network layer") thing.

"Streams" and "datagrams" are a level 4 ("transport layer" thing).

In the case of TCP/IP, both "streams" and "datagrams" are accessed directly by Layer 7 (the "application layer": which includes HTTP/web, SMTP/e-mail, FTP/file transfer, etc etc).

Is it true that upon receiving a segment from Transport Layer(TCP) towards Network Layer(IP) the resulting data unit will be a packet.

No.

The only unit of reception in TCP that the client can see is a byte. TCP segments consist of one or more IP packets but all the application can see is a byte stream. Any and all segment and packet boundaries are lost before the application ever gets to see any data. You send some bytes, you receive some bytes, and there is no necessarily strong correlation between how many were sent and received respectively, except that they all add up to the same stream.

In UDP by contrast the unit of both sending and receiving is the datagram. You send a datagram, and if it arrives intact you receive the same datagram containing the same bytes and the same number of bytes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top