Core Networking Protocols: TCP/IP, IPv4/IPv6, and DNS Resolution

TCP/IP Reference Model Features

The TCP/IP reference model (Transmission Control Protocol / Internet Protocol) is the conceptual framework used for network communication over the internet. It describes how data should be packaged, addressed, transmitted, routed, and received.

Key Features of the TCP/IP Model

  • 1. Based on Standard Protocols: Uses open, standard protocols such as TCP and IP, which are vendor-independent and interoperable across devices and operating systems.
  • 2. End-to-End Communication: Ensures that data sent from one host can be reliably delivered to another host, even across multiple networks.
  • 3. Supports Connection-Oriented and Connectionless Services:
    • TCP: Connection-oriented, reliable communication.
    • UDP: Connectionless, faster but without guaranteed delivery.
  • 4. Flexible and Scalable: Can handle networks of all sizes, from small LANs to the global Internet. Allows easy addition of new protocols and technologies without redesigning the whole system.
  • 5. Addressing and Routing: Uses IP addressing (IPv4/IPv6) to uniquely identify devices. Supports routing so that data can travel across multiple interconnected networks.

TCP/IP vs. OSI Reference Model Comparison

AspectOSI Reference ModelTCP/IP Reference Model
Full FormOpen Systems InterconnectionTransmission Control Protocol / Internet Protocol
Layers7 layers: 1. Physical 2. Data Link 3. Network 4. Transport 5. Session 6. Presentation 7. Application4 layers: 1. Network Access 2. Internet 3. Transport 4. Application
ApproachTheoretical and conceptual model, protocol-independent.Practical model based on standard protocols.
DevelopmentDeveloped by ISO (International Organization for Standardization).Developed by DARPA (U.S. Department of Defense).
Protocol SpecificationDoes not specify protocols; only a guideline for designing network architecture.Specifies standard protocols (TCP, IP, UDP, etc.).
FlexibilityMore rigid, designed as a universal standard.More flexible, designed for real-world communication and scalability.
Example ProtocolsOSI doesn’t define protocols (examples from TCP/IP can be mapped to OSI).HTTP, FTP, SMTP, DNS (Application); TCP, UDP (Transport); IP, ICMP (Internet); Ethernet, Wi-Fi (Network Access).

Common Network Topologies

TopologyDescriptionAdvantagesDisadvantages
BusAll devices share a single cable.Easy to install, low cost.One cable failure affects the whole network.
StarDevices connect to a central hub.Easy to manage, failure of one device doesn’t affect others.Hub failure brings down the network.
RingDevices form a closed loop.Predictable performance.Failure in one device affects all.
MeshEvery device connects to every other.High reliability and redundancy.Expensive and complex.
TreeHierarchical, combines star + bus.Scalable and easy to manage.If the main cable fails, the network fails.
HybridMix of two or more topologies.Flexible and scalable.Complex and costly.

Understanding IPv4 and Packet Format

IPv4 is the fourth version of the Internet Protocol, and it is one of the core protocols used to identify devices on a network and route data between them. It is widely used for assigning IP addresses in most networks.

IPv4 Packet Format

FieldSize (bits)Description
Version4IP version (always 4 for IPv4)
Header Length4Length of header in 32-bit words
Type of Service (ToS)8Priority of the packet (QoS)
Total Length16Entire packet size (header + data)
Identification16Used for fragmenting packets
Flags3Control flags (e.g., don’t fragment)
Fragment Offset13Position of a fragment in the original packet
Time to Live (TTL)8Maximum hops before packet is discarded
Protocol8Protocol used in the data portion (e.g., TCP = 6)
Header Checksum16Error checking of the header
Source IP Address32Sender’s IP address
Destination IP Address32Receiver’s IP address
Options (Optional)VariableExtra features like security or routing
DataVariableActual payload (e.g., message or file data)

IPv4 Address Format

  • Consists of 4 octets (8 bits each), separated by dots.
  • Example: 192.168.0.1
  • Each number ranges from 0 to 255 (since 8 bits = 0 to 255).

IPv6 Protocol and Address Format

IPv6 is the successor to IPv4, designed to solve the problem of limited IP addresses. It offers a much larger address space and improved features for modern networks.

IPv6 Address Format

  • Total length: 128 bits.
  • Divided into 8 groups of 16 bits (each group = 4 hexadecimal digits).
  • Leading zeros can be omitted, and long sequences of zeros can be shortened using :: once.

Example:
Full form: 2001:0db8:0000:0000:0000:0000:1428:57ab
Compressed: 2001:db8::1428:57ab

IPv6 Header Structure

FieldSize (bits)Description
Version4IP version (always 6)
Traffic Class8Packet priority information
Flow Label20Identifies packet flows
Payload Length16Size of the data after the header
Next Header8Type of the next protocol (e.g., TCP, UDP)
Hop Limit8Like TTL in IPv4
Source Address128Sender’s IPv6 address
Destination Address128Receiver’s IPv6 address

RIP vs. OSPF Routing Protocols

FeatureRIP (Routing Information Protocol)OSPF (Open Shortest Path First)
Routing TypeDistance VectorLink State
MetricHop CountCost (bandwidth-based)
Max Hop Count15No fixed limit
UpdatesEvery 30 secondsOn change (event-driven)
SpeedSlowerFaster
Best forSmall/simple networksLarge/complex networks

TCP vs. UDP Comparison

