Archived from groups: comp.dcom.lans.ethernet (
More info?)
In article <52053ea0.0407150447.50249409@posting.google.com>,
mittal@einfochips.com (mittal patel) wrote:
> >
> > > Hi,
> > >
> > > I want to know exactly how the SFD detection algorithm works for MII MAC
> > > receiver.
> >
> > SFD detection is completely specified in the IEEE 802.3 standard,
> > available free from standards.ieee.org.
>
> Yes, it's given in the 802.3 standard. The PhysicalSignalDecap
> function in the standard says: "receive one bit at a time from the
> physical medium until a valid sfd is detected". But when working at
> the MII interface, 4 bits are received by the MAC at a time. Therefore
> 1)Should MAC check 4 bit pattern 101011 or 8 bit pattern 10101011.
The SFD is an 8-bit field, therefore the MAC must check 8 bits to
determine the presences of an SFD (2 nibbles across the MII).
> 2)If the Preamble is corrupted, should the corrupted preamble ptterns
> be ignored, except the one which is similer to sfd.
In the original 10 Mb/s design, preamble was *expected* to be corrupted;
that's part of the reason why a preamble was sent before any data. In
this way, the "throwaway" preamble would experience the corruption
rather than the important data. Preamble corruption came about from:
decoder (PLL) startup phase/frequency offset, lowered S/N ratio (i.e.,
error robustness) while the cabling system and transceiver electronics
were coming to steady-state, external noise, etc.
The standard specifies that a valid SFD signifies the start of the MAC
frame. Preamble (corrupted or not) was ignored. That said, most *robust*
10 Mb/s implementation looked for some amount of valid preamble before
accepting a (presumed valid) SFD; my own designs looked for at least 16
valid preamble bits before accepting an SFD.
In 100 Mb/s systems, continuous signaling and the use of Start-of-Stream
Delimiters (SSD) virtually guarantees that the entire preamble will be
uncorrupted; however, an MII-based design must also allow for 10 Mb/s
PHYs, so you can't depend on this behavior.
Bottom line: I would recommend that you look for some number of valid
preamble bits, plus an 8-bit SFD, to qualify a MAC frame.
> 3) what if sfd is corrupted and data contains sfd pattern.
If the "real" SFD is corrupted, then it will not trigger the start of
the frame. If there is an SFD pattern within the data, it could trigger
a false start. However, the likelihood that such a frame would be passed
up to a client is vanishingly low. First, if you follow the advice from
above, the frame would have to contain both 16 (or more) bits of
preamble (101010...) immediately prior to the ersatz SFD. Second, the
32-bit FCS would also have to match "by chance", which has (at best) a 1
in 2^32 probability. Third, the MAC will then inspect the fields after
the ersatz SFD; e.g., the MAC DA would somehow have to match the
station's unicast (or some enabled multicast) address, the Type field
would have to appear valid, etc. All of this is highly unlikely.
In addition, the upper layer client will also be imposing some syntactic
restrictions. For example, if somehow the fields following the ersatz
SFD did pass the MAC address/Type/FCS constraints, *plus* it was aligned
on octet boundaries, the payload would also have to "appear" like an IP
datagram, or whatever Network or other client protocol was using the
Ethernet. Possible, but not worth worrying about.
Remember that this frame was already corrupted (due to the corruption of
the SFD); the proper behavior is to detect the error and discard the
frame, not to somehow recover from the corrupted SFD.
> 4)If MAC don't find sfd within first 8 bytes (i.e max(preamble+sfd)),
> should it stop frame collection after the 8 bytes considering sfd
> error.
>
Remember that, in 10 Mb/s systems, you can't always depend on the
integrity of the clock during decoder PLL synchronization. Noise might
cause lots of extraneous zero-crossings in the early data, making it
appear (to the MAC) that there were a lot more than 64 preamble bits, if
it was using the receive clock as its reference. Just keep looking for
the SFD, no matter how long it takes. You have nothing to lose.
--
Rich Seifert Networks and Communications Consulting
21885 Bear Creek Way
(408) 395-5700 Los Gatos, CA 95033
(408) 395-1966 FAX
Send replies to: usenet at richseifert dot com