Introduction to computer networks:
Definition Of a Network:
A computer network or referred as just a network, is a combination of two or more computers, and also other peripherals/devices as well (like printers, external HDD, modems etc), that are connected together so that they communicate with each other and thereby exchange commands and share data, hardware and other resources. 
A Computer Network or simply Network is a collection of computers and devices connected by communications channels that facilitates communications among users and allows users to share resources with other users. Networks may be classified based on a wide variety of characteristics. 
A network is a group of terminals, computers, servers, and components which accommodates an easy flow of data and sharing of resources between each another. The general purpose of a network is to transfer information/data between multiple devices. This usually contains a system sends request for information to another system, which responds to the request and replies with suitable information back to the requesting system. These systems might be computers or could also be printers, a teller machines, or telephones. It is also a fact that these systems might not be on the same wire but can also be located on different continents, connected over a global network. 
Evolution of Networks:
The evolution of networks is quite interesting. The first and foremost operational computer network in the world is the Advanced Research Projects Agency Network (ARPANET) developed for the US DoD (Department of Defense). This research was funded by The Advanced Research Projects Agency (ARPA). The initial network development began in 1969 based on the design from 1960s.
In the earlier sixties, the predominant mainframe computers were standalone computers. The electronic communication between these computers was meagre due to the fact that they came from different manufacturers and didn't have a standard communication mechanism. During 1960s the US ARPA commissioned a project to build a communication link between the computers. ARPANET thus evolved in 1967. ARPANET started with 4 nodes in 1969 and grew to 100 by 1975. The TCP protocol came into existence in 1973 to enable communication between different operating systems. Later TCP split into TCP/IP where TCP is for reliable transfer and IP for datagram routing. TCP/IP became popular with the entry of UNIX.
Uses of networks:
Ø Easy Facilitation of communications.
Ø Sharing the hardware.
Ø Sharing the files, data, and information and
Ø Sharing Software.
Network data transmission cycle:
An interesting part of networks is how data that is initiated for an application on a source computer is delivered to its corresponding application on the exact destination computer over a network that might be on the same wire or may be across continents. The below diagram depicts a realtime scenario for data transfer over networks.
* The application that neds network usage generates a data packet and feeds it forward to the operating system that further generates the network transmission packet.
* The originating source (computer/device etc) will have to pack the information based on a method which both systems can understand.
* The sender then uses methods that are commonly understood by the systems to deliver the packet to the destination – This is functionality is called a protocol.
* The packet then over the network is transferred to the receiver based on some network governing algorithm.
* The destination computer/system on receiving this packet checks for any errors incurred during transmission.
* The data is then unpacked and passed to the local application for processing.
* The same process is followed to acknowledge or reply to the source.
NETWORK PACKET – OSI MODEL:
Every network protocol should evolve from a core skeleton of the system interconnection model. The OSI (Open System Interconnect) reference model has always been an essential element of computer network design. The OSI is an abstract version of all the real-time network protocols and how equipment should interoperate using it.
The OSI model is standard device and maintained by the ISO (International Standards Organization). Although some of the current technologies might not fully live on to this standard, it always remains a standard to introduce network architectures.
The OSI Model Stack:
The task of internetworking is divided by the OSI model into a series of layers which are actually the different stages. Layers are ordered from lowest to the highest. These layers together form the OSI stack. The stack consists of 7 layers:
ISO – OSI Reference Model
Upper Layers of the OSI Model
The application, presentation, and session layers of OSI stack designate the upper layers. In general, software in these stages performs application related activities viz data formatting, data encryption, and also connection management. HTTP, SSL and NFS are standard examples of technologies implemented in the upper layer of OSI model.
Lower Layers of the OSI Model
The remaining stages considered as the lower layers of the OSI model are to provide core level network-specific functionalities like routing, addressing, and flow control. Examples of lower layer technologies in the OSI model are TCP, IP, and Ethernet.
Benefits of the OSI Model
* Complexity Abstraction: As the network communication is divided into logical pieces the complexity of network protocol design is minimized.
* Compatibility: The OSI model ensures different equipment like network adapters, hubs and routers are compatible inspite of the fact that they come from different manufacturers. When both vendors stand for this model, a Product from one vendor will be more compatible with the product from another vendor.
* Extensibility: The OSI model also enables network designs more extensibility for new protocols, network services and network devices are easier to be added to a layered architecture.
Classifications of network:
Networks are classified based on different criteria. Below are a few classifications of networks in a nutshell.
* Connection method
* Wired technologies
* Wireless technologies
* Functional relationship (network architecture)
* Network topology
Network hardware components:
Networks involved hardware components that deal with the network data. Below are a few components that play a major role in networks.
Network interface cards (NIC): A network card or a network adapter hardware component designed to provide physical access to a networking medium and also a low-level addressing system using MAC addressing.
Repeaters: An electronic device that receives a data signal eliminates noise and regenerates the same signal and retransmits it at higher power levels to cover long distances.
Hubs: A network hardware that consists multiple ports. Packet that arrives on any of the port dispensed to all ports of the hub, the port that has a matching MAC will process this packet.
Bridges: A network bridge connects different network segments at the data link layer. Unlike hubs, bridges will not copy traffic to all ports but will learn which MAC addresses are reachable through specific ports by associating a port and an address. Bridges learn the association of ports and addresses by examining the source address of frames that it sees on various ports. When an unknown address occurs, bridges do a broadcast to all ports accept the source. It then associates the new port with this address.
Bridges are classified as Local bridges (LAN), Remote bridges (WAN), Wireless bridges (WLAN)
Switches: A switch is device that based on the MAC addresses in the packet makes forwarding decisions of frames and filters layer 2 datagram's. A switch follows a star topology for devices and cascading additional switches. Multi-layer switches can do the routing based on Layer 3 addressing which is additional logical level.
Routers: A networking device uses information in protocol headers to forward packets using forwarding tables to decide the best next router for each packet.
Introduction to Network Switching
A general network consists of:
* nodes (computers)
* a medium for connection (wired or wireless)
* Specialized network equipment like routers + switch unit.
The switch + router might connect this network with the internet or in general the outer world to another network.
Switch vs. Routers
A quick dig into the differences between switches and routers.
Switches usually work at Layer 2 (Data link layer) of the OSI Model
routers work at Layer 3 (Network layer) of the OSI model
Switches forward frames based on MAC addresses
Routers forward data frames based on IP address or Layer 3 addresses
a switch will pass along any broadcast packets they receive to all the other segments in the broadcast domain
A router will not broadcast all packets to the other segments
Data packets are forwarded based on the address on the data link.
Data packet is transferred only if the address of the other device is specified.
This device is a good option when communication is between devices of the same network
This device will be an option when communication is over networks as it maintains network separation.
Of all the algorithms between switches and routers have a major difference. Its is how broadcasts are handled. Broadcasts are used any time a device needs to make an announcement to the rest of the network or is unsure of who the recipient of the information should be.
Why network switch?
In the basic networks today, nodes are connected using hubs. But for growing networks, there are potential problems at configuration level:
* Scalability - In a hub network growth cannot be accommodated without sacrifice of performance due to the fact that it has a limited shared bandwidth. With growing application bandwidth, network growth will recommend network redesign.
* Latency – in a hub network as number of nodes increase the time that it takes a packet to get to its destination increases. As each node in the hub network has to wait for transmission to avoid collisions.
* Network failure – In a hub network, if any of the devices are cond to a lower speed or excess broadcast this will lead to a network failure over all. Switches can be cond to limit broadcast levels.
* Collisions – In Hub network, the Ethernet node will not send out a packet unless the network is clear of traffic. If more than one node send out packets at the same time it will lead to collision and packet loss.
While hubs provide a cheaper and physically easier method to scale up and minimize the distance that the packets must travel to get from one node to another, they lack in viewing the actual network as discrete segments. That is where switches come in. All the problems mentioned above can be corrected by switches. Switches speed things up.
How Adding Switches is a solution?
In a hub, when a device is transmitting data, all the other devices will have to wait for the network to be traffic free. When the number of such devices increase, or the size of data being transmitted is high, the total response time of the network increases. A Switch actually provides an exit ramp for the network traffic. A switch which follows a star topology will eliminate the need for packets to wait to get on to the network for transmission.
An important variation between a hub and a switch is how bandwidth is allotted. A hub shares the band width between devices where are switch dedicates full bandwidth to the device.
Role of switches in networks:
Multi-Layered Switches can work at one or more OSI layers including end-to-end communication. Switches connect through different channels including Ethernet, Fiber Channel, ATM, ITU-T G.hn and 802.11. While Layer 2 functionality is excess for speed-shifting within a technology, interconnecting technologies such as Ethernet and token ring are easier at Layer 3. "Layer-3 switches" are optimized larger switches for high-density Ethernet connectivity.
In few environments where there is a need for analysis of network performance and security, switches can be connected between WAN routers as analytic modules. firewall, network intrusion detection, and performance analysis modules are provided by some vendors are can plug into switch ports. Some of these functions are combined, but in other cases, the switch creates a mirror image of data to go to an external device. As most switch port mirroring accommodates only one mirrored stream, fanning out data to several read-only analyzers, such as intrusion detection systems and packet sniffers is simpler.
Classification of Switches
switches classification based on Presence:
Due to the fact that switches are costlier than hubs, most networks are a combination of switches and hubs.
Example, all the computers in a department of a company can be connected over a hub and a switch can be used to connect multiple departments of the company.
Fully Switched Networks: When switches replace all the hubs of an Ethernet network with a dedicated segment for every node it's a fully switched network. As the only devices on each segment are the switch and the node, the switch picks up every transmission before it reaches another node. The switch then forwards the frame over the appropriate segment. Since any segment contains only a single node, the frame only reaches the intended recipient. This allows many conversations to occur simultaneously on a switched network.
Switching allows full-duplex Ethernet, which means data can be transferred bidirectional at a time. In a fully switched network every node communicates only with the switch, not directly with other nodes. In this environment, collision detection process is of least need and transmission can be done at will as there is total bandwidth allocated to the device. This allows bidirectional transmission and collision-free environment. Each node can now utilize full network bandwidth to communicate.
switches classification based on form factor:
* Desktop switch: which are not in enclosure and are used in a home or small office environments
· Rack mounted switches
* Chassis switch - with swappable "switch module" cards. e.g. Alcatel's OmniSwitch 7000; Cisco Catalyst switch 4500 and 6500; 3Com 7700, 7900E, 8800.
* DIN rail mounted: Large switches normally seen in industrial environments or panels
Switch classification based on configuration:
* Unmanaged switches - As the name says, switches without a configuration interface or options are unmanaged switch or the plug and play kind. Are cost effective switches, desktop mounted and mostly found in homes or small businesses.
* Managed switches – These switches can be cond using a console or command line interface accessed via telnet or Secure Shell with a SNMP agent allowing management from a remote computer sometimes a web interface for management. Configuration changes like enabling/disabling of features such as Spanning Tree Protocol, set port speed, create or modify VLANs Managed switches are again classified as:
o Smart (or intelligent) switches - Managed switches with limited management features like basic settings, such as VLANs, port-speed and duplex etc. A low cost switch that is limitedly managed over a web interface.
o Enterprise Managed (or fully managed) switches – Switches that can be fully managed and comes with a command Line Interface, SNMP agent, and web interface. Additional features to manipulate configurations like ability to display, modify, backup and restore configurations. Enterprise switches can be customized or optimized and are expensive than "smart" switches. In large enterprises where centralized management is required and cost effective, these switches are used.
switch classification based on architecture
Switches differential in physical design. Three of the popular configurations in use are:
* Shared memory - all incoming packets are stored in a common memory buffer shared by all the switch ports and then sent via correct port for the destination node.
* Matrix - This type of switch maintains an internal grid with the input and output ports crossing each other. When a packet turns up on the input port, the MAC address is verified on the lookup table to identify the correct output port. The switch then connects the two ports on the grid.
* Bus architecture – in this architecture, A common bus is shared across all of the ports using TDMA. A switch of this configuration will have a dedicated memory buffer for each port, as well as an ASIC to manage control to the internal bus access.
Switches are classified into different layers based on their topology; however they have many features in common. Most commercial switches user primary Ethernet interface at different speeds. Switch ports default to full duplex operations except if the architecture requires it to work in a half duplex environment. At any layer, switches can also implement power over Ethernet (PoE) where the switch can also act as a power source to the device.
Layer-1 Hubs VS Higher-Layer Switches
A network hub is a simplest form of a switch. They don't manage any traffic that comes but only act as a connecting medium between the nodes. Every packet that comes onto this hub is broadcasted to all the other ports on the hub except the source port; this is the reason for high latency or packet collisions to occur.
A network bridge operates at the MAC level or the data link layer of the OSI model. In the bridging the bridge learns the MAC address of the devices connected and associates it with a port. Classic bridges can interconnect on basis of spanning tree protocol eliminating links so the LAN is a tree without loops. Contrary to routers, spanning tree bridges can have topologies with a single active path between two points. The latest edition of IEEE 802.1D-2004, adopts the 802.1w extensions as the core standard. Because layer 2 user full duplex communication using an internal forwarding plane which is faster than any interface, giving the impression of dedicated paths within multiple devices.
On learning the topology through a STPprotocol, it forwards the data link layer frames implementing a layer 2 forwarding method. There are four forwarding methods a bridge can use:
1. Store and forward: The switch buffers the frames performs an error check on each frame then forwards it on.
2. Cut through: On reading the hardware address on the frame, the switch starts to forward it without error checking.
3. Fragment free: A method which is a combination of benefits in "store and forward" and "cut through". Fragment free considers the first 64 bytes (addressing field) of the frame. As per the specifications of Ethernet, collisions would be detected during the first 64 bytes of the frame, so error frames are not forwarded. Error checking of the packet data is done typically in a router.
4. Adaptive switching: A method of automatically switching between above three modes. This is a switch that provides access to server ports which generally connect to them at a much higher speed than what is used by the end user devices.
A layer 3 switch can perform some or all the function of a router within the confinement of Ethernet. IP Multicast one of the common capability of layer 3. A layer 3 switch increases efficiency by delivering the data to the exact port where the device wants to listen to the group. IGMP Snooping is implemented when the switch is not aware of multicast or broadcast.
Layer 4 switch are defined vendor dependant and the major capability is NAT (network address translation), and load addition based on TCP sessions. The device can include firewall, VN concentrator or security gateways.
Layer 7 switch can distribute load based on URL or application level settings. Layer 7 switches can have a web cache and participate in content delivery networks.
INTRODUCTION TO L2 SWITCHING
Layer 2 Switch Evolution
Layer 2 switches are installed for high speed data access at datalink layer in enterprises. Layer 3 switches are over layer 2 and are a new phenomenon. The evolution of Layer 2 and Layer 3 switches are based on their previous products.
Layer 2 Switches
Bridging technology came around the 1980s. Bridging involves segmentation at LAN. A multiport bridge learns the MAC address of the ports and passes on the frames for that MAC directly over that port. The bridge ensures not to transfer same data to the originating ports. Layer 2 switches also provide similar functionality. Like multiport bridges they learn and forward frames to the correct ports. The only different is that multiple switch parts inside the switch can be active simultaneously.
In the above, we can observe that a four port switch on Layer 2 connects Station A, B, C, D. Now when A and B are communicating, C and D desire to communicate in a single CPU bridge (full bandwidth) the forwarding has to be done at software level where all the packets that come from A are send to B and simultaneously another bridge is formed to send data between C and D.
The hardware-level Layer 2 switching with their hardware support can forward such frames in parallel so that A and B and C and D can have simultaneous conversations. This parallel communication has many advantages. Assuming A and B are NetBIOS stations and C and Do on IP stations, without sacrificing their protocols this hardware switching can be done.
Virtual LANs: In real LANs aren't so clean. Assuming A and B run on NetBIOS, c and D on LAN, for A and C to communicate there must be a IP router for this. However, in this absence, if A has a broadcast message, C and D shouldn't receive it. Virtual LANs evolve in this situation. Layer 2 VLANs broadcast domains at Layer 2. On configuration Layer 2 switches can restrict MAC broadcasting. Stations on two different VLANS can communicate only via a router. This router is connected to a port on the switch and receives and sends frames on the same port.
Thus Layer 2 switches evolved to fulfill the requirement of simultaneous bridging and VLANs.
L2 Switching Basics
L2 switches allow MAC based switching. When a packet arrives it reads the MAC address of the destination and sends directly to the port to which this MAC is bound. If not, then it broadcasts the packet and records the port for the destination MAC.
MAC address and the VLAN are the fundamentals of L2 switches. End stations are referenced based on MAC. MAC addresses are unique and hardware fixed. In the absence of VLANs a broadcast is sent to all stations, segmentation of the LAN into logical entities is allowed in VLANs where traffic is localized within the segment. The VLANs are independent of the stations. The VLAN is allocated by the switch. Switching decisions are based on the VLAN number. Thus traffic is isolated between different VLANS.
Basic concepts of Ethernet switching are:
* MAC learning
* Using broadcast and multicast
* Expanding the network with trunks
* VLAN tagging
* Spanning Tree Protocol (STP)
MAC learning enables Ethernet switch to learn the MAC addresses and associate it with a port to direct further traffic directly. A MAC table and VLAN table are maintained at the switch. The MAC table holds relationship between MAC/VLANS with give ports, and the VLAN table holds the list of ports for a VLAN.
When destination MAC address does not exist in the MAC learning table, the packet is sent over to all ports that belong to the same VLAN of the source. It increases delivery speed of packets to their destinations even before MAC learning is completed. Flooding consumes switch and network resources in the initial stages of MAC learning. With VLANs effect of flooding minimizes because the number of ports to broadcast is subset of all the ports in the switch.
Using Broadcast and Multicast
For clients to discover available resources a broadcast is sent by the server. A broadcast message to MAC addresses FFFF FFFF FFFF it means to all stations. Stations interested in this broadcast process this message others ignore. Multicast is a subset of broadcast where the date is sent only to a selected group of stations. Within a VLAN these addresses of broadcast and multicast are treated as unknown addresses and sent across the VLAN.
Expanding the Network with Trunks
A L2 Ethernet-switched network contains multiple interconnected switches over trunk ports. The trunk ports arelike access ports connecting end stations with an added task of carrying traffic coming in from many VLANs in the network. The basic mechanism that Ethernet VLANs perform are suitable for small enterprises where surfing the internet or allocation of minor groups for VLAN is possible but the complexity is when the network grows larger.
The VLAN ID is switch assigned. The switch allots VLAN number to the port and packets on that port to the same VLAN ID. The Ethernet switches switch packets between the same VLANs. Traffic between different VLANs is sent to a routing function within the switch itself or an external router. The 802.1Q tag header gets inserted between the source MAC address and the Type field. It consists of a 2-byte Type field and a 2-byte Tag Control Info field.
The Need for the Spanning Tree Protocol
L2 Ethernet-switched networks work on the basis of MAC address learning and flooding. If multiple paths exist to the same destination, and the packet has an unknown destination, packet flooding might cause the packet to be sent back to the original switch that put it on the network, causing a broadcast storm. STP prevents loops in the network by blocking redundant paths and ensuring that only one active path exists between every two switches in the network. STP uses bridge protocol data units (BPDUs), which are control packets that travel in the network and identify which path, and hence ports, need to be blocked.
L2 Soft Switch
The next level of switching is soft switching. Soft switches are super set of the typical L2 switch that transfers data packets on the network. Soft Switch apart from network transfer acts as a media gateway where further processing is done. SoftSwitch plays a major role in telecommunication networks. A softswitch acts as a central device in a network connecting calls from one phone line to another line, completely by means of software running on a computer system. This work formerly carried out by hardware of physical switchboards to route the phone calls.
A softswitch is mostly used to manage connections at the junction point between the circuit and packet networks. It is a single device rather a computer that is programmed with the switching logic. The switching fabric is used for this purpose; however, with increasing technology and needs of telecom companies, this led to a preference for decomposing this computer device into a simpler Call Agent and a Media Gateway with little customization. However, a SoftSwitch that is implemented in full as a computer is at the flexibility of growth in size and capacity.
Use of L2 SoftSwitch
L2 softswitch are present in networks where the switch role is beyond just data switching. Telecommunication has one major benefit of this softswitch. When telecom companies initially moved out of Hardware based switchboard switching for phone calls, to computers, every phone line is considered as a station/node. Now, when there is an incoming call, the computer processes this call data based on the destination address (phone number) compares it in the mapping table to gather the MAC and forwards the call to the destination. During this call, the duration of the call is calculated at the switch level and the billing is done.
This is a major achievement of the telecom industry as the fact that a softswitch can do on spot billing and simultaneously handle multiple activities.
L2 Soft Switch Architecture:
The softswitch is very similar to the regular L2 switch architecture from outside. Below is typical softswitch architecture that is connecting two different mobile devices. This looks exactly like the star network a L2 switch proposes. The internal architecture of a softswitch would be like below.
When there is an incoming call which can be from any device that is on the same network or may be from an partner network (call via a router) the call is first received by the call queue. The call is then forwarded to verify the destination from the routing table and the destination ID is identified. On identifying the destination ID, the call is then forwarded to the call manager which processes this call.
The call manager is the customized part of a softswitch. The call manager is an integration of the data processor with corresponding applications like billing, call monitoring etc. Once the call is connected, a process is initiated for this connection. This process is a thread of the call manager. The above is a simple typical architecture of a soft switch. The soft switch can grow in size and can add features like backup, redundancy, load balancing etc which can be little critical when done based on hardware.
Other benefit of a soft switch is that it can be customized based on the user requirement with minimum changes the hardware.
 linux Information project http://www.linfo.org/network.html
 Computer Networks by Tannenbaum