views:

64

answers:

2

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

+2  A: 

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
How does **ETHERNET** ensure that the preamble won't occur in TCP/IP section?
wamp
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
Probably by some sort of **escaping** technique inside ethernet data...
Pablo Santa Cruz
@ChrisW: ethernet protocol is usually implemented in hardware. In ETHERNET cards... But I still thing *frames* belong to MEDIUM ACCESS LAYER.
Pablo Santa Cruz
But how does the hardware recognize where the beginning of a frame is?
wamp
Has the **escaping** technique any actual provement?
wamp
@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
I don't think that's stable, because if one frame is broken, it'll affect all subsequent frames.
wamp
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
@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
@Tyler, so you also agree with the **escaping** technique theory?But is there any reference on this?
wamp
@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
@caf, can you elaborate the `electrical methods`? Also what you mean by `carrier` ?
wamp
@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
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
@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
@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
+1  A: 

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