Computer Networks | Semester 5 Core Notes
Semester 5 - Page 2: Computer Networks. 27 numbered topics, highlighted rules, packet diagrams, worked subnet/rate examples, answered exam questions, comparison tables and three complete Python demos. General common-core guide, not an official syllabus or past-paper prediction.
Topic map
- Protocols, networks and layering
- OSI and Internet models
- Encapsulation and addresses
- Topologies, devices and switching
- Transmission, propagation and bandwidth-delay
- Physical media, signals and multiplexing
- Framing and error detection
- CRC worked polynomial check
- Stop-and-wait and sliding-window ARQ
- Go-Back-N and Selective Repeat
- Ethernet, Wi-Fi and medium access
- IPv 4, CIDR and subnetting
- IPv 6 and neighbor discovery
- Forwarding, longest prefix and routing
- Distance-vector and link-state routing
- ARP, ICMP and NAT
- UDP and application reliability
- TCP byte stream and handshake
- TCP ACKs, retransmission and termination
- Flow control versus congestion control
- DNS hierarchy, caching and records
- HTTP, TLS and a browser trace
- Email, file transfer and application protocols
- Sockets and message framing
- Network security and segmentation
- Troubleshooting and measurement
- Revision and calculation checklist
1. Protocols, networks and layering
A protocol defines message format and behavior. Layering lets components use services below them while hiding implementation details; the Internet is a network of networks.
Answer: No. It is a teaching model; Internet layer mappings are approximate.
2. OSI and Internet models
OSI has physical, data link, network, transport, session, presentation and application layers. The Internet suite is commonly taught with four or five layers; some OSI functions are integrated into applications/libraries.
Answer: It makes packet traces and diagnosis useful across different implementations.
3. Encapsulation and addresses
Application data is carried by transport segments/datagrams, IP packets and link frames. Link addresses identify a local hop; IP addresses identify network interfaces; ports help demultiplex transport endpoints.
Answer: Link-layer addresses; final IP addresses normally stay unchanged except translation/tunneling.
Application data
-> TCP segment / UDP datagram
-> IP packet
-> Link frame
-> Physical signals4. Topologies, devices and switching
A switch forwards link frames; a router forwards IP packets; an access point joins wireless clients to a LAN. Packet switching shares capacity, while circuit switching reserves a path/resource model.
Answer: No. Propagation, processing, queueing and endpoint work remain.
5. Transmission, propagation and bandwidth-delay
Transmission delay is packet bits/link rate; propagation is distance/signal speed. Throughput is achieved useful rate, not necessarily the nominal bandwidth. Bandwidth-delay product estimates in-flight data.
Answer: No. Propagation depends on path distance and medium.
6. Physical media, signals and multiplexing
Copper, fiber and radio have different attenuation, interference and propagation properties. Multiplexing shares a medium by time, frequency, wavelength or codes; modulation and line coding serve different roles.
Answer: No. Receivers must distinguish signals under real noise/timing limits.
7. Framing and error detection
Data-link framing marks boundaries; parity, checksums and CRC detect selected error patterns. Detection is not automatically correction or security authentication. Different CRC generators have different guarantees.
Answer: No. Noncryptographic checks are not a defense against deliberate forgery.
8. CRC worked polynomial check
CRC arithmetic uses XOR, not ordinary carries. For a generator of degree r, append r zeros to data, divide modulo 2 and replace those zeros by the r-bit remainder; receiver divides the full codeword.
Answer: No. Some error patterns are divisible by the generator; guarantees depend on the polynomial and length.
Teaching CRC remainder and corruption check
def remainder(bits, divisor):
if not bits or any(x not in "01" for x in bits):
raise ValueError("binary data required")
if len(divisor) < 2 or divisor[0] != "1" or divisor[-1] != "1" or any(x not in "01" for x in divisor):
raise ValueError("invalid generator")
work = list(map(int, bits))
poly = list(map(int, divisor))
for i in range(len(work) - len(poly) + 1):
if work[i]:
for j, bit in enumerate(poly):
work[i+j] ^= bit
return "".join(map(str, work[-(len(poly)-1):]))
data, generator = "1101", "1011"
check = remainder(data + "0" * (len(generator)-1), generator)
frame = data + check
print("CRC:", check)
print("frame:", frame)
print("valid remainder:", remainder(frame, generator))
corrupt = ("0" if frame[0] == "1" else "1") + frame[1:]
print("corrupt remainder:", remainder(corrupt, generator))
Checked output:
CRC: 001 frame: 1101001 valid remainder: 000 corrupt remainder: 101
9. Stop-and-wait and sliding-window ARQ
ARQ combines error detection, acknowledgments, timeouts and retransmission. Sequence numbers distinguish duplicates; a sliding window permits multiple frames in flight.
Answer: Loss or failure can prevent an ACK from arriving.
10. Go-Back-N and Selective Repeat
Go-Back-N commonly retransmits the outstanding suffix after loss; Selective Repeat acknowledges/buffers individual frames. Sequence-number/window limits must avoid confusing new frames with old duplicates.
Answer: No. Out-of-order buffering can require more receiver state.
11. Ethernet, Wi-Fi and medium access
Classic shared Ethernet uses CSMA/CD; modern switched full-duplex Ethernet does not need collision detection. Wi-Fi uses contention/avoidance mechanisms and cannot assume Ethernet's collision model.
Answer: No. Learned unicast forwarding can select one output port.
12. IPv 4, CIDR and subnetting
IPv 4 has 32-bit addresses; a /p prefix leaves 32-p address bits. Network/broadcast conventions reserve two addresses in ordinary subnets, with /31 point-to-point and /32 host-route exceptions.
Answer: No. Membership includes network/broadcast addresses under ordinary conventions.
IPv4 subnet calculation with standard library
from ipaddress import ip_interface, ip_network
interface = ip_interface("192.0.2.42/26")
network = interface.network
print("network:", network.network_address)
print("mask:", network.netmask)
print("broadcast:", network.broadcast_address)
print("total:", network.num_addresses)
print("conventional hosts:", network.num_addresses - 2)
print("192.0.2.63 in block:", ip_interface("192.0.2.63/32").ip in network)
print("192.0.2.64 in block:", ip_interface("192.0.2.64/32").ip in network)
print("/31 total:", ip_network("192.0.2.0/31").num_addresses)
print("/32 total:", ip_network("192.0.2.0/32").num_addresses)
Checked output:
network: 192.0.2.0 mask: 255.255.255.192 broadcast: 192.0.2.63 total: 64 conventional hosts: 62 192.0.2.63 in block: True 192.0.2.64 in block: False /31 total: 2 /32 total: 1
13. IPv 6 and neighbor discovery
IPv 6 uses 128-bit addresses, extension headers and no IPv 4-style broadcast. Neighbor Discovery uses ICMPv 6 instead of ARP. Routers do not fragment IPv 6 packets; source handling and path MTU matter.
Answer: No. Addressing and protocol mechanisms differ.
14. Forwarding, longest prefix and routing
Forwarding selects the next hop for one packet; routing computes/distributes reachability. Choose the longest matching prefix, not simply the first textual route. Default /0 is the least-specific fallback.
Answer: No. Specificity is an address match rule, not distance.
Longest-prefix route selection
from ipaddress import ip_address, ip_network
routes = [(ip_network("0.0.0.0/0"), "default"),
(ip_network("192.0.2.0/24"), "gateway-A"),
(ip_network("192.0.2.64/26"), "gateway-B")]
def choose(text):
address = ip_address(text)
candidates = [(n.prefixlen, hop) for n, hop in routes if address in n]
return max(candidates, default=(None, None))[1]
for text in ["192.0.2.70", "192.0.2.42", "198.51.100.8"]:
print(text, choose(text))
Checked output:
192.0.2.70 gateway-B 192.0.2.42 gateway-A 198.51.100.8 default
15. Distance-vector and link-state routing
Distance-vector shares route-distance information with neighbors; link-state distributes topology information and computes paths. Both need convergence and loop handling. BGP policy routing is a different interdomain setting.
Answer: No. It may represent cost, hop count, delay or policy-related preference.
16. ARP, ICMP and NAT
ARP resolves IPv 4 next-hop link addresses on suitable local links. ICMP carries control/error information. NAT rewrites addressing/ports at a boundary but does not encrypt data or replace firewall policy.
Answer: No. It tests limited reachability, not DNS, TLS or application routing.
17. UDP and application reliability
UDP transports datagrams with ports and checksum rules but no built-in retransmission, ordering or congestion control. Applications/protocols above it can add those features.
Answer: No. UDP preserves datagram boundaries; TCP presents a byte stream.
18. TCP byte stream and handshake
TCP offers an ordered reliable byte stream with connection state. The three-way handshake synchronizes initial sequence state; application message boundaries require their own framing. It does not authenticate identity or encrypt.
Answer: TCP may split or combine data independently of application writes.
Client Server |--- SYN ------------->| |<-- SYN + ACK --------| |--- ACK ------------->| | byte-stream data |
19. TCP ACKs, retransmission and termination
TCP sequence numbers identify bytes; ACKs report progress and retransmission recovers loss. FIN closes one direction; RST aborts. Timers and duplicate data handling are part of the state machine.
Answer: No. It can mean local buffering; transport delivery and application commitment differ.
20. Flow control versus congestion control
Flow control protects receiver buffer space; congestion control adapts to network capacity/loss signals. Sender flight size is constrained by both advertised receiver window and congestion state.
Answer: No. They protect different resources and are tracked separately.
21. DNS hierarchy, caching and records
DNS maps names to records through delegated authority and resolvers, caching answers according to TTL. A/AAAA name addresses, MX mail routing, and CNAME aliases; DNS does not fetch web content.
Answer: No. TLS certificate/name validation supplies separate authentication.
22. HTTP, TLS and a browser trace
A common HTTPS trace resolves DNS, establishes TCP, negotiates TLS and exchanges HTTP; connection reuse/cache can skip work. HTTP/3 uses QUIC over UDP instead. TLS protects a properly authenticated transit channel, not compromised endpoints.
Answer: No. Diagnose hostname, time, chain or server configuration instead.
Name -> DNS answer
-> route and next hop
-> TCP connection
-> authenticated TLS
-> HTTP request/response23. Email, file transfer and application protocols
Application protocols define messages and workflow above transport. SMTP handles mail transfer; IMAP/POP support retrieval; FTP has a distinct channel/security design. Use secure supported deployments rather than assuming plaintext protocols protect credentials.
Answer: No. Services can use other ports; verify the actual endpoint/configuration.
24. Sockets and message framing
A socket API exposes transport operations, not automatic domain-message handling. Stream applications need framing, partial-read/write handling, timeouts and cleanup. Bind/listen/accept differ from connect.
Answer: To prevent unbounded allocation or resource exhaustion on malicious/broken input.
25. Network security and segmentation
Firewalls enforce traffic policy; TLS/VPNs protect selected channels; segmentation limits reach. Authentication/authorization and endpoint hygiene remain necessary. Test only networks/accounts you are permitted to inspect.
Answer: No. Confidentiality and authorization are independent.
26. Troubleshooting and measurement
Work layer by layer:local link/address, route, DNS, transport, TLS, HTTP and application. Distinguish timeout, refusal, name failure and resource error. Measure latency/loss/throughput before assigning cause.
Answer: No. A single limited test does not represent the full workload/path behavior.
27. Revision and calculation checklist
State units, width, prefix, protocol assumptions and the exact objective. Draw encapsulation and one request path; solve subnet/rate problems by arithmetic and test boundary addresses.
Answer: Definition, layer responsibility, worked trace/calculation, assumptions and a relevant limitation.
Address and delivery scope
| Item | Scope | Common mistake |
|---|---|---|
| MAC/link address | One local link | Using remote MAC across routers |
| IP address/prefix | Network interface and route match | Treating prefix as port |
| Port | Transport endpoint demultiplexing | Assuming port proves identity |
| DNS name | Name-to-record mapping | Assuming DNS fetches web page |
| TLS certificate | Authenticated channel identity under validation | Disabling verification |
TCP and UDP comparison
| Property | TCP | UDP |
|---|---|---|
| Abstraction | Byte stream | Datagrams |
| Ordering/retransmission | Built in | Not built in |
| Message boundary | Application defines it | Datagram boundaries retained |
| Control | Flow and congestion mechanisms | Higher layer must handle needs |
| Security | Not encrypted by itself | Not encrypted by itself |
Subnet and rate calculations
| Question | Working | Result |
|---|---|---|
| /24 total addresses | 2^(32-24) | 256 |
| /26 total addresses | 2^(32-26) | 64 |
| /26 conventional hosts | 64 - 2 | 62; exceptions do not use this formula |
| 1000 bytes at 1 Mb/s | 8000 / 1000000 seconds | 8 ms transmission only |
| 10 Mb/s x 100 ms | 10000000 x 0.1 bits | 1000000 bits = 125000 bytes |
Revision and exam checklist
Explain each layer, draw a request trace, calculate subnet boundaries, distinguish flow/congestion control and diagnose errors by stage. State ordinary IPv4 subnet assumptions before subtracting two addresses. For CRC, state generator and arithmetic. Network testing requires permission.
Resources and sources
Standards and open textbooks support the rules. Diagrams and examples here are original; lab resources retain their own runtime requirements.
Comments
Post a Comment