TCP/IP packets and datagrams

16,155

Solution 1

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.

Solution 2

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

Share:
16,155
user1927452
Author by

user1927452

Updated on July 30, 2022

Comments

  • user1927452
    user1927452 almost 2 years

    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?

  • paulsm4
    paulsm4 over 11 years
    To say "The OSI stack isn't really used any longer" is just flat-out wrong. The OSI 7-layer stack is a reference model. The X.500 protocol implementation (like contemporaries DecNET and LanTastic) - ancient history. The OSI reference model: is - and continues to be - a valuable conceptual model. IMHO... PS: "frames" (Layer 2), "packets" (Layer 3) and "datagrams" (TCP/IP, Layer 4) are all examples of "PDUs" (Protocol Data Units) and are all very well defined!
  • michelson
    michelson over 11 years
    @paulsm4 - what I mean is that the OSI model as defined, most notably layers 5 and 6, are all but forgotten. Everything above the transport layer has merged into the application layer which is precisely what the IETF model is. I do agree that OSI is well-defined to a fault where the IETF model is, at best, loosely defined.
  • user207421
    user207421 over 11 years
    He may need to familiarise with the 4 layer TCP/IP model. There is absolutely no need to familiarise with the obsolete and inapplicable 7 layer OSI network model.
  • user207421
    user207421 over 11 years
    @paulsm4 The OSI reference model applies to the ODI protocol stack. TCP/IP has its own reference model, and it has 4 layers, not 7. The 7 layer OSI reference model is as obsolete as the protocol stack it refers to.
  • paulsm4
    paulsm4 over 11 years
    Close, but still not quite correct. The network layer deals with packets: true. It's the Application layer (Layer 7) that deals with either 1) a stream of bytes, or 2) a UDP datagram. Not the network layer :) Interestingly, the datagram may or may not be the size of your layer 3 packet: cboard.cprogramming.com/networking-device-communication/…
  • paulsm4
    paulsm4 over 11 years
    @D.Shawley: +1 - good explanation. In particular, thank you for distinguishing "frames", "packets" and "datagrams". And noting that TCP "byte streams" and UDP "datagrams" are what's passed to the "Application Layer" (layer 7: the level at which your program is actually reading and writing network data).
  • user207421
    user207421 over 11 years
    It is certainly not an ignorant statement, and your comment is borderline offensive. All the standard authors on TCP/IP that I have ever read, including the RFCs themselves, agree that the OSI model doesn't apply to it, and there are whole layers of OSI that don't apply to anything in particular at all: not even to the OSI protocol stack with any great precision actually. As a pedagogical tool it is obsolete by about 20 years. What is important is the concept of protocol layers, and the fairly universal agreement on what is in layers 2 and 3.
  • user207421
    user207421 over 11 years
    @paulsm4 Come to think of it I'm not even sure what 'receiving a segment from Transport Layer ... towards Network Layer even means. TCP doesn't send segments to IP at all, they are a figment of its own imagination, not part of the interface.
  • user207421
    user207421 almost 8 years
    @paulsm Late, but I haven't stated anything whatsoever about the network layer, let alone what you have attributed to me here. Talking about layer 7 in the context of TCP/IP is meaningless. The TCP/IP reference model doesn't have 7 layers, and the 7-layer OSI model doesn't apply to TCP/IP, or to anything else that I am aware of. I don't see what your link has to do with my answer.