AspectTCP (Transmission Control Protocol)UDP (User Datagram Protocol)
Connection TypeConnection-oriented (establishes a connection before data transfer)Connectionless (no setup before sending data)
ReliabilityReliable – ensures data is delivered correctly and in orderUnreliable – no guarantee of delivery or order
Error CheckingYes, with acknowledgment and retransmissionYes, but no retransmission or acknowledgment
SpeedSlower due to overhead from reliability featuresFaster, with minimal overhead
Data TransferStream-based (continuous flow)Message-based (sends discrete packets)
Use CasesWeb browsing (HTTP/HTTPS), Email (SMTP), File transfer (FTP)Streaming (video/audio), Online games, VoIP, DNS
Header SizeLarger (20 bytes or more)Smaller (8 bytes)
Flow Control & Congestion ControlYesNo

UDP Header Format and Structure

UDP is a simple, connectionless transport layer protocol used for fast, lightweight data transmission. It adds only minimal overhead by using a small 8-byte header.

UDP Header Structure (8 bytes total)

FieldSize (bits)Description
Source Port16Port number of the sender
Destination Port16Port number of the receiver
Length16Total length of the UDP header and data
Checksum16Error-checking for header and data

Explanation of UDP Fields

  1. Source Port: Identifies the port of the sending application. Optional in some cases.
  2. Destination Port: Specifies the port of the receiving application.
  3. Length: The length in bytes of the entire UDP packet (header + data). Minimum is 8 bytes.
  4. Checksum: Ensures data integrity. If an error is found, the packet is discarded.

Types of Network Switching

Switching is the process of forwarding data packets between devices in a network. It determines how data travels from the source to the destination.

Switching Methods

  1. Circuit Switching: Establishes a dedicated path for the entire communication. Reliable but wastes bandwidth. Example: Traditional telephone calls.
  2. Packet Switching: Data is broken into packets that travel independently. Efficient and flexible but can have delays. Example: The Internet.
  3. Message Switching: The entire message is sent to each node, stored, then forwarded. No dedicated path, but slower due to storage delays. Example: Email systems (older method).

Circuit Switching vs. Packet Switching

AspectCircuit SwitchingPacket Switching
ConnectionDedicated path established for the entire sessionNo dedicated path; data sent in packets independently
Data TransferContinuous, real-time communicationData broken into packets, sent separately
EfficiencyInefficient; bandwidth reserved even if idleEfficient; bandwidth shared among users
DelayLow delay once the circuit is set upVariable delay due to routing and congestion
ExampleTraditional telephone networksInternet, LANs
ReliabilityHigh reliability during connectionPossible packet loss or delay

Datagram vs. Virtual Circuit Switching

AspectDatagram SwitchingVirtual Circuit Switching
Path SetupNo prior path setup; each packet routed independentlyPath is established before data transfer begins
Packet RoutingEach packet may take a different routeAll packets follow the same pre-established path
Packet NumberingPackets may arrive out of orderPackets arrive in order
Connection TypeConnectionlessConnection-oriented
ReliabilityLess reliable; possible out-of-order or lost packetsMore reliable due to fixed path and order
ExampleInternet Protocol (IP)Frame Relay, ATM networks

TCP Header Format and Key Fields

TCP is a connection-oriented, reliable transport layer protocol. Its header is larger than UDP’s because it includes mechanisms for error checking, flow control, sequencing, and acknowledgment.

TCP Header Structure

FieldSize (bits)Description
Source Port16Sender’s port number
Destination Port16Receiver’s port number
Sequence Number32Number of the first byte in the segment
Acknowledgment Number32Next expected byte from sender
Data Offset4Header length in 32-bit words
Reserved3Reserved for future use
Flags9Control bits (URG, ACK, PSH, RST, SYN, FIN)
Window Size16Amount of data receiver can accept (Flow Control)
Checksum16Error checking of the header and data
Urgent Pointer16Indicates urgent data if URG flag is set
Options + PaddingVariableOptional features (e.g., MSS, timestamps)

Explanation of Key TCP Fields

  1. Sequence Number: Ensures data is received in order.
  2. Acknowledgment Number: Confirms receipt of data.
  3. Flags: Control connection state (e.g., SYN for start, FIN for end).
  4. Window Size: Used for flow control, indicating buffer space available.
  5. Checksum: Ensures data integrity.
  6. Urgent Pointer: Points to urgent data (rarely used).

Steps of the RSA Algorithm

The RSA algorithm is a public-key cryptosystem widely used for secure data transmission.

  1. Choose two large prime numbers: p and q.
  2. Compute the modulus: n = p × q.
  3. Compute Euler’s totient function: φ(n) = (p − 1)(q − 1).
  4. Choose an integer e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1 (usually e = 65537 for efficiency).
  5. Compute the private key exponent d such that d × e ≡ 1 (mod φ(n)).
  6. Public key: (e, n)
  7. Private key: (d, n)

DNS: Working Process and Resolution

The Domain Name System (DNS) is like the phonebook of the internet. It translates human-readable domain names (e.g., www.example.com) into IP addresses (e.g., 93.184.216.34) that computers use to locate each other on a network.

DNS Working Process (Step-by-Step)

  1. Step 1 – Browser Cache: The browser first checks if it already knows the IP address from its cache.
  2. Step 2 – OS Cache: If not found, the operating system checks its own DNS cache.
  3. Step 3 – Recursive Resolver Query: Your computer sends the request to a recursive DNS resolver (usually provided by your ISP or a public DNS like Google 8.8.8.8).
  4. Step 4 – Root Server Query: If the resolver doesn’t know the IP, it asks a root DNS server for the location of the Top-Level Domain (TLD) server (e.g., .com).
  5. Step 5 – TLD Server Query: The root server responds with the IP address of the appropriate TLD server.
  6. Step 6 – Authoritative Name Server Query: The resolver asks the authoritative name server for www.example.com. The authoritative server returns the actual IP address.
  7. Step 7 – Response to Client: The resolver sends the IP address back to your computer. Your browser then connects to that IP and loads the website.