Bird
Raised Fist0
Interview Prepcomputer-networksmediumAmazonGoogleMicrosoftFlipkart

IP Addressing - IPv4, Subnet Mask, CIDR, Subnetting

Choose your preparation mode3 modes available
▶
Steps
setup

Initialize IP Address and Subnet Mask

The algorithm starts by defining the IPv4 address 192.168.1.130 and the subnet mask 255.255.255.192 (equivalent to /26). These values are prepared for processing.

💡 Initialization sets the stage for subnetting by establishing the IP and mask to analyze.
Line:ip_address = '192.168.1.130' subnet_mask = '255.255.255.192'
💡 Understanding the input values is crucial before any bitwise operations.
📊
IP Addressing - IPv4, Subnet Mask, CIDR, Subnetting - Watch the Algorithm Execute, Step by Step
Watching this step-by-step packet flow visualization helps you understand how IP addresses and subnet masks interact at a low level, making abstract concepts concrete and easier to grasp.
Step 1/10
·Active fill★Answer cell
IP address and subnet mask initialized.
Hop: 0
Host (192.168.1.130)
Router
Switch
DNS Server
src→—:—
dst→—:—
data→IP=192.168.1.130, Mask=255.255.255.192
IP address converted to binary for bitwise operations.
Hop: 1
Host (IP binary)
Router
Switch
DNS Server
📦Packet
↗ fromclient
↘ torouter
📄 payload11000000101010000000000110000010
🔌 protocolbinary
🚩 flags
src→—:—
dst→—:—
data→IP binary: 11000000101010000000000110000010
IP binary conversion: 192.168.1.130 → 11000000101010000000000110000010
Subnet mask converted to binary for bitwise AND.
Hop: 2
Host
Router (Mask binary)
Switch
DNS Server
📦Packet
↗ fromrouter
↘ toswitch
📄 payload11111111111111111111111111000000
🔌 protocolbinary
🚩 flags
src→—:—
dst→—:—
data→Mask binary: 11111111111111111111111111000000
Subnet mask binary conversion: 255.255.255.192 → 11111111111111111111111111000000
Network address computed by bitwise AND.
Hop: 3
Host
Router
Switch (Network Address)
DNS Server
📦Packet
↗ fromrouter
↘ toswitch
📄 payload11000000101010000000000110000000
🔌 protocolbinary
🚩 flags
src→—:—
dst→—:—
data→Network binary: 11000000101010000000000110000000
Network address calculation by AND: IP & Mask → 11000000101010000000000110000000
Network address converted to dotted decimal.
Hop: 4
Host
Router
Switch (Network Address: 192.168.1.128)
DNS Server
src→—:—
dst→—:—
data→Network address: 192.168.1.128
Network address converted to dotted decimal: 192.168.1.128
Broadcast address computed by setting host bits to 1.
Hop: 5
Host
Router
Switch
DNS Server (Broadcast Address)
📦Packet
↗ fromswitch
↘ todns
📄 payload11000000101010000000000110111111
🔌 protocolbinary
🚩 flags
src→—:—
dst→—:—
data→Broadcast binary: 11000000101010000000000110111111
Broadcast address calculation: Network OR inverted mask → 11000000101010000000000110111111
Broadcast address converted to dotted decimal.
Hop: 6
Host
Router
Switch
DNS Server (Broadcast: 192.168.1.191)
src→—:—
dst→—:—
data→Broadcast address: 192.168.1.191
Broadcast address converted to dotted decimal: 192.168.1.191
Calculated usable hosts in subnet.
Hop: 7
Host
Router
Switch
DNS Server
src→—:—
dst→—:—
data→Usable hosts: 62
Usable hosts calculation: 2^(32-26) - 2 = 62
Subnet information summarized for output.
Hop: 8
Host
Router
Switch
DNS Server
src→—:—
dst→—:—
data→Summary: Network=192.168.1.128, Broadcast=192.168.1.191, Hosts=62
Subnet summary: Network=192.168.1.128, Broadcast=192.168.1.191, Usable hosts=62
Subnetting process complete; results output.
Hop: 9
Host
Router
Switch
DNS Server
src→—:—
dst→—:—
data→Output: Network=192.168.1.128, Broadcast=192.168.1.191, Hosts=62
Final output: Network=192.168.1.128, Broadcast=192.168.1.191, Usable hosts=62

Key Takeaways

✓ Subnetting is fundamentally a bitwise operation between the IP address and subnet mask.

This insight is difficult to grasp from code alone because the binary manipulation is abstract; seeing the bits flow clarifies the process.

✓ The network address is the base address of the subnet, and the broadcast address is the highest address, both derived from the mask.

Visualizing these addresses as packets moving through nodes helps understand their derivation and significance.

✓ The number of usable hosts depends on the number of host bits, which is the inverse of the mask's prefix length.

This relationship is often overlooked but is critical for network design; the visualization makes it explicit.

Practice

(1/5)
1. A client sends a request to a web server and receives a 3xx status code in response. Which scenario best explains why the server returned this status code?
easy
A. The requested resource has been permanently moved to a new URL, and the client should update its bookmarks.
B. The server successfully processed the request and returned the requested data.
C. The client sent a malformed request that the server could not understand.
D. The server encountered an unexpected error and could not fulfill the request.

