2009年11月9日 星期一

Dealing with multiple clients

CSMA/CD shared medium Ethernet

Ethernet originally used a shared coaxial cable (the shared medium) winding around a building or campus to every attached machine. A scheme known as carrier sense multiple access with collision detection (CSMA/CD) governed the way the computers shared the channel. This scheme was simpler than the competing token ring or token bus technologies. When a computer wanted to send some information, it used the following algorithm:

Main procedure
1.Frame ready for transmission.
2.Is medium idle? If not, wait until it becomes ready and wait the interframe gap period (9.6 µs in 10 Mbit/s Ethernet).
3.Start transmitting.
4.Did a collision occur? If so, go to collision detected procedure.
5.Reset retransmission counters and end frame transmission.

Collision detected procedure
1.Continue transmission until minimum packet time is reached (jam signal) to ensure that all receivers detect the collision.
2.Increment retransmission counter.
3.Was the maximum number of transmission attempts reached? If so, abort transmission.
4.Calculate and wait random backoff period based on number of collision
5.Re-enter main procedure at stage 1.

This can be likened to what happens at a dinner party, where all the guests talk to each other through a common medium (the air). Before speaking, each guest politely waits for the current speaker to finish. If two guests start speaking at the same time, both stop and wait for short, random periods of time (in Ethernet, this time is generally measured in microseconds). The hope is that by each choosing a random period of time, both guests will not choose the same time to try to speak again, thus avoiding another collision. Exponentially increasing back-off times (determined using the truncated binary exponential backoff algorithm) are used when there is more than one failed attempt to transmit.

沒有留言:

張貼留言