The OSI model is a conceptual framework that standardizes how network communication works, broken into 7 layers. Each layer handles a specific part of the process of sending data between devices:

  1. Physical — Raw bit transmission over physical media (cables, radio waves, voltages)
  2. Data Link — Node-to-node transfer, framing, MAC addresses, error detection (Ethernet, Wi-Fi)
  3. Network — Routing and logical addressing across networks (IP addresses, routers)
  4. Transport — Reliable end-to-end delivery, flow control, segmentation (TCP, UDP)
  5. Session — Manages sessions/connections between applications (establishing, maintaining, terminating)
  6. Presentation — Data translation, encryption, compression (SSL/TLS, JPEG encoding, serialization)
  7. Application — Closest to the user; protocols apps use directly (HTTP, FTP, DNS, SMTP)

Transport Layer:

The Transport layer is primarily responsible for ensuring that data is transferred from one point to another reliably and without errors. For example, the Transport layer makes sure data are sent and received in the correct sequence.

The Transport layer provides flow control and error handling, and participates in solving problems concerned with the transmission and reception of packets. Common examples of Transport layer protocols are Transmission Control Protocol (TCP), User Datagram Protocol (UDP) and Sequenced Packet Exchange (SPX).

In order to write a TCP/IP protocol we need to do Socket Programming.