Saturday, 13 August 2016

Basics of Networking



  

         Today almost all devices are connected to the internet. I am just trying to explain the basics of networking. You can see that your PC is connected through a long cable to a box and you can connect your other devices like your TV, Mobile etc. through wire or wireless to the same box and can share resources.
   So in order to make a network you need end devices like PC or mobile through a medium like cable or radio signals to a central device like hub or switch and from there to our Internet Service Provider’s network to get the internet connectivity. In reality these end devices are sending chunks of binary data through the medium to the central device. We can call these chunks of data as frames or packets which we will learn later. These frames are generated or destroyed in the network interface card (NIC) itself. A frame can be a maximum of 1500bytes.Whatever the applications we are using like word or browser send the data to the NIC and the NIC converts the data to the frame and send it out. The NIC do the reverse while receiving data and send it the appropriate application.
NIC

Switch
UTP Cable

                    As we said earlier the frame is travelling through a medium to the central device like Hub. A hub is a networking device which repeats whatever it receives in one port to all the ports. So the frame send by one device will be forwarded to all the other devices connected to the hub and only the destined NIC will receive the frame and others will discarded it. So in order to identify the sender or receiver there should be some address and we can call this as Media Access Control (MAC) address or Physical Address. Each NIC is having a unique 48 bit MAC address. In a windows based computer, if you open command prompt and type ipconfig /all or getmac command, you will be able to see the MAC address in hex decimal format. As each hex represents 4 bits, you can see 12 hex. The first 6 hex represents the manufacturer of NIC, which is in my case VMware.



                            Each Device knows its MAC address and that information is added to the packet along with the destination device’s MAC address and a cyclic redundancy checker at the end to make sure the data is good. The receiving computer checks the frame and if it is for its MAC, will accept else will discard it.





Unicast vs broadcast

   As we discussed, the frame is having the source and destination MAC addresses. There will be situations like we don’t know the destination MAC address and we send the frame to all connected devices. This process is called as broadcasting and the frame uses ff-ff-ff-ff-ff-ff as the destination MAC to indicate it as a broadcast and all connected device will accept it. If the destination MAC is mentioned, then it will become a point to point communication and is called as Uni cast.


Hubs vs Switches

                   Now let’s discuss about the central device. As we said earlier a hub is simply a repeater that makes multiple copies of frame and forward it to all ports. A switch is a smart device having some intelligence. It learns the MAC address of each devices connected to it and the corresponding ports. So the switch will forward the frame only to the destined computer and making the communication between other computers also possible at the same time. Hubs are obsolete and we will use the term switch for the central device.



IP Addressing



As the network grows, it is difficult to manage the network using MAC addresses. Also we cannot separate network based on MAC address. So we are using logical address called IP Address. Unlike MAC addresses IP addresses are not bounded to the network card. So why we need MAC? I will explain how MAC and IP addresses used together in a network communication. So we are introducing a new device called router in to the picture.  Most of us are familiar with our broadband router in to which our home devices are connected and also connected to the service provider. An IP address will be like 192.168.10.10. Each machine appends its IP address and the destination IP address along with the data and that piece is called as a packet. The NIC adds the source, destination MAC and CRC and after that the packet will become a frame. In a network to reach a different network from a device, we are configuring the default gateway (Usually the address of the Router). The computer uses the router’s MAC address as the destination MAC address for any destination IP address that belongs to different network. The router is having a table called the routing table, which helps to find the path to different network. So the router strips the MAC part of the frame and replaces it routers Mac as the source and the MAC address of next hop as the destination MAC. The IP will remain as it is until it reached the destined IP device.
  
 
Packets and Ports
  As we discussed earlier the frame or packet is only a piece of information belongs to a particular application. May be we downloading a document, Watching video on YouTube or making a call on skype. There are thousands of frames coming in and how will we identify which frame is for which application? So we are adding two more fields to our IP packet discussed earlier called as port numbers (Source port and destination port). We can use up to 65536 as port number. The first 1024 ports are known as well-known ports and hence it is reserved. We can’t use these numbers as client side port numbers.

        If I am accessing a website it uses port 80 as the destination port and a random non-reserved port as source port. The web server responses back 80 as source port and my random port as destination port. Thus my computer is able identify the frame is for which application.

      Another issue is we are getting the data as pieces of packets for different applications. So we need to combine these packets in correct order for appropriate application. A protocol called Transmission Control Protocol (TCP) taking care of all these requirements. It uses sequence numbers with each packet and rearrange the data as per that for different applications. TCP waits for the acknowledgment from the receiving computer and hence known as connection oriented reliable protocol. There is one more transport protocol User Datagram Protocol (UDP), it simply sends the data and not asking any acknowledgment and hence known as connection-less unreliable protocol.


Network Models

                    We use some standards or models to represent the network communication. There are two popular network models, The Open System Interconnection (OSI)-7 layer and the TCP/IP model. There are different types of hardware and software in the network and all these need to be communicate each other. These models defines that communication between devices independent of the hardware or software.



                 OSI 7 Layers

    7:   Application: The application that we used in a network communication should be network aware and this layer deals with the application itself.
    6.   Presentation: The presentation layer converts arranged packets in to the appropriate application format to get the actual content.
    5.   Session: The session layer establishes the end to end session between two computers.
    4.   Transport: The transport layer re arranges the chunks of data in the correct sequence. The protocol TCP and UDP works at this layer.
    3.   Network: We adds or removes the IP information at this layer. After this addition the data chunks become known as Packets. Devices like routers works at this layer.
    2.   Datalink: We adds or removes the MAC address and CRC at this layer and after this the packets become known as frames. Devices like NIC, Switches etc. works at this layer.
    1.   Physical: This layer deals with actual transmission of data through the physical medium like UTP cables.

TCP/IP Model

         4.   Application: This layer deals with the application. Protocols like DNS, FTP   etc. operates at this layer.
3. Transport: Operates similar to the transport layer in OSI, deals with the assembly and dis-assembly.
     2. Internet: Deals with IP and devices like routers comes under this.
         1.   Network Interface: Deals with the physical connectivity, MAC addresses, switches etc.

 

No comments:

Post a Comment