=

OSI vs TCP/IP model

OSI (Open Systems Interconnection) and TCP/IP both are networking models that describes how a data is sent over a network. It makes data transmission easy and reliable.

Before TCP/IP model there are no such reliable standerd for communication. Different networks uses different ways for communication. (ex. NCP, X.25)

Table of Contents

    TCP/IP Model

    History

    • The Defense Advanced Research Projects Agency (DARPA) started the project in late 1960s.
    • Vine Cerf and Kahn, scientists at DARPA, designed the TCP/IP model in 1970s
    • It was relesed in 1975 with the name of ARPANET (Advanced Research Projects Agency Network)
    • ARPANET was renamed as TCP/IP in 1983 and become a open standerd.
    • Now TCP/IP is managed by IETF (Internet Engineering Task Force)

    What TCP/IP solves

    • Interoperability : Makes a Standard for networking in all devices and networks.
    • Global Addressing (IP) : Allowed unique identification of every device.
    • Routing Mechanisms : Packets can find best path dynamically.
    • Scability : Can handle millions of devices.
    • Reliable (TCP) : It ensures retransmissions, error handling, acknowledgements.

    Architecture / Layers

    TCP/IP is made of 4 layers. Each layer should communicate with its neighbouring layer.

    1. Application layer
    2. Transport layer
    3. Internet layer
    4. Network access layer

    Application layer

    Application layer is the top most layer of TCP/IP model. It handles end user interactions, data formatting and encodings, session managements etc.

    Example : A user enter some information in a login form. Then the data is formatted into a structured formate. And sent to the transport layer for further transmission. And same happens on other end, transport layer sends a structured data to application layer and application layer shows it to the user if necessary.

    Some protocols that are used in application layer are : HTTP, HTTPS, SMTP, SNMP

    { "username": "cyberstudent", "password": "secure123" } DATA Examle - A raw json data at application layer

    Transport layer

    • Data received from application layer are divided into smaller chuncks. For TCP these smaller chunks are called Segments and Datagrams for UDP. In this layer a transport layer header is add to each chunks. Some header like : source port, destination port, sequence number, acknowledgment number, checksum
    • There are two main protocols TCP (Transmission Control Protocol) and UDP (User datagram protocol) in transport layer, that doesn't mean transport layer have only these two. Some other protocols are : QUIC, ESP etc.
    • After adding the ip headers the chunks are called packets.
    Header (segment/datagram/other) data
    (Generally if a port number is used by one service then it cann't be used by another service or application. It is possible but with many limitations.) Some example foramt of headers :
    At - Transport layer TCP segment UDP Datagram if if Source Port (16 bite) Destination Port (16 bits) Sequence Number (32 bits) Acknowledgment Number (32 bits) Data Offset 4 bits Reserved (6 bits) Window (16 bits) Flags (6 bits) Checksum (16 bits) Urgent Pointer (16 bits) Options Padding Data Source Port (16 bits) Destination Port (16 bits) Length (16 bits) Checksum (16 bits) Data

    For TCP → RFC793, for UDP → RFC768

    Internet layer

    The Internet Layer in the TCP/IP model is responsible for addressing, routing, and packet forwarding to ensure data reaches the correct destination across networks.

    • It receives data from transport layer and add IP headers (source & destination IP addresses, TTL etc.), determines the best path then send it to network access layer. At the destination device it Decapsulate / exract IP headers and transfer the remaining to transport layer.
    • Data at this layer are called IP Packets.
    • Some protocols at this layer : IP, ICMP, ARP, RARP
    Header (segment/datagram/other) data (transport layer) (internet layer) Header (ipv4/ipv6)
    Some foramt of headers :
    At - Internet layer IPV4 header IPV6 header if if Version (4 bits) Total Length (16 bits) Identification (16 bits) Time to Live (8 bits) Source Address (32 bits) Destination Address (32 bits) Options Padding IHL (4 bits) Type of Service (8 bits) Flag (3 bits) Fragment Offset (13 bits) Protocol (8 bits) Header Checksum (16 bits) Version (4 bits) Traffic Class (8 bits) Flow Label (20 bits) Payload Length (16 bits) Next Header (8 bits) Hop Limit (8 bits) Source Address (128 bits) Destination Address (128 bits)

    For ipv4 → RFC791, for ipv6 → RFC8200

    Network access layer

    Network access layer is also known as link layer is responsible for transmitting the data physically with the help hardwares.

    • The packets received from internet layer are wrapped inside a header and trailer.
    • After wrapping the data is called frame.
    • Trailer area used for error detections.
    • Frames are converted into bits (0,1) and transfered to the destination through a physical medium.