Thursday, May 17, 2007

Ethernet - Short ideas

Theory

Layer 2 (data link) is divided into 2 sub-layers:

  • MAC: deals with problems regarding the transmission media (Copper / fiber optics / radio waves)
  • LLC: here operate for instance network device drivers or more general, any software that encapsulates the communication with a TX / RX equipment and which provides an interface to another software component (like an operating system, e.g. Cisco's IOS).
Ethernet operates at MAC and Physical layers (1.5 OSI layers) => deals with addressing, access to transmission media and with the effective transmission on Copper / Fiber Optics:
  • Addressing: by using the MAC address
  • Transmission media access: through CSMA/CD (Carrier Sense Multiple Access with Collision Detection) - many devices have access to the media and if collision is detected, measures are taken (basically retransmission)
  • Coding: how the bits are transformed into electrical signals: it depends on the transmission media and in the applied line code: Manchester (MPE/MDE), 4B/5B, etc
All of these functions are implemented in an Đ•thernet controller (like RTL8019AS, RTL8168, etc). Ethernet provides the possibility to implements networks that are cheap and scalable, with pretty good performance.
There are some factors that need to be considered when designing an Ethernet network; the thing to have in mind is segmentation and microsegmentation. Segmentation means "breaking" the layer 2 network into multiple collision domains. A collision domain is an "area" in which collision can (but not necessarily will) happen. More, collisions will not be propagated from one collision domain to another. The segmentation is possible with the use of switches.


    About switches
    Everybody saw them, but let's see how they work. Internally switches' main components are ASICs (Application-Specific Integrated Circuits) and the switching table. ASICs are the hardware / software modules that implement the Ethernet protocol. Each switch port has an ASIC and a switch may have multiple types of ASICs (for Copper, Fiber Optics, etc). The switching table is basically the implementation of a map between a MAC address and a port number. In this map we have MAC address as key and port number as a value. The problem is that MAC addresses are not ordered, but we should use them as memory address. How do we do this? Switches use CAM (Content-addressable Memory) chips as a support for the switching table. In CAMs addressing isn't made through an integer address, but through String values. Think of a CAM as a hardware hash map :) In the case of switches CAMS have MAC addresses as memory address and port numbers as content. CAM is the technology that permits the switching to be made in hardware rather than in software, resulting in decreased delay.


    Switching assures
    • Bridging with hardware support
    • A delay comparable with the delay of electrons traveling through Copper media (especially at the "cut-through" switching mode). More, after the way from input to output is "switched", the speed is the speed of electrons traveling through Copper media.
    • Low cost
    Bridging transforms an initially flatter network in a segmented one, by reducing the number of collisions. There is no collision between 2 Ethernet controllers that are both linked in 2 ports of a switch as long as each of the 2 Ethernet links (between controller1/controller2 and switch port's controller) have negotiated their speed to full-duplex.

    Collisions appear in the following situation and in the following steps:

    • There is a propagation media that is shared by multiple Ethernet controllers and at least 2 of them want to transmit at the same time.
    • 2 / more Ethernet controllers want to transmit at about the same time:
      • Controller1 starts sending a frame
      • Controller2 senses no activity on the transmission media (carrier sense function), because the electrical signal generated by Controller1 hasn't reach Controller2's RX => Controller2 starts sending, too
    Segmentation deals with segmenting the layer 2 network in "collision domains". A collision domain is a "piece/area of network" in which collisions can occur. Collisions are not propagated outside a collision domain.

    LAN design rules
    Cisco's 80/20 design rule: 80% of the traffic from a LAN is made inside the LAN.
    Cisco's Ethernet 5/4/3 rule: between each 2 stations (not Ethernet controllers) of an Ethernet LAN there must be at most 5 segments, 4 repeaters and at most 3 of the segments to be populated with other stations (the rest must be links between switches).

      Switch memory buffering
      Switches use buffers to temporary store frames that must go from one switch port to another. For layer 2 switches there are 2 buffering modes:

      1. Port-based: the same amount of memory is allocated for each port. This can cause problems if some ports are slower than others (they can reach out of memory)
      2. Shared memory buffering: memory is "globally" allocated and shared by all ports. There is a scheduling rule for frame delivery (FIFO is the simplest, but there are switches where we can determine the usage of another scheduling strategy)