|  | 2.3 | Switching and VLANs
| 2.3.3 | Layer 2 and L ayer 3 switching
There are two methods of switching data frames-Layer 2 and Layer 3 switching. Switching is the process of taking an incoming frame from one interface and delivering it out through another interface. Routers use Layer 3 switching to route a packet; switches (Layer 2 switches) use Layer 2 switching to forward frames. The difference between Layer 2 and Layer 3 switching is the type of information inside the frame that is used to determine the correct output interface. With Layer 2 switching, frames are switched based on MAC address information. With Layer 3 switching, frames are switched based on network-layer information. Layer 2 switching does not look inside a packet for network-layer information as does Layer 3 switching. Layer 2 switching looks at a destination MAC address within a frame. It sends the information to the appropriate interface if it knows the destination address location. Layer 2 switching builds and maintains a switching table that keeps track of which MAC addresses belong to each port or interface. If the Layer 2 switch does not know where to send the frame, it broadcasts the frame out all its ports to the network to learn the correct destination. When the frame's reply is returned, the switch learns the location of the new address and adds the information to the switching table. The manufacturer of the data communications equipment determines the Layer 2 addresses. They are unique addresses that are derived in two parts- the manufacturing (MFG) code and the unique identifier. The Institute of Electrical and Electronic Engineers (IEEE) assigns the MFG code to each vendor. The vendor assigns a unique identifier. Except in Systems Network Architecture (SNA) networks, users have little or no control over Layer 2 addressing because Layer 2 addresses are fixed with a device, whereas Layer 3 addresses can be changed. In addition, Layer 2 addresses assume a flat address space with universally unique addresses. Layer 3 switching operates at the network layer. It examines packet information and forwards packets based on their network-layer destination addresses. Layer 3 switching also supports router functionality. For the most part, the network administrator determines the Layer 3 addresses. Protocols such as IP, IPX, and AppleTalk use Layer 3 addressing. By creating Layer 3 addresses, a network administrator creates local areas that act as single addressing units (similar to streets, cities, states, and countries) and assigns a number to each local entity. If users move to another building, their end stations obtain new Layer 3 addresses, but their Layer 2 addresses remain the same. Because routers operate at Layer 3 of the OSI reference model, they can adhere to and create a hierarchical addressing structure. Therefore, a routed network can tie a logical addressing structure to a physical infrastructure, for example, through TCP/IP subnets or IPX networks for each segment. Traffic flow in a switched (that is, flat) network is therefore inherently different from traffic flow in a routed (that is, hierarchical) network. Hierarchical networks offer more flexible traffic flow than flat networks because they can use the network hierarchy to determine optimal paths and contain broadcast domains.