How is data sent over the network? Why do we need so many layers in the OSI model?The diagram shows how data is encapsulated and de-encapsulated when transmitting over the network.
When Device A sends data to Device B over the network via the HTTP protocol, it is first added an HTTP header at the application layer.
2
Transport Layer
Then a TCP or a UDP header is added to the data. It is encapsulated into TCP segments at the transport layer. The header contains the source port, destination port, and sequence number.
3
Network Layer
The segments are then encapsulated with an IP header at the network layer. The IP header contains the source/destination IP addresses.
4
Data Link Layer
The IP datagram is added a MAC header at the data link layer, with source/destination MAC addresses.
5
Physical Layer
The encapsulated frames are sent to the physical layer and sent over the network in binary bits.
6
De-encapsulation
When Device B receives the bits from the network, it performs the de-encapsulation process, which is a reverse processing of the encapsulation process. The headers are removed layer by layer, and eventually, Device B can read the data.
We need layers in the network model because each layer focuses on its own responsibilities. Each layer can rely on the headers for processing instructions and does not need to know the meaning of the data from the last layer.
HTTP is a protocol for fetching resources such as HTML documents. It is the foundation of any data exchange on the Web and it is a client-server protocol.Key Features:
Request-response model
Stateless protocol
Port 80 (default)
Built on TCP
HTTP/3
HTTP/3 is the next major revision of the HTTP. It runs on QUIC, a new transport protocol designed for mobile-heavy internet usage.Key Features:
Built on UDP instead of TCP
Faster web page responsiveness
Better for VR applications
Reduced latency
HTTPS (HyperText Transfer Protocol Secure)
HTTPS extends HTTP and uses encryption for secure communications.Key Features:
TLS/SSL encryption
Port 443 (default)
Certificate validation
Secure data transmission
WebSocket
WebSocket is a protocol that provides full-duplex communications over TCP.Key Features:
Bidirectional communication
Real-time updates
Persistent connection
Used in gaming, trading, messaging
Unlike REST, which always “pulls” data, WebSocket enables data to be “pushed”.
TCP (Transmission Control Protocol)
TCP is designed to send packets across the internet and ensure the successful delivery of data and messages over networks.Key Features:
Connection-oriented
Reliable delivery
Ordered packets
Error checking
Many application-layer protocols build on top of TCP.
UDP (User Datagram Protocol)
UDP sends packets directly to a target computer, without establishing a connection first.Key Features:
Connectionless
No delivery guarantee
Lower latency
Lightweight
Voice and video traffic are often sent using this protocol.
SMTP (Simple Mail Transfer Protocol)
SMTP is a standard protocol to transfer electronic mail from one user to another.Key Features:
Port 25 (default)
Email transmission
Text-based protocol
Push protocol
FTP (File Transfer Protocol)
FTP is used to transfer computer files between client and server.Key Features:
Address RecordMaps a domain name to an IPv4 address. One of the most essential records for translating human-readable domain names into IP addresses.
AAAA Record
IPv6 Address RecordSimilar to an A record but maps a domain name to an IPv6 address. Used for websites and services that support the IPv6 protocol.
CNAME Record
Canonical Name RecordUsed to alias one domain name to another. Often used for subdomains, pointing them to the main domain while keeping the actual domain name hidden.
MX Record
Mail Exchange RecordDirects email traffic to the correct mail server. Essential for email routing.
NS Record
Name Server RecordSpecifies the authoritative DNS servers for the domain. These records help direct queries to the correct DNS servers for further lookups.
PTR Record
Pointer RecordProvides reverse DNS lookup, mapping an IP address back to a domain name. Commonly used in verifying the authenticity of a server.
SRV Record
Service RecordSpecifies a host and port for specific services such as VoIP. Used in conjunction with A records.
TXT Record
Text RecordAllows administrators to add human-readable text to DNS records. Used to include verification records, like SPF, for email security.
The transition from IPv4 to IPv6 is primarily driven by the need for more internet addresses, alongside the desire to streamline certain aspects of network management.
IPv4
IPv6
Transition
Format and Length
Address Size: 32-bit
Format: Four decimal numbers separated by dots
Example: 192.168.0.12
Total Addresses: ~4.3 billion
Status: Address exhaustion
Header ComplexityThe IPv4 header is more complex and includes fields such as:
Header length
Service type
Total length
Identification, flags, fragment offset
Time to live (TTL)
Protocol
Header checksum
Source and destination IP addresses
Options
Format and Length
Address Size: 128-bit
Format: Eight groups of four hexadecimal digits
Example: 50B3:F200:0211:AB00:0123:4321:6571:B000
Total Addresses: 340 undecillion (practically unlimited)
Status: Future-proof
Header SimplificationIPv6 headers are designed to be simpler and more efficient:
Fixed header size: 40 bytes
Less frequently used fields in optional extension headers
Main fields: version, traffic class, flow label, payload length, next header, hop limit, addresses
Improves packet processing speeds
Translation MechanismsAs the internet transitions from IPv4 to IPv6, mechanisms to allow these protocols to coexist have become essential:Dual Stack
Runs IPv4 and IPv6 simultaneously
Same network devices support both protocols
Seamless communication in both protocols
Depends on destination address availability
Considered the best approach for smooth transition
HTTPS is an extension of HTTP that transmits encrypted data using Transport Layer Security (TLS). If the data is hijacked online, all the hijacker gets is binary code.
The client (browser) and the server establish a TCP connection.
2
TLS Handshake
The client sends a “client hello” to the server. The message contains a set of necessary encryption algorithms (cipher suites) and the latest TLS version it can support. The server responds with a “server hello” so the browser knows whether it can support the algorithms and TLS version.The server then sends the SSL certificate to the client. The certificate contains the public key, hostname, expiry dates, etc. The client validates the certificate.
3
Session Key Exchange
After validating the SSL certificate, the client generates a session key and encrypts it using the public key. The server receives the encrypted session key and decrypts it with the private key.
4
Secure Communication
Now that both the client and the server hold the same session key (symmetric encryption), the encrypted data is transmitted in a secure bi-directional channel.
The asymmetric encryption goes only one way. This means that if the server tries to send the encrypted data back to the client, anyone can decrypt the data using the public key.
Performance
The asymmetric encryption adds quite a lot of mathematical overhead. It is not suitable for data transmissions in long sessions.
Uniform Resource Locator (URL) is used to locate resources on the internet. URLs comprise several components:
Protocol/Scheme
The protocol or scheme, such as http, https, ftp, wsExample: https://
Domain and Port
The domain name and port, separated by a period (.)Example: www.example.com:443
Domain: www.example.com
Port: 443 (optional, defaults based on protocol)
Path
The path to the resource, separated by a slash (/)Example: /products/category/item
Query Parameters
The parameters, which start with a question mark (?) and consist of key-value pairsExample: ?id=123&color=blue&size=largeFormat: key1=value1&key2=value2
Fragment/Anchor
Indicated by a pound sign (#), used to bookmark a specific section of the resourceExample: #section-headerNote: Not sent to the server, processed by browser only