In computer science, a "collision" has two different meanings. One occurs when two or more sets of data are modified and produce the same resulting value. The other is specific to networking and happens when two devices transmit data at the same time.
1. Data Collision
A data collision may take place when hashing data or when calculating a checksum. A hash function reduces data to a smaller value and is often used in compression and cryptography. While the hash operation may save disk space, it is possible that two different inputs may produce the same output. Multiple hash functions can be used to avoid duplicate values when a collision occurs.
Similarly, checksums are not guaranteed to be unique since they are smaller than the original data. While the probability is often very low, two different data sets can theoretically produce the same checksum value. A well-designed algorithm should minimize this risk.
2. Network Collision
A network collision occurs when two or more devices attempt to transmit data over a network at the same time. For example, if two computers on an Ethernet network send data at the same moment, the data will "collide" and not finish transmitting. This is why most networking protocols confirm that packets has been received before transmitting additional data.
Switches and routers can reduce collisions by checking if a transmission line is idle or "in use" before transmitting data. A common method is CSMA/CD or "Carrier-sense multiple access with collision avoidance." While it is possible to reduce collisions, they cannot be completely avoided. For example, if two systems determine a line is idle and then transmit data at exactly the same time, a collision may occur. This can be resolved by retransmitting the data after a random delay.
Updated: December 20, 2018