summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-09-27 23:17:19 -0600
committermo khan <mo@mokhan.ca>2025-09-27 23:17:19 -0600
commit7de6a3a590d5f9f4f36c9e5e91ba17a59cdb7d3a (patch)
treef782fdaf5a4e75205ca57fd9268e6c0382744c59
parent179c061f972f2e57753f29e4342f730040ad4fde (diff)
update a2
-rw-r--r--assignments/2/README.md215
1 files changed, 115 insertions, 100 deletions
diff --git a/assignments/2/README.md b/assignments/2/README.md
index f64448a..3843fe1 100644
--- a/assignments/2/README.md
+++ b/assignments/2/README.md
@@ -1,6 +1,6 @@
---
title: "COMP-347: Computer Networks"
-author: "munir khan - 3431709"
+author: "Munir Khan (ID: 3431709)"
date: "September 2025"
subtitle: "Assignment 2"
institute: "Athabasca University"
@@ -13,146 +13,161 @@ linestretch: 1.0
## 1.1 TCP Reliable Data Transfer (5%)
-TCP provides reliable data transfer over IP's unreliable best-effort service through several key mechanisms:
+> (5%) TCP provides a reliable data transfer service on top of IP’s unreliable best‑effort service. Study related sections of the textbook and articles from other sources. In your own words, explain how TCP provides a reliable data transfer service.
-### 1. Sequence Numbers and Acknowledgments
-TCP assigns a sequence number to each byte of data sent. The receiver sends acknowledgments (ACKs) back to the sender to confirm successful receipt of data. The ACK number indicates the next expected sequence number, providing cumulative acknowledgment of all bytes received up to that point.
-
-### 2. Checksums for Error Detection
-Each TCP segment includes a checksum field that covers the header and data. The receiver calculates the checksum and compares it with the received value. If they don't match, the segment is discarded, and no ACK is sent, triggering retransmission.
-
-### 3. Timeout and Retransmission
-TCP maintains a retransmission timer for each unacknowledged segment. If an ACK is not received within the timeout period, TCP assumes the segment was lost and retransmits it. The timeout value is dynamically calculated based on measured round-trip times (RTT).
-
-### 4. Duplicate Detection
-Using sequence numbers, TCP can detect and discard duplicate segments that may arrive due to unnecessary retransmissions. This prevents duplicate data from being delivered to the application.
-
-### 5. Flow Control
-TCP implements a sliding window mechanism using the receive window field in the header. The receiver advertises how much buffer space it has available, preventing the sender from overwhelming the receiver with data.
-
-### 6. In-Order Delivery
-TCP uses sequence numbers to reorder segments that arrive out of order due to different network paths or processing delays, ensuring the application receives data in the correct sequence.
-
-### 7. Connection Management
-TCP establishes connections through a three-way handshake and terminates them gracefully, ensuring both endpoints agree on the connection state and that all data has been successfully delivered before closing.
-
-Summary: TCP transforms IP's unreliable service into a reliable one by adding acknowledgments, retransmission, error detection, flow control, and ordering mechanisms, creating a robust communication channel for applications.
+TCP provides reliable data transfer over IP's best-effort service using:
+- Sequence numbers and cumulative ACKs: Each byte is sequenced; ACK(n) confirms receipt of all bytes up to n−1.
+- Checksums: Header+payload checksum detects corruption; corrupt segments are discarded (no ACK).
+- Timeout and retransmission: RTO based on RTT estimation; missing ACKs trigger retransmission.
+- Fast retransmit/fast recovery: Triple-duplicate ACKs imply loss and trigger immediate retransmission and window adjustment.
+- Flow control: Receiver-advertised window prevents overrunning receiver buffers.
+- Reordering/in-order delivery: Out-of-order segments are buffered and reassembled before delivery to the application.
+- Connection management: Three-way handshake establishes state; graceful close ensures all data delivered.
## 1.2 Go-Back-N Protocol (5%)
-While Reliable Data Transfer (RDT) protocols are essentially stop-and-wait protocols that send one packet and wait for acknowledgment before sending the next, Go-Back-N (GBN) achieves higher throughput by allowing multiple packets to be transmitted without waiting for individual acknowledgments. GBN accomplishes this through several key mechanisms:
+> (5%) While the RDT protocols are essentially stop‑and‑wait protocols, the GBN protocol allows the sender to send multiple packets without waiting for acknowledgement from the receiving parties. How does GBN achieve that?
-### 1. Sliding Window Mechanism
-GBN uses a sliding window of size N that allows the sender to transmit up to N unacknowledged packets. The window "slides" forward as acknowledgments are received, enabling continuous transmission without waiting for each individual ACK.
+GBN achieves higher throughput than stop-and-wait via a sliding window that allows up to N unacknowledged packets in flight. The sender maintains base (oldest unACKed) and nextseqnum, uses a single timer for the oldest unACKed packet, and the receiver sends cumulative ACKs. On timeout, the sender retransmits from base ("goes back N"). This pipelining avoids per-packet waiting.
-### 2. Sequence Number Space
-GBN uses a finite sequence number space (typically modulo 2^k) where packets are numbered sequentially. The sender maintains:
-- base: oldest unacknowledged packet sequence number
-- nextseqnum: next sequence number to be used
-- Window boundary: base ≤ sequence numbers < base + N
+## 1.3 IPv6 Transition (5%)
-### 3. Cumulative Acknowledgments
-The receiver sends cumulative ACKs, where ACK(n) acknowledges all packets up to and including sequence number n. This allows a single ACK to acknowledge multiple packets, reducing ACK traffic and simplifying the protocol.
+> (5%) Invention and adoption of IPv6 is a big advance in computer networking. What problems was IPv6 intended to solve? With the large number of networking devices and applications using IPv4 still in use, how is the transition from IPv4 to IPv6 being resolved?
-### 4. Selective Retransmission Strategy
-When a timeout occurs or a NAK is received, GBN retransmits all unacknowledged packets starting from the oldest unacknowledged packet (base). This "go-back-N" behavior ensures reliable delivery while maintaining simplicity.
+Motivation: Vast address space (no exhaustion), fewer routing entries via hierarchical aggregation, simplified autoconfiguration (SLAAC, DHCPv6), removal of many NAT constraints, and native IPsec support.
-### 5. Receiver Window Size of 1
-The receiver maintains a window of size 1, accepting only the next expected packet in sequence. Out-of-order packets are discarded and the receiver sends a duplicate ACK for the last correctly received packet. This maintains simplicity at the receiver.
+Transition: Dual stack (IPv4+IPv6), tunneling (e.g., 6in4/6to4/Teredo), and translation (NAT64/DNS64) allow coexistence while IPv6 adoption increases.
-### 6. Timer Management
-GBN uses a single timer for the oldest unacknowledged packet. When the timer expires, all unacknowledged packets are retransmitted, and the timer is restarted.
+## 1.4 SNMP Protocol (5%)
-### Performance Benefits
-- Pipeline Utilization: Multiple packets can be "in flight" simultaneously, utilizing available bandwidth more efficiently than stop-and-wait
-- Higher Throughput: Transmission rate approaches channel capacity when the window size is appropriately chosen relative to the bandwidth-delay product
-- Reduced Idle Time: Sender doesn't wait for individual ACKs before continuing transmission
+> (5%) SNMP is a protocol for network management. It has seven message types. What are the purposes of the SNMP GetRequest and SetRequest messages? Why were UDP datagrams chosen to transport SNMP messages?
-Key Insight: GBN trades some efficiency (retransmitting correctly received but out-of-order packets) for simplicity and improved throughput compared to stop-and-wait protocols.
+- GetRequest: Manager reads MIB object values from an agent.
+- SetRequest: Manager changes configuration parameters on an agent.
+- Why UDP: Low overhead and no connection setup; scalable for polling many devices; SNMP defines its own retry/timeout; resilient during control-plane stress when maintaining TCP connections is harder.
-## 1.3 IPv6 Transition (5%)
+## 1.5 SDN-Enabled Devices (5%)
-IPv6 was developed to address critical limitations of IPv4 and represents a major advancement in Internet Protocol technology.
+> (5%) In today’s market and its applications, there are many SDN-enabled networking devices. What are the preferrable features that an SDN-enabled networking device usually has?
-### Problems IPv6 Was Intended to Solve
+Preferable features:
+- Separation of control/data planes; secure controller channel; OpenFlow or similar southbound API.
+- Programmable match-action pipelines and flow tables; counters/telemetry.
+- Network virtualization (slicing/overlays), QoS, and service chaining support.
+- Northbound APIs/integration for centralized policy and automation.
+- Security via centralized policy (ACLs, microsegmentation).
-1) Address Space Exhaustion: IPv4's 32-bit address space provides ~4.3 billion addresses; IPv6 provides ~3.4×10^38 addresses.
+## 1.6 BGP Loop Detection (5%)
+
+> (5%) BGP is a routing protocol used for routing among ISPs. One problem that BGP faces is detecting loops in paths. What are the loops? Why should loops be avoided? How does BGP detect the loops in paths?
-2) NAT Limitations: NAT breaks end-to-end connectivity, complicates P2P, adds overhead; IPv6 removes need for NAT.
+- Loops: Paths that revisit the same AS/router (e.g., A→B→C→B→...).
+- Avoidance: Loops waste bandwidth, add delay, and cause instability.
+- Detection: AS_PATH attribute lists traversed ASes; if a received route’s AS_PATH contains the local AS, discard it. Policies/filters and max-path-length provide additional safeguards.
-3) Routing Table Growth: IPv6 supports hierarchical addressing and aggregation.
+---
-4) Configuration Complexity: IPv6 introduces SLAAC along with DHCPv6.
+# Part 2: Long Answer Questions (70%)
-5) Security Integration: IPv6 was designed with IPsec support in mind.
+## 2.1 1's Complement Checksum (10%)
-### IPv4 to IPv6 Transition Methods
+> (10%) UDP and TCP use 1’s complement for their checksums to detect errors. Suppose you have the following 8‑bit bytes: 11011001, 01010010, 11001010, 10100100 and 01011001.
+> a) What is the 1’s complement of the sum of these 8‑bit bytes? Show all the details of your work.
+> b) Why do UDP and TCP take the 1’s complement of the sum as their checksum, instead of the just sum of these bytes?
+> c) With the 1’s complement scheme, how does the receiver detect errors?
+> d) With this checksum scheme, is it possible that any 1‑bit error will go undetected? How about a 2‑bit error? Explain your answer.
-- Dual Stack: Run IPv4 and IPv6 simultaneously.
-- Tunneling: Encapsulate IPv6 in IPv4 (6in4, 6to4, Teredo).
-- Translation: NAT64/DNS64 for IPv6-only to reach IPv4-only hosts.
+Given 8-bit bytes: 11011001, 01010010, 11001010, 10100100, 01011001.
-Current status: Gradual dual-stack deployments with growing IPv6 adoption.
+a) 1’s complement of the sum (8-bit 1’s-complement arithmetic with end-around carry):
-## 1.4 SNMP Protocol (5%)
+- Interpret bytes (hex/dec): D9 (217), 52 (82), CA (202), A4 (164), 59 (89)
+- Running sum with wrap-around:
+ - D9 + 52 = 0x12B → keep 0x2B, add carry 1 → 0x2C (44)
+ - 0x2C + CA = 0xF6 (246), no carry
+ - 0xF6 + A4 = 0x19A → keep 0x9A, add carry 1 → 0x9B (155)
+ - 0x9B + 59 = 0xF4 (244), no carry
+- Final 1’s-complement sum = 0xF4 = 11110100
+- Checksum = bitwise complement = 0x0B = 00001011
-SNMP is an application layer protocol for monitoring/managing devices. It uses GetRequest to retrieve management info and SetRequest to modify configuration.
+Answer: 00001011
-### Why UDP for SNMP
-- Lightweight/low overhead
-- No connection setup; scalable for polling many devices
-- Custom retries/timeouts at application layer
-- Works even under network stress when TCP might suffer
+b) Why 1’s complement? With 1’s-complement addition and end-around carry, adding data plus checksum yields an all-ones result in the absence of errors, which is easy to verify. It provides better coverage than a simple modulo-2^n sum while remaining simple to implement.
-## 1.5 SDN-Enabled Devices (5%)
+c) Receiver detection: Add all bytes including the checksum using 1’s-complement arithmetic. A correct segment sums to all 1s (for 8-bit, 0xFF); equivalently, the 1’s complement of the total is 0x00. Otherwise, declare error.
-Key features:
-- Separation of control/data planes
-- OpenFlow support with programmable flow tables
-- Southbound API to controller, secure channels
-- Centralized management and real-time monitoring
-- Programmability (QoS, service chaining)
-- Network virtualization (slicing, overlays)
-- Enhanced security via centralized policy
+d) Error coverage: Detects all single-bit errors and most multi-bit errors. Certain balanced multi-bit patterns can evade detection (so some 2-bit errors may go undetected).
-## 1.6 BGP Loop Detection (5%)
+## 2.2 Dijkstra's Shortest Path Algorithm (20%)
-BGP avoids loops using the AS_PATH attribute: if a router sees its own AS number in a received route’s AS_PATH, it discards the route. Additional safeguards include max AS_PATH length and route filtering.
+> (20%) The following table is used to compute the shortest path from A to all other nodes in a network, according to the link‑state algorithm, which is better known as Dijkstra’s shortest path algorithm.
+> a) Interpret the table above in your words: what it is showing and what are each row and each column showing?
+> b) Consider the network shown in the following diagram. With the indicated link costs, use Dijkstra’s shortest path algorithm to compute the shortest path from x to all other network nodes. Show how the algorithm works by computing a table like the one above.
----
+a) Interpretation of the sample table: Each row is one iteration. N’ lists nodes whose shortest-path distances from the source are finalized. Each D(n),P(n) shows the current best known distance to node n and its predecessor on the tentative shortest path. At each iteration, the node with the smallest tentative D(·) is added to N’, and edges from that node are relaxed to update neighbors’ D(·)/P(·).
-# Part 2: Long Answer Questions (70%)
+b) Apply Dijkstra from source x (see figure). The following table shows the iterations and tentative distances; final paths are listed after the table.
-## 2.1 1's Complement Checksum (10%)
+![Network for Q2.2](fig-Q2-2.png)
-Given 8-bit bytes: 11011001, 01010010, 11001010, 10100100, 01011001
+| Step | N’ | D(s),P(s) | D(t),P(t) | D(u),P(u) | D(v),P(v) | D(w),P(w) | D(y),P(y) | D(z),P(z) |
+|:----:|:----------------|:----------|:----------|:----------|:----------|:----------|:----------|:----------|
+| 0 | {x} | 5,x | ∞ | ∞ | ∞ | 3,x | 5,x | ∞ |
+| 1 | {x,w} | 5,x | ∞ | 4,w | ∞ | 3,x | 5,x | ∞ |
+| 2 | {x,w,u} | 5,x | ∞ | 4,w | 5,u | 3,x | 5,x | ∞ |
+| 3 | {x,w,u,s} | 5,x | 6,s | 4,w | 5,u | 3,x | 5,x | ∞ |
+| 4 | {x,w,u,s,v} | 5,x | 6,s | 4,w | 5,u | 3,x | 5,x | ∞ |
+| 5 | {x,w,u,s,v,y} | 5,x | 6,s | 4,w | 5,u | 3,x | 5,x | ∞ |
+| 6 | {x,w,u,s,v,y,t} | 5,x | 6,s | 4,w | 5,u | 3,x | 5,x | 9,t |
+| 7 | {x,w,u,s,v,y,t,z}| 5,x | 6,s | 4,w | 5,u | 3,x | 5,x | 9,t |
-a) 1’s complement of the sum = 11101010 (work shown in notes)
+Final shortest-path costs from x: w=3; u=4 (x→w→u); s=5 (x→s); y=5 (x→y); v=5 (x→w→u→v); t=6 (x→s→t); z=9 (x→s→t→z).
-b) 1’s complement provides better error detection properties with simple implementation.
+## 2.3 CIDR Routing (20%)
-c) Receiver adds all bytes (including checksum). If 1’s complement of sum is 00000000 (or sum=all 1s), no error; else error.
+> (20%) A router running classless interdomain routing (CIDR) has the following entries in its routing table:
+> Address/mask Next hop
+> 135.46.56.0/22 Interface 0
+> 135.46.60.0/22 Interface 1
+> 192.53.40.0/23 Router 2
+> Default Router 3
+>
+> How does a CIDR router route the packets it receives? For each of the following IP addresses, explain what the router will do if a packet with that address arrives.
+> a) 135.46.61.10
+> b) 135.46.53.16
+> c) 192.53.40.6
+> d) 192.53.56.7
+
+CIDR routing uses longest-prefix match: for each packet’s destination, select the matching entry with the longest prefix; otherwise use Default.
+
+Decisions:
+- 135.46.61.10 → matches 135.46.60.0/22 (covers 135.46.60.0–135.46.63.255) → Interface 1
+- 135.46.53.16 → no /22 match (those cover 56.0–63.255) → Default → Router 3
+- 192.53.40.6 → matches 192.53.40.0/23 (covers 40.0–41.255) → Router 2
+- 192.53.56.7 → no match → Default → Router 3
-d) Detects all single-bit errors; most multi-bit errors; some 2-bit patterns can evade detection.
+## 2.4 TCP Congestion Control (20%)
-## 2.2 Dijkstra's Shortest Path Algorithm (20%)
+> (20%) Consider that only a single TCP connection uses a 1 Gbps link, which does not buffer any data. Suppose that this link is the only congested link between the sending and receiving hosts. Assume that the TCP sender has a huge file to send to the receiver and the receiver’s receive buffer is much larger than the congestion window. Further assume that each TCP segment size is 1,500 bytes; the two-way propagation delay of this connection is 15 msec; and this TCP connection is always in the congestion avoidance phase (ignore slow start).
+> a) What is the maximum window size (in segments) that this TCP connection can achieve?
+> b) What is the average window size (in segments) and average throughput (in bps) of this TCP connection?
+> c) How long would it take for this TCP connection to reach its maximum window again after recovering from a packet loss?
+> d) Assume we want the 1 Gbps link to buffer a finite number of segments and always keep the link busy sending data. How would you choose a buffer size? Justify your answer.
-Interpretation and run from node x provided with final shortest paths:
-- x→w: 3; x→u: 4 (x-w-u); x→y: 5 (x-y); x→v: 5 (x-w-u-v);
-- x→s: 5 (x-s); x→t: 6 (x-s-t); x→z: 9 (x-s-t-z)
+Given: Single TCP flow over a 1 Gbps link, no buffering at the link; MSS=1500 B (12,000 bits); two-way propagation delay (RTT) ≈ 15 ms; always in congestion avoidance.
-## 2.3 CIDR Routing (20%)
+a) Maximum window (segments):
+- BDP = C × RTT = 1e9 bps × 0.015 s = 15e6 bits
+- W_max ≈ BDP / MSS = 15e6 / 12,000 ≈ 1,250 segments
-Longest-prefix matching decisions:
-- 135.46.61.10 → 135.46.60.0/22 → Interface 1
-- 135.46.53.16 → Default → Router 3
-- 192.53.40.6 → 192.53.40.0/23 → Router 2
-- 192.53.56.7 → Default → Router 3
+b) Average window and throughput:
+- AIMD sawtooth average ≈ 0.75 × W_max ≈ 937.5 segments
+- Average throughput ≈ (937.5 × 12,000 bits) / 0.015 s ≈ 7.5e8 bps ≈ 750 Mbps
-## 2.4 TCP Congestion Control (20%)
+c) Time to recover to W_max after a loss:
+- After halving to W_max/2, cwnd increases by ~1 MSS per RTT → needs W_max/2 RTTs
+- 625 RTTs × 0.015 s ≈ 9.375 s
-Given 1 Gbps, MSS=1500B, RTT=15ms, single flow in congestion avoidance:
-- a) Max window ≈ BDP/MSS = 15e6/12000 ≈ 1250 segments
-- b) Avg window ≈ 0.75×Wmax ≈ 937.5 seg → throughput ≈ 750 Mbps
-- c) Recovery time: (Wmax/2) seg at +1 seg/RTT → 625 RTTs ≈ 9.375 s
-- d) Buffer ≈ BDP (single flow) ≈ 15 Mb ≈ 1250 segments
+d) Buffer sizing to keep the link busy:
+- For a single flow, provision on the order of the BDP to absorb bursts and maintain full utilization despite window dynamics: ≈ 15 Mb ≈ 1.875 MB ≈ ~1,250 MSS-sized segments.
+- With many flows, smaller buffers (≈ BDP/√N) can suffice, but for N=1, BDP is the safe choice.