Computers and their networks

September 3, 2023

(1y ago)

Hello There🐼

Let's talk Computer Networks.


Components-of-CN

Hub

  • It is a device that splits the network connection into multiple devices that are connceted to it.
  • Or simply put together, Hub tranfers the request or response to all the devices that are conncted to it.
  • It is Dumb.

Switch

  • It is a device that splits the network connection into specific device specified by the sender or reciever.
  • Or simply put together, Switch tranfers the request or response to the device to which it is intended to.
  • It does so by keeping track of MAC addressess of all the devices that are connected to the switch theough it's ports.
  • Switch has something called CAM (Content Addressable Memory) table. Which stores the MAC addressess of the devices connected to it's ports.
  • It is Smart.

Routers

  • It is a device that connects the LAN to outside world or so called The Internet.
  • It is usually used to connect different networks.
  • Part of Network layer.
  • It is very expensive to maintain one.


Computer Architecture

CN-architecture

Peer-to-PeerClient / Server
Equal opportunity to everyone in the networkThose who are in need only given option to talk with whom they want to talk.
Peer-to-PeerClient-Server
If the desired computer is busy in talking to other computer we can not talk to it at that time.High speed data sharing can take place.


Various Network Types

Network-Types

PAN

  • Personal Area Network.
  • Belongs to a person.
  • Revolves around a person's personal devices like mobile phone, watch and etc..

LAN

  • Local Area Network.
  • Involves a bunch of computers/devices connected with each other through cables.
  • Limits to an office or a room or a building.
  • Faster data tranfer takes place.
  • Secure as there is no intervention of external entity.

MAN

  • Metropolitan Area Network.
  • Group of LAN's together is called MAN.
  • They can be used to connect different branches of a bank in a city together.

WAN

  • Wide Area Network.
  • Spread over large geographical area like states and countries.
  • For example Internet is a WAN.



TCP/IP-model

TCP/IP Model



Physical Layer

  • Pyhysical Layer also known as Layer-1.
  • At the bottom of the TCP/IP layer.
  • Responsible for transporting and accepting data from and to the internet.
  • It does it so through Cables and radiowaves and stuff.
  • Many concepts like What type of signal transportation method is efficient to transfer the data through a channel is discussed here.
  • Concepts like Digital data encoding and decoding takes place here.
  • Some encoding and decoding techniques like Bipolar, Polar, NRZ, NRZ-I etc..
  • Multiplexing is a concept of combining various signals into one and sending it through one/multiple channel to achieve efficiency and better performance.
  • 3 techniques in Multiplexing Frequency-division, Wavelength-division and Time-division multiplexing.
  • Concepts like frame, frame length and time slots occur in Time-division multiplexing.
  • Switching is a concept where the computer signal is sent from one computer netowrk to another computer network.
  • Switch uses MAC address to forward packets through various network.

  • Data-Link Layer also known as Layer-2.

  • Responsible for moving the data frames from one node to another node in the network from source to destination.

  • You can also call it Hop-to-Hop delivery of the data.

  • Data link layer has sublayers

    data-link-layer-sublayers

  • LLC(Logical Link control) or DLC(Data Link Control) is responsible for Flow control

  • MAC sublayer is responsible for:

    • Data Encapsulation:
      • Frame Assemmbly and disassembly is done here.
      • Frames are created here.
      • Header and trailer are added here.
    • Media Access Control:
      • Placing and removing of the frames from the media line.
  • Service provided by Data link layer:


Framing

  • Frame = Header + Network Layer PDU(Data) + Trailer

  • Making each data frame that need to be transported unique or distinguishable from each other so that reciever can know what the data is.

  • Each frame of data is made unique by adding a header and trailer to the data that need to be sent over the channel.

  • The bits which are added at the begining and at the end of the frame is agreed by both sender and reciever.

  • We add bunch of bits at the begining and end of the data to mark one data frame. Below figure explains the Framing.

  • Notice how in the below figure we have the same header and trailer bit in the data part of the frame. It is called Framing error. Framing

  • Framing Error solution:

  • Bit stuffing is used to overcome framing error problem

  • Let's say that 1001 is the agreed code to be added in header and trailer of the frame.

  • If we encounter 1001 we need to replace it with something else. Like say we replace it with 1011 and let the reciever know that it needs to be converted back to 1001.

  • We might come across 1011 in the data. In this case the reciever will convert it into 1001 but it is not the correct data. To overcome this kind of problem we need to come up with a very strong and reliable bit stuffing code.


Physical addressing

  • This layer is responsible for appending header and trailer to the data frame.
  • The header contains the MAC addresss of each node in between source and destination.