Solution

  1. Step 1: Identify the meaning of 3xx status codes

    3xx status codes indicate redirection, meaning the client must take additional action to complete the request.
  2. Step 2: Analyze each option

    The requested resource has been permanently moved to a new URL, and the client should update its bookmarks. describes a permanent redirect (301), which is a typical 3xx scenario.
    The server successfully processed the request and returned the requested data. describes a successful 2xx response.
    The client sent a malformed request that the server could not understand. describes a client error (4xx).
    The server encountered an unexpected error and could not fulfill the request. describes a server error (5xx).
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    3xx codes always involve redirection, so The requested resource has been permanently moved to a new URL, and the client should update its bookmarks. is correct.
Hint: 3xx = redirection, telling client to look elsewhere
Common Mistakes:
  • Confusing 3xx with 2xx success codes
  • Thinking 3xx means client or server error
  • Assuming 3xx means temporary server failure
2. Which of the following statements about DNS caching is INCORRECT?
medium
A. DNS caching at the recursive resolver reduces the number of queries sent to authoritative servers.
B. Local DNS resolvers cache negative responses (e.g., non-existent domains) to improve efficiency.
C. Caching at the browser level can completely eliminate the need for DNS queries for repeated domain lookups.
D. DNS cache entries respect TTL values, after which cached data must be refreshed.

Solution

  1. Step 1: Understand caching layers

    DNS caching occurs at multiple levels: browser, OS resolver, recursive resolver.
  2. Step 2: Browser caching limitations

    Browser caches DNS results temporarily but cannot completely eliminate DNS queries because OS or network conditions may require fresh lookups.
  3. Step 3: Why other options are correct

    Recursive resolvers cache to reduce authoritative queries; negative caching is standard; TTL governs cache expiry.
  4. Final Answer:

    Option C -> Option C
  5. Quick Check:

    Browser caching helps but does not fully eliminate DNS queries -> incorrect statement
Hint: Browser DNS cache helps but does not fully replace DNS queries.
Common Mistakes:
  • Assuming browser cache is authoritative and permanent
  • Ignoring negative caching
  • Forgetting TTL governs cache validity
3. Why is the TCP/IP model considered more practical for real-world networking compared to the OSI model?
medium
A. Because TCP/IP strictly separates presentation and session layers for modularity
B. Because OSI model supports only connectionless communication
C. Because TCP/IP combines layers to reduce complexity and improve implementation efficiency
D. Because OSI model lacks a transport layer

Solution

  1. Step 1: Compare design philosophies of TCP/IP and OSI models

    TCP/IP merges some OSI layers (e.g., Application, Presentation, Session combined) to simplify implementation and focus on practical protocols. OSI strictly separates layers but is more theoretical and complex.
  2. Final Answer:

    Option C -> Option C
  3. Quick Check:

    TCP/IP's fewer layers make it more practical and widely adopted [OK]
Hint: TCP/IP merges layers for simplicity; OSI is more theoretical
Common Mistakes:
  • Believing TCP/IP separates presentation and session layers distinctly
  • Thinking OSI supports only connectionless communication
  • Assuming OSI lacks a transport layer
4. Why might using TCP for a real-time multiplayer game cause performance issues compared to UDP?
medium
A. TCP packets are always larger than UDP packets, increasing bandwidth usage
B. TCP does not support packet loss detection, causing inconsistent game state
C. UDP requires establishing a connection first, which delays game startup
D. TCP's retransmission and ordering guarantees introduce latency that can disrupt real-time responsiveness

Solution

  1. Step 1: Identify real-time game requirements

    Low latency and timely updates are critical; some packet loss is tolerable.
  2. Step 2: Analyze TCP behavior

    TCP ensures reliability and ordered delivery by retransmitting lost packets, which adds latency.
  3. Step 3: Analyze UDP behavior

    UDP sends packets without retransmission or ordering, reducing delay.
  4. Step 4: Evaluate options

    TCP's retransmission and ordering guarantees introduce latency that can disrupt real-time responsiveness correctly explains TCP's latency impact. TCP does detect packet loss, so TCP does not support packet loss detection, causing inconsistent game state is incorrect. UDP is connectionless, so UDP requires establishing a connection first, which delays game startup is incorrect. Packet size depends on payload, so TCP packets are always larger than UDP packets, increasing bandwidth usage is incorrect.
  5. Final Answer:

    Option D -> Option D
  6. Quick Check:

    TCP's reliability mechanisms add latency unsuitable for real-time games.
Hint: TCP = reliable but slower; UDP = faster but less reliable.
Common Mistakes:
  • Believing TCP does not detect packet loss
  • Thinking UDP requires connection setup
  • Assuming TCP packets are always larger
5. If a company wants to improve both security and performance for a public-facing web application, which combined deployment of firewall, proxy, and reverse proxy is most effective?
hard
A. Deploy a proxy server between backend servers and clients without a firewall
B. Use only a reverse proxy to handle all security filtering and caching
C. Rely solely on a firewall to filter traffic and improve performance
D. Deploy a firewall at the network edge, a forward proxy for client requests, and a reverse proxy in front of backend servers

Solution

  1. Step 1: Firewall role

    Firewall at network edge filters unauthorized traffic, providing security.
  2. Step 2: Forward proxy role

    Forward proxy manages client requests, can enforce policies and cache content.
  3. Step 3: Reverse proxy role

    Reverse proxy protects backend servers, performs load balancing, SSL termination, and caching.
  4. Step 4: Evaluate other options

    Only reverse proxy (B) or only firewall (C) miss layered defense and performance optimization; no firewall (A) reduces security.
  5. Final Answer:

    Option D -> Option D
  6. Quick Check:

    Combined deployment leverages strengths of all components [OK]
Hint: Layered defense: firewall + proxies for security and performance.
Common Mistakes:
  • Assuming one component can handle all roles
  • Ignoring the need for firewall in security
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard