I understand that Carrier Sense is essentially the NIC "listening" to the medium for any transmissions, Multiple Access means that multiple devices on the network can "listen" to the medium, and Collision Detection is the procedure it goes through if there is a Frame collision. My question is how does a NIC actually determine if there was a collision? is there a discrepancy in the voltages, or what?
Assume you have the following situation...
- PC with the NIC hard-coded to 100Mbps, Full-duplex
- RJ45 cable, pinned EIA-568B (not that the colors in the pinout matter)
- Cisco Catalyst Switch, using autonegotiation (at 100Mbps)
Since the PC's NIC is locked at 100/full, the Cisco's Ethernet autonegotiation fails and it falls back to 100/half. Now there is a duplex mismatch on the line. The Cisco switch uses CSMA/CD for access to the link.
Let's assume the PC and the Cisco both transmit at exactly the same instant; the logical diagram and physical layer diagram show the same behavior from two different perspectives, but the physical layer diagram is most relevant to your question.
LOGICAL DIAGRAM =============== Tx Tx 100/full -----> <----- 100/half PC ----------------------------------- Cisco Catalyst Switch PHYSICAL LAYER PIN DIAGRAM ========================== PC Cisco Catalyst Switch 100/full 100/half Tx D1 -----> 568B 568B Pin Signal Pin Signal 1 TX+ D1 --------------------------- 3 RX+ D2 2 TX- D1 --------------------------- 6 RX- D2 3 RX+ D2 --------------------------- 1 TX+ D1 6 RX- D2 --------------------------- 2 TX- D1 <------ Tx D1
In the diagrams above, the PC (full duplex) is on the left and the Cisco Switch (half duplex) is on the right. Both sides transmit (Tx) simultaneously on pins 1 and 2, this pair of pins is called D1.
When the NIC on the switch receives the PC's frame on the D2 pair while the switch is simultaneously transmitting on the D1 pair, the switch registers a collision (answer reference). The collision is only registered on the switch, because it is in half-duplex mode.
Notes about GigabitEthernet:
- Half-duplex is called out in the standardNote 1; however, nobody actually uses half-duplex GigE. This means that GE won't use CSMA/CD
- GE uses all 8 pins in the RJ45 mod plug, and the specific TX / RX pins are allocated dynamically.
Note 1 Quoting IEEE 802.3-2012 4.1 (Italic emphasis mine):
184.108.40.206.2 Reception without contention
In half duplex mode, at an operating speed of 1000 Mb/s, frames may be extended by the transmitting station under the conditions described in 220.127.116.11. The extension is discarded by the MAC sublayer of the receiving station, as defined in the procedural model in 4.2.9.
In the olden days (10base-2), a collision was detected by current sensing -- it takes more power (electrical current) when two transmitters step on each other. For the 10/100/1000-baseT specs, it's as simple as looking at the RX pair while transmitting on your TX pair. (or pairs in the case of 1000, but gig-e never does half-duplex.)
Modern (for 10base-X tech) transceivers use echo cancellation to subtract their signal from the wire to listen for other signals.
The MAC or repeater (hub) is is notified of a collision by the PHY
When a MAC is informed of a collision it goes through the collision detected procedure (random backoff).
When a repeater (hub) is informed of a collision it generates a "JAM signal" on all ports to ensure that the collision is detected by the MACs that sent the colliding frames and that other hosts correctly detect the line as busy.
How the phy detects the collision is media type specific. For coaxial ethernet it is based on the DC voltage on the coax https://books.google.co.uk/books?id=MRChaUQr0Q0C&pg=PA54&lpg=PA54&dq=coaxial+ethernet+collision+detection&source=bl&ots=oGaQGcNnkN&sig=OayChWr1zEIc8heoihW6Dm-p8JY&hl=en&sa=X&redir_esc=y#v=onepage&q=coaxial%20ethernet%20collision%20detection&f=false
The common variants of twisted pair and fiber ethernet are full duplex at an electricial level but for compatibility reasons and to allow operation in networks with repeaters (hubs) they needed to be able to operate in a half duplex mode. This is done by treating simultanious activity on the transmit and receive datapaths as a collision.
Note that links running in full duplex mode do not use CSMA/CD, collisions simply can't happen there. At 10Mbps CSMA/CD was the norm. In the early days of 100Mbps CSMA/CD was still used to support hubs (repeaters) but as switches (bridges) took over and autonegotiation matured full duplex became the norm. At 1Gbps half duplex mode exists in the standards but afaict noone ever sold a hub making it kinda pointless. At higher speeds half duplex is not supported at all.
CSMA/CD nowadays is a feature for compatbility with legacy equipment.