Data Link Layer

Data Link Layer 
Ensures Error free transmission of    information between two end stations.
Error detection & correction (CRC) and Retransmission
Accepting Packet & Transmitting Frames
Frame Sync.
MAC (Medium Access Control) on the lower half, deals with getting the data on and off the wire.

LLC (Logical Link Control) on the upper half, does the error checking.


CSMA/CD

The CSMA/CD access rules 
1) Carrier sense—Each station/transmitter continuously listens for traffic on the medium to determine when gaps between frame transmissions occur.
2) Multiple-access—Stations/transmitter may begin transmitting any time they detect that the network is quiet/idle (there is no traffic).
3) Collision detect—If two or more stations/transmitters in the same CSMA/CD network (collision domain) begin transmitting at approximately the same time, the bit streams from the transmitting stations will interfere (collide) with each other, and both transmissions will be unreadable. If that happens, each transmitting station must be capable of detecting that a collision has occurred before it has finished sending its frame.
.  All devices on the network have equal-priority access to the medium.
.  Multiple nodes may simultaneously receive data from the medium but only one node can transmit at a time.
.  The technique used to arbitrate is called Carrier Sense Multiple Access with collision detection (CSMA/CD).
.  A node wishing to send data, first “listens” the medium.
.  If some activity is going on then the node will differ its transmission until the activity ceases and a predetermined period of silence passes.
.  This period of inactivity is known as IPG (inter packet gap)
.  The IPG delineates each packet and allows all stations to detect carrier sense as inactive (IPG values is one round trip delay)
.  If two or more nodes simultaneously starts transmitting then a Collision occurs.
.  Each transmitting node monitors for “collision” and if detects one, stops immediately and sends a 32 bit jamming sequence.
.  Jam period guarantees that stations at the extremes of the network are able to detect collision condition.
.  If the collision is detected during preamble, Preamble/SFD sequence is completed and then Jam sequence is sent.
.  After collision the MAC retries until either it is successful or a maximum number of attempts have been made and all have terminated due to collisions.
.  The scheduling of the retransmissions is determined by a controlled randomization process called “truncated binary exponential backoff”.
.  The delay is integer multiple of slot time.
.  The number of slot times to delay before the nth retransmission attempt is chosen as a uniformly distributed random integer r in the range:
                        0 <= r < 2k
                        Where k = min (n, 10)
.  If all attempts fail, this event is reported as an error.
.  Algorithms used to generate the integer r should be designed to minimize the correlation between the numbers generated by any two stations at any given time.
.  A round-trip delay called Slot time determines how long it takes to detect a collision.
.  Slot time is fixed as 512 bit times for Ethernet.

.  If a collision is detected after slot time then its called as Late collision and transmission is aborted immediately.