If you replace the hub in Figure 2-18 with a LAN switch, the switch prevents the collision on the left.
The switch operates as a Layer 2 device, meaning that it looks at the data link header and trailer. A
switch would look at the MAC addresses, and even if the switch needed to forward both frames to
Larry on the left, the switch would send one frame and queue the other frame until the first frame was
finished.
Now back to the issue created by the hub’s logic: collisions. To prevent these collisions, the Ethernet
nodes must use half-duplex logic instead of full-duplex logic. A problem only occurs when two or
more devices send at the same time; half-duplex logic tells the nodes that if someone else is sending,
wait before sending.
For example, back in Figure 2-18, imagine that Archie began sending his frame early enough so that
Bob received the first bits of that frame before Bob tried to send his own frame. Bob, at Step 1B,
would notice that he was receiving a frame from someone else, and using half-duplex logic, would
simply wait to send the frame listed at Step 1B.
Nodes that use half-duplex logic actually use a relatively well-known algorithm called CSMA/CD
(carrier sense multiple access with collision detection). The algorithm takes care of the obvious
cases but also the cases caused by unfortunate timing. For example, two nodes could check for an
incoming frame at the exact same instant, both realize that no other node is sending, and both send
their frames at the exact same instant, causing a collision. CSMA/CD covers these cases as well, as
follows: