0

How do protocols like TCP identify the beginning of a new frame?

kbrimington
  • 25,142
  • 5
  • 62
  • 74
wamp
  • 5,789
  • 17
  • 52
  • 82

2 Answers2

2

TCP can be viewed as an ordered stream of bytes. I don't think TCP needs to identify the beginning of new frames. Frames are usually related to medium access control protocols such as ETHERNET.

ETHERNET protocol uses a preamble (sequence of bytes) to identify beginning of a frame.

This is a common TCP/IP STACK used on LANs:

TCP <-- transport (byte streams here)
------
IP <-- network (packets here)
------
ETHERNET <-- medium access (frames here)
------
RJ45 cable <-- physical layer 
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • How does **ETHERNET** ensure that the preamble won't occur in TCP/IP section? – wamp Aug 25 '10 at 02:01
  • It's true that there is a header at the start of each packet/frame, but I think that the start of the frame is detected by hardware, i.e. by [Layer 1, the Physical Layer](http://en.wikipedia.org/wiki/Physical_Layer). – ChrisW Aug 25 '10 at 02:02
  • @ChrisW: ethernet protocol is usually implemented in hardware. In ETHERNET cards... But I still thing *frames* belong to MEDIUM ACCESS LAYER. – Pablo Santa Cruz Aug 25 '10 at 02:16
  • But how does the hardware recognize where the beginning of a frame is? – wamp Aug 25 '10 at 02:16
  • Has the **escaping** technique any actual provement? – wamp Aug 25 '10 at 02:17
  • @wamp That depends on the hardware - see e.g. [Ethernet physical layer](http://en.wikipedia.org/wiki/Ethernet_physical_layer). I'm assuming that the hardware sees: frame ... not a frame ... frame ... not a frame ... etc. – ChrisW Aug 25 '10 at 02:26
  • I don't think that's stable, because if one frame is broken, it'll affect all subsequent frames. – wamp Aug 25 '10 at 02:35
  • I expect that hardware detection is equivalent to switching on, switching off, switching on, i.e. a clean reboot: the detection of a new frame is independent of previous frames. – ChrisW Aug 25 '10 at 02:39
  • @wamp if one frame is broken, the physical layer will just discard all data until the next complete preamble. Some frames may be lost due to this, but that's OK. The Ethernet link layer does not guarantee reliable delivery. That's left to other layers such as TCP. – Tyler McHenry Aug 25 '10 at 03:15
  • @Tyler, so you also agree with the **escaping** technique theory?But is there any reference on this? – wamp Aug 25 '10 at 03:36
  • @wamp: "Escaping" is not used. The ethernet physical layer can directly sense the presence or absence of a carrier on the underlying medium, using electrical methods. – caf Aug 25 '10 at 04:33
  • @caf, can you elaborate the `electrical methods`? Also what you mean by `carrier` ? – wamp Aug 25 '10 at 04:51
  • @wamp: The presence of a voltage (for coaxial medium) or a voltage differential (for twisted-pair mediums) above a threshold causes a transistor to switch on. "Carrier" in the sense of [definition 2 in this Wikipedia article](http://en.wikipedia.org/wiki/Carrier_wave). – caf Aug 25 '10 at 05:03
  • I still can't agree with such conclusion. Think what if we roll our own protocol, we can't depend on the voltage to do the job for us... – wamp Aug 25 '10 at 05:07
  • @wamp: If you roll your own protocol, it depends on lower level protocols to tell it how big the frame it has recieved is. TCP depends on IP, IP depends on the datalink layer, and the datalink layer depends on the physical layer. It is only if you want to build a new physical layer protocol that you need to worry about the electrical signalling that denotes frame boundaries. – caf Aug 25 '10 at 08:29
  • @wamp This SO question should be enlightening for you (particularly the answer by Tom Anderson): http://stackoverflow.com/questions/990661/how-does-ppp-or-ethernet-recover-from-errors – Tyler McHenry Aug 25 '10 at 12:09
1

How does ETHERNET ensure that the preamble won't occur in TCP/IP section?

A TCP stream is carried in (broken into) one or more IP packets.

IP packets are carried in Ethernet frames.

The IP network device driver splits its IP packets into one or more Ethernet frames before transmission (splitting the IP packets, and adding Ethernet frame headers), and after reception it reassembles Ethernet frames into IP packets (discarding Ethernet frame headers and combining IP packet fragments).

ChrisW
  • 54,973
  • 13
  • 116
  • 224