Today I have been looking at Layer 1 and layer 2 devices.
Layer 1 Devices
There are not really any Layer one devices. Layer one really defines the physical interconnect between boxes; the actual cables, wires and fibers that form the connections of the network.
Layer 2 Devices
I remember the days of 10Base Ethernet hubs, where every packet was broadcast on single broadcast domain. These hubs are dumb devices and can waste considerable bandwidth by passing all broadcast and other data, and causing collisions preventing other stations from transmitting data.
Ethernet runs a protocol called Carrier Sense Multiple Access with Collision Detection or CSMA/CD for short – not to be confused with the token ring system CSMA/CA which uses a collision avoidance system by means of a token passed from one host to another. If you like the TV show, Breaking Bad, its a system much like the talking pillow.
So, CSMA/CD however doesn’t do that. All it does is detect collisions on the shared line. Once a collision is detected, both hosts back off the bus, based on a random timer. If at the end of the time period, the bus is free, transmission will continue. Obviously there are issues with this in that this system is inefficient, and slow, wastes bandwidth, and on a busy bus, can cause tremendous congestion.
Moving from hubs, to switches alleviates this problem. With a hub, because every host is sharing bandwidth, they all sit in the same collision domain. Moving to switches, where each interface of the switch is managed, each switch interface becomes its own collision domain (Micro segmentation). So for instance, a 24 port switch now has 24 collision domains, where as a 24 port hub has one. A bridge will segment a collision domain, although it will not segment a broadcast domain.
This is another term to get familiar with; the broadcast domain defines the spread of broadcast packets. On a single hub, the broadcast domain was the entire hub and on a hub based network, the borders of the broadcast domain are delineated by routers and hosts. With switches, the entire switch is a broadcast domain, just like a hub, until you start using VLANs.
The Mac Address Table
Switches use the MAC address to intelligently route frames rather than broadcast them across all ports. This is achieved by using a MAC address table. The MAC address table has a number of different names that you might see:
- MAC table
When a frame enters the switch, the SOURCE MAC address is checked, and if it is not in the MAC address table, it is added.
Be aware that entries in the table will age out after 300 seconds. This is configurable.
The destination MAC address is then checked against the MAC address list and if it is present, the frame is sent on its way (Forwarded). If it is not present, the frame is FLOODED to every port, looking for the destination device. Once that device replies, the MAC address table is updated and a route established. If however there is no destination address response OR the destination is on the same port as the source (a hub feeding a switch for instance), the frame is FILTERED or dropped.
- Flooding – unknown unicast frame, sent out on all ports (except the input port)
- Forwarding – sent to a single known port
- Filtering – dropped
The MAC address table ages over time and that time can be set, but is default to 300 seconds.
Broadcast frames are sent out on MAC address: ff.ff.ff.ff.ff.ff.ff.ff’ and are itnended for ALL recipients. Remember the unicast is sent to all but is looking for one recipient.
To limit the scope of this broadcast, you can use virtual LANs (VLANs)
How is the frame processed?
- Store and forward – default on newer systems.
- Cut through
- Fragment free
Store and Forward – stores the frame (while checking MAC table). Last few bites are the FCS (Frame Check Sequence) and this is checked against the frame payload. If the check passes, the frame can be forwarded. This method adds latency and memory/cpu overhead.
Cut Through – forwards the frame as it comes in but does not check the FCS. Very fast but no error detection.
Fragment Free – Works on the principle that if there is damage to the frame it will be evident in the first 64 bytes so this is the only data that is checked. If this is ok, the frame is forwarded. FCS is not checked.
Other things to remember
Bandwidth – the bandwidth of a hub is shared. The bandwidth of a switch is on a per port basis meaning that a fast Ethernet port in full duplex mode, can transfer data at 200Mb/s. That is 100Mb/s in each direction at the same time.