A network bridge, also known as a layer 2 switch, is a hardware device used to create a connection between two separate computer networks or to divide one network into two. Both networks usually use the same protocol; Ethernet is an example of a protocol. Network devices include, but are not limited to, Personal Computers (PCs), printers, routers, switches and hubs. Devices connected to a network via an Ethernet adapter card have what is known as a Media Access Control (MAC) address, also called a physical or hardware address. It is this address that uniquely identifies a device to a bridge that can then determine to which network the device is connected.
The principal function of a network bridge is to forward data based on the MAC address of the sending and receiving devices. This operation helps to eliminate what are known as collision domains. One way of defining a collision domain is a network in which one device, also called a node, forces every other device to listen when it is transmitting data packets. Another definition states that a collision domain exists when two or more devices attempt to transmit information at the exact same time. Networks running Carrier Sense Multiple Access/Collision Detection (CSMA/CD) should, in theory, be protected from collisions occurring, but CSMA/CD can fail.
Whenever collisions occur, the efficient transmission of data packets is greatly compromised. The more devices that are on a network trying to transmit data, the greater the chance for a collision to occur. A network bridge can be used to segment one network into two, thereby reducing the number of devices competing for transmission privileges. For example, if network A has 20 devices, there is the likelihood that two or more of them will attempt to transmit data at the same time and cause a collision. If a bridge is added, it can split network A into networks A and B of 10 devices each.
Once the network bridge is incorporated, it will begin to "listen" to the transmission of data performed by devices on the two networks. It accomplishes this by recording the MAC address of the devices in a table that it automatically generates without being programmed to do so. When the first device transmits data, the bridge will add its MAC address to what is known as a forwarding table for future reference. The bridge also looks at the MAC address of the destination or receiving device. If it does not appear in its table, the bridge will broadcast the data packet to all devices on both networks to locate the intended destination.
Forwarding tables are not instantly built, rather the network bridge has to wait until it receives a transmission from a device before it can learn its MAC address. MAC addresses of receiving devices also have to be learned via broadcast, a search for the location of the destination. Once the destination responds, its address is also added to the forwarding table of the network bridge. Eventually, all MAC addresses will be captured and data packets will be efficiently routed straight to their destination. This will happen without all devices having to listen to one transmitting device.
When the sending and receiving devices are on the same network, no forwarding of data packets takes place. If they are on opposite networks, the bridge will forward the information. The prevention of collisions is not the only advantage of using bridges; they also are used to control the flow of information to maintain privacy. When a device transmits, it is seen by the bridge as a MAC address that belongs to one of two separate networks, and if the sending and receiving devices are on the same network, the data will not be forwarded. This is one way a network administrator might maintain privacy of information.