Flow control

  • There need to be a flow control mechanism between sender and reciever so that they both are in sync.
  • It is basically the amount of data a sender can send before recieving an acknowledgement from the recever.
  • Various Flow control protocols:
    • Simple protocol: Simply just send all the frames that need to be transmitted.
    • Stop-and-wait: After sending a frame wait for the acknowledgement of that frame from the reciever so that you can send next frame in the row.
    • Stop-and-wait-ARQ: It is same as Stop-and-wait, The difference is that here we have a timer. After the timer burns out the unacknowledged frame is sent again.
    • Sliding-window: We have a fixed window size of some length say n.
      • We send first n frmaes and wait for their acknowledgement in the order we sent the frames.
      • If we get the acknowledgement for the first frame we slide the window and send the next frame.
      • If the timer burns out or we get acknowledgement for wrong frame we send back the first frame assuming that there was a problem with the frame transmission.
    • Go-back--ARQ: It is same as Sliding-window as we have a sliding-window here too. The only difference is whenever we get the wrong frame acknowledgement or no acknowledgement we send back all the frames available on our window size.

Error control

  • Whenever there is an error in the data frames there are two ways to deal with this problem
    1. Error detection
    2. Error Correction
  • Types of error:
    1. Bit error: There is one bit difference between original data and the recieved data.
    2. Burst error: Multiple bits difference between original data and the recieved data.
  • Error detection can be implemented in data link layer or Transport-layer
  • When the recever gets the data it needs to validate that it is correct. It does so with help of redundancy bits added with the data.
  • Redundancy bits are just extra bits added to data from sender to validate the correctness of the data by reciever.
  • Some methods of generating Redundancy bits:
    • Checksum:
      • You divide the data that need to be sent into k parts of size n.
      • Then add all n parts with each other and take 1's compliment.
      • This 1's compliment is only redundancy bits which are sent with the data
      • On the reciever's side the recieved data is added together.
      • If the final value of addition results into 1 at all places then the recieved data is valid.
      • Else it is descarded and notified to the sender.
    • Cyclic Redundancy Check(CRC):
      • We have some complicated method to generate the CRC.

Access control

  • When multiple devices are accessing the same channel to send data, we need some mechanism to make sure the data do not collide with each other.
Random Access protocolcontrolled access protocolChannelization
AlohaReservingFDMA
CSMAPollingWDMA
CSMA/CDToken PassingCDMA
CSMA/CA


Network Layer

  • Network Layer also known as Layer-3.
  • It's main role is to deliver packets from source host to destination host.
  • In this layer IP addresses are discussed. This layer uses IP address to deliver the packets.
  • Makes sure the destination recieves data in the same order the sender has sent.
  • It provides the path for the data packets to travel through various networks(Routing).
  • Main functions performed by network layer:
    • Routing
    • Logical addressing
    • Inter networking
    • Fragmentation

IP address

  • It is a logical address which is used to identify the device's connection to the internet.
  • There are two types of IP addresses
    1. IPV4- 32 bits
    2. IPV6- 128 bits

IPV4


Classfull addressing

  • Here the size of the hosts and networks are limited and fixed.
  • We may waste the number of IP addresses present in the given network.
  • For big organizations a monolothic address space is given. Which might not fit the organizations need and underlying architecture.
  • There are 5 types of Classfull addresses here
ClassRangeUsageSubnet MaskNo of n/wNo of Hosts
A0-127General255.0.0.027232-7-2
B128-191General255.255.0.0217232-14-2
C192-223General255.255.255.0221232-21-2
D224-239Broadcast---
E224-255/Research---
  • Subnet mask is used to identify the class of the address.

  • For each class the subnet is unique and can be identified in two ways:

    ClassBinary notationSlash notation
    A00000000/8
    B10000000/16
    C11000000/24
  • The First and last address in each class os reserved and is not for Usage

    • First address for example 127.0.0.0 for class-A is used to identify the netowrk.
    • Last address is used to brodcast data to all the other devices present in the network.
  • localhost /127.0.0.1

    • It is used a special IP address.
    • Used to direct traffic to themselves.
  • IPV4 Transmission types:

    • unicast, multicast and broadcast
    unicastmulticastbroadcast
    Can only talk to one device which is connected to the same network.Can talk to multiple hosts in possible different networks.Will talk to all the devices present in the network.
  • It is impossible to give unique address to each device in the world.

  • Here the concept of private and public IP address comes into picture.

  • Devices which need not connect to the internet can use private IP addresses.

  • But, what if that device want to connect to the internet???

  • This can be achieved via connceting the device to a Proxy server or a router which has NAT setup init.

  • What NAT basically does is, It maps out the private IP address to public IP address of the router and handles the request.

  • Few Private IP addresses:

    Address
    10.0.0.0 - 10.255.255.255 (10.0.0.0/8)
    172.16.0.0 - 172.31.255.255 (172.16.0.0/12)
    192.168.0.0 - 192.168.255.255 (192.168.0.0/16)

Classless addressing

  • Formal name of classless addressing is known as CIDR(classless-Inter-domain-routing).

  • It allowes ISP to allocate IP address with any address bit-boundary(prefix length).

  • It allows us to create our own network with the number of devices needed in the network.

  • Subnetting:

    • Dividing a network into 2 or more networks is Subnetting.
    • Sub network is a logical division of the network.
  • Subnet masks:

    • Possible values for subnet mask TCP/IP-model
    • It is used to divide the network and host part of the IP address.
    • It is a 32-bit number constructed with all 1's at the begining and 0's at the end.
    • /-notaion is used to represent the subnet mask
    • /3 --> 11100000 00000000 00000000 00000000

Problems on Subnetting

There are few steps to be followed to calculate the number of IP addresses in a subnet

  1. Given the IP address figure out how many devices need to be there in a given subnet.
  2. Convert the number of devices into binary format. For example we need to address 32 devices then we convert 32 into Binary format which is 100000.
  3. Count the minimum number of bits required to denote the number of devices in Binary format. Call it n. For the above example it will be 6.
  4. To represent the new subnet mask in /-notation, Just do 32 - n.
  5. Make the new range of IP addresses from the new /-notation.

IPV6

  • 128 bits long.

IPV6


Network Layer Protocols:

Few protocols which network layer provides.

ARP(Address Resolution Protocol)

  • It is a protocol used to get the MAC address of other devices present in the network which is essential for communication between two devices in the same or different network.
  • The sender or host who wants to know the MAC address will send a brodcast message to all the devices in the network.
  • The one to whom the broadcast is intended to responds back with it's MAC address.

ICMP(Internet Control Message Protocol)

  • It is a protocol used to send notifications of IP datagram packets.
  • It's main functionality is to alert the router about the problem but not to fix them.
  • It has the least priority over all other protocols.

IGMP(Internet Group Message Protocol)

  • It is a protocol used to identify the members of a group in LAN.
  • It is essential in multicast addressing.
  • In multicast addressing data needs to be tranmitted to multiple hosts. IGMP is essential to identify the devices in the network.

Transport Layer

  • Responsible for transporting data to the correct process running on the destination's computer.
  • Uses port number to identify the process.

PortNumbers

  • We have Error control, Flow control and Access control defined in this layer.
  • This layer deals with process to process communication that's why we need it here.
  • Socket-address = IP address + Port number
  • Purpose of Socket address is to uniquely identify each process running

Error control and Flow control are defined in both Transport layer and Data Link Layer because:

  1. Transport layer deals with Process to Process communication. There need to be flow and error control while transfering the data.
  2. Data Link layer deals with node-to-node transportation of data hence we need flow and error control.
  • There are two major protocols used in transport layer: TCP and UDP.

TCP

  • Transmission control protocol.
  • TCP is a communication standard over which enables application programs to excahnge data over the internet.
  • This communication standard requires a connection to be made before transmission of any data.
  • Offers byte streaming. i.e; Sender sends the data through the connection.
  • It has a FULL DUPLEX transmission method.
  • We can piggyback the acknowledgement and data.
  • Has Error Control
  • Has Flow Control

Three-way-handshake connection mechanism:

Three-way

UDP

  • User Datagram protocol.
  • UDP does not require a connection to be made before transmission of the data(UDP is a connectionless protocol).
  • UDP is not reliable as it does not offer Error control, Congestion control and Flow control.
  • UDP is Faster than TCP as it does not require a large header.

Applications:

  • Streaming videos(Youtube live stream) as we need speed transmission of the data.
  • Single request and response protocols(RIP).

TCPUDP
Transmission control ProtocolUser datagram protocol
SlowerFaster
ReliableNot Reliable
Offers FLow control, Error control and congestion controlDo not offer FLow control, Error control and congestion control
Connection Oriented ProtocolNot a connection Oriented Protocol


Application Layer

  • Through this layer users can access the internet.

Application Layer Protocols:

DHCP

  • Dynamic host configuration protocol used to assign IP address to devices dynamically.
  • Steps in assigning dynamic IP address
    1. Client(device) sends a broadcast signal to all nearby server DISCOVER message.
    2. Some server will respond to that broadcast message with a OFFER message.
    3. For the OFFER message client responds with REQUEST message.
    4. The server assigns an IP address to the client and sends an ACKNOWLEDGEMENT message.


Good Day 🐼