Internet and Security - Mock Exam 2
Questa pagina non ha ancora la versione ripasso: qui sotto c'è il testo completo.
In questa pagina 13
Mock exam of Internet and Security (9 credits, Information Engineering, UniPD), not an official paper. The official written exam has two modules, theory (questions on the course) and practical (network configuration exercises like those seen in class), plus a laboratory test. The theory module of the real papers is not public: the model for this mock exam is the set of past written exams and the official simulations of the Internet course of Padova (same exercise types: store-and-forward queues, ARQ and TCP, addressing, forwarding and routing tables), completed with security topics taken from the notes. The laboratory test is not simulated here. The number of questions, the points and the duration are a proposal: Theory module = 10 quizzes with four options and exactly one correct answer, 1 point each (10 points, at least 4 of them on Network Security: here 5); Practical module = Exercise 1 (12 points) and Exercise 2 (8 points); total 30 points, 2 hours, calculator allowed, no other material. No penalty for wrong answers.
Quiz 1
A datagram with Total Length bytes (header of bytes, no options) must cross a link with MTU bytes. Which description of the resulting fragments is correct?
- A) fragments; the last one has Fragment Offset and Total Length
- B) fragments; the last one has Fragment Offset and Total Length
- C) fragments; the last one has Fragment Offset , Total Length and MF
- D) fragments; the last one has Fragment Offset and Total Length
Show the result
Answer C.
Show the full solution
The payload is bytes (IPv4 Datagram and FragmentationIPv4 is a connectionless, unreliable best-effort service; the header is 20 to 60 bytes (HLen counts 4-byte words), TTL limits hops, Protocol identifies the payload (1 ICMP, 6 TCP, 17 UDP) and the checksum covers only the header; a datagram larger than the link MTU is fragmented (only the payload is split, offsets are in units of 8 bytes, MF is 1 in all fragments but the last) and reassembled only at the destination.IPv4 Datagram and Fragmentation →). Every fragment repeats the -byte header, so it can carry at most bytes of data. The offset is written in units of bytes, hence every fragment except the last must carry a multiple of : bytes. The number of fragments is .
| fragment | payload | Total Length | MF | offset (units of 8 bytes) |
|---|---|---|---|---|
| 1 | 976 | 996 | 1 | 0 |
| 2 | 976 | 996 | 1 | 122 |
| 3 | 976 | 996 | 1 | 244 |
| 4 | 92 | 0 | 366 |
Why the others are wrong. A writes the offset in bytes () instead of in units of bytes. B uses bytes per fragment: is not a multiple of (the offset of the second fragment would be ), so the last offset cannot even be written. D forgets that the header takes of the bytes (it would put bytes of data in each fragment, giving fragments and offset ). Typical errors: dividing by , forgetting the multiple of , writing the offset in bytes.
Quiz 2
Which fields of the IPv4 header must be modified by every router that forwards a datagram without fragmenting it?
- A) Time To Live and Header Checksum
- B) Time To Live only
- C) Time To Live, Header Checksum and Identification
- D) Time To Live, Header Checksum and Destination Address
Show the result
Answer A.
Show the full solution
At each hop the router decrements the TTL by (and discards the datagram, possibly sending an ICMP time exceeded message, when it reaches : ICMP, Ping and TracerouteICMP adds to IP the error reporting and queries it lacks; its messages travel inside IP datagrams with Protocol 1 and are either errors (destination unreachable type 3, time exceeded 11, redirect 5, parameter problem 12), always sent to the original source with the original IP header plus 8 bytes of data, or queries (echo request 8 and reply 0, timestamp 13 and 14); ICMP only reports and never corrects errors, and it supports ping (RTT), path MTU discovery with the D bit (maximum payload 1500-20-8=1472 bytes) and traceroute (TTL increasing, n+1 probes for n routers), but also attacks such as smurf and fake redirects.ICMP, Ping and Traceroute →). The Header Checksum covers the whole header, so changing the TTL forces the router to recompute it at every hop (IPv4 Datagram and FragmentationIPv4 is a connectionless, unreliable best-effort service; the header is 20 to 60 bytes (HLen counts 4-byte words), TTL limits hops, Protocol identifies the payload (1 ICMP, 6 TCP, 17 UDP) and the checksum covers only the header; a datagram larger than the link MTU is fragmented (only the payload is split, offsets are in units of 8 bytes, MF is 1 in all fragments but the last) and reassembled only at the destination.IPv4 Datagram and Fragmentation →). B forgets the checksum. The Identification is the same for all fragments of a datagram and is never changed by a router that does not fragment (C), and source and destination addresses never change in transit (D): they change only inside a NAT (NAT and Private AddressesPrivate networks (intranets) use TCP/IP with private address blocks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) that may be reused by different intranets but are never routed in the public Internet; to reach the Internet an intranet needs an application proxy or NAT, a router that translates private to public addresses using a NAT table and per-session mappings: Basic NAT translates only the IP address one to one, NAPT also translates the port so many sessions share one public IP, and Twice NAT adds DNS support and static mappings so sessions can also start from outside.NAT and Private Addresses →). Typical error: believing that the checksum is computed only by the sender.
Quiz 3
Host H has address , netmask and default gateway . Its ARP cache is empty. H sends a datagram to . What does H do?
- A) It sends a broadcast ARP request with target IP and then puts the MAC address of that host in the frame
- B) It sends a unicast ARP request to the gateway asking for the MAC address of
- C) It sends the datagram in a frame with destination MAC FF:FF:FF:FF:FF:FF, because the destination is not on its network
- D) It sends a broadcast ARP request with target IP , then sends a frame with the gateway's MAC address as destination and as IP destination
Show the result
Answer D.
Show the full solution
Mask is : blocks of addresses (Subnetting, VLSM and SupernettingSubnetting splits an address block into smaller subnets by lengthening the mask (2^s subnets when s bits are borrowed), supernetting does the opposite by shortening the prefix to merge contiguous blocks; design rules for variable-size subnets are power-of-two sizes M with M at least hosts plus 2, prefix 32 minus log2 M, and start addresses divisible by M (largest subnet first), while 2^j blocks of prefix n aggregate into one block of prefix n minus j only if contiguous and aligned.Subnetting, VLSM and Supernetting →). lies in the block -, so the network of H is (broadcast ). The destination lies in the block -: AND , so the delivery is indirect (Forwarding and Routing TablesForwarding moves each packet one hop at a time toward its destination; it is direct when the destination is on a local network (ARP gives its MAC) and indirect otherwise (the packet goes to the next hop or default gateway given by the routing table). With netmasks, delivery is direct on interface x if the destination AND the mask equals the interface address AND the mask; otherwise the table is scanned from the longest mask (longest prefix match) and the default route 0.0.0.0/0 always matches; route aggregation shortens tables.Forwarding and Routing Tables →). The next hop is the default gateway , which belongs to the network of H (it is the last host address of -).
ARP always resolves the next hop, never the final destination (ARP - Address Resolution ProtocolTo place an IP datagram in a frame a node needs the MAC address of the next hop, obtained with ARP: a broadcast request (destination MAC FF:FF:FF:FF:FF:FF, carrying the sender's IP and MAC and the wanted IP) and a unicast reply with the wanted MAC, stored in the ARP cache; ARP always resolves the next hop (destination host or router), never the final destination, and since broadcasts do not leave the subnet a router can answer with its own MAC (proxy ARP).ARP - Address Resolution Protocol →): H broadcasts an ARP request (frame destination FF:FF:FF:FF:FF:FF) with target IP , the gateway answers in unicast, and the data frame is addressed to the gateway's MAC while the IP destination remains . A asks for the wrong host, which would never answer a broadcast of this network because it is not here. B is wrong twice: the request is a broadcast (the MAC is unknown), and the target is the gateway. C confuses the link-layer broadcast with forwarding: a datagram is never sent in broadcast to reach another network.
Quiz 4
A DHCP client obtains at 09:00 a lease of hours. The server is switched off right after sending the DHCPACK. At what time does the client first send a broadcast DHCPREQUEST to any server (rebinding)?
- A) 13:00
- B) 16:00
- C) 15:00
- D) 17:00
Show the result
Answer B.
Show the full solution
The client state machine of DHCP - Dynamic Host ConfigurationBOOTP (obsolete) statically maps MAC addresses to IP addresses, while DHCP assigns addresses dynamically on lease, even after the operating system has started; the client-server dialogue runs over UDP (server port 67, client port 68) with DHCPDISCOVER, DHCPOFFER, DHCPREQUEST and DHCPACK (plus DHCPRELEASE), and the ACK delivers IP address, netmask, default gateway and DNS server, with lease renewal at 50 percent and rebinding at 87.5 percent of the lease.DHCP - Dynamic Host Configuration → has three thresholds. At percent of the lease ( hours, 13:00) the client enters the renewing state and sends a DHCPREQUEST in unicast to the server that gave the address; the server is off, so no DHCPACK arrives. At percent of the lease ( hours, 16:00) it enters the rebinding state and sends a DHCPREQUEST in broadcast, so that any server can renew. At percent (17:00) the lease expires and the client restarts from DHCPDISCOVER. A is the first (unicast) request, D is the expiry; C comes from taking percent. Typical error: confusing the unicast renewal with the broadcast rebinding.
Quiz 5
A NAT router uses NAPT with the single public address . Hosts and both open a TCP connection from source port to , port . Which statement is correct?
- A) The NAT must assign two different public addresses, otherwise it cannot separate the replies
- B) The NAT keeps source port for both connections and separates the replies by the private address contained in them
- C) The NAT rewrites source address and source port of the two connections with different NAT ports (for example and ) and uses the destination port of the replies to find the right row of its table
- D) The NAT rewrites only the source address, and the second connection is refused because port is already in use
Show the result
Answer C.
Show the full solution
NAPT translates (NAT and Private AddressesPrivate networks (intranets) use TCP/IP with private address blocks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) that may be reused by different intranets but are never routed in the public Internet; to reach the Internet an intranet needs an application proxy or NAT, a router that translates private to public addresses using a NAT table and per-session mappings: Basic NAT translates only the IP address one to one, NAPT also translates the port so many sessions share one public IP, and Twice NAT adds DNS support and static mappings so sessions can also start from outside.NAT and Private Addresses →). The two internal hosts use the same port and the same destination, so the only way to tell the two sessions apart on the way back is the NAT port, chosen among the free ports of the gateway: for example and . A reply to is matched in the table and its destination is rewritten to ; the NAT must also recompute the IP and TCP checksums. A describes Basic NAT (one public address per session, IP only). B is impossible: the reply carries only the public address, never the private one. D describes Basic NAT without the port: with NAPT nothing is refused, because a public address supports about simultaneous sessions (Transport Layer - Ports and MultiplexingThe transport layer provides logical end-to-end communication between application processes on different hosts and exists only in end hosts; the network layer delivers to the right computer (IP address) and transport to the right process (16-bit port number, 0 to 65535); an IP address plus a port is a socket and the four-tuple of IPs and ports identifies a connection, with multiplexing and demultiplexing done by UDP on the destination socket and by TCP on the whole four-tuple, and the protocols are UDP (connectionless, unreliable), TCP (connection-oriented, reliable) and SCTP.Transport Layer - Ports and Multiplexing →). Typical error: forgetting that in NAPT the port is rewritten too.
Quiz 6
On a switched Ethernet LAN, client C (address ), router R () and attacker M (MAC address ) are connected to the same switch. M wants to read the traffic between C and R with ARP poisoning. Which false ARP replies must M send, repeatedly?
- A) To C: " is at "; to R: " is at "
- B) To C: " is at "; to R: " is at "
- C) Only to C: " is at "
- D) To the switch: "the MAC addresses of C and R are on the port of M"
Show the result
Answer B.
Show the full solution
The poisoning changes the destination MAC that each victim writes in its frames (Man-in-the-Middle Attack with ARP PoisoningLab 7 shows that Telnet sends user name and password in clear, so with a hub a tcpdump on the attacker is enough, while with a switch the attacker needs ARP poisoning (false ARP replies repeated every second) and IP forwarding to sit in the middle and read the session in Wireshark with Follow TCP stream.Man-in-the-Middle Attack with ARP Poisoning →). C must believe that the router's IP has the attacker's MAC, and R must believe that the client's IP has the attacker's MAC; in each false reply the MAC is the attacker's and the IP is the impersonated machine's (A swaps the two and tells each victim a false address of itself, which changes nothing useful). With C only (C) the frames from C to R reach M, but the answers of R still go straight to C: M sees one direction only, so it is not a man in the middle on the whole session. D describes an attack on the switch table (not ARP): ARP replies are sent to the hosts, never to the switch, and the lab does not touch the switch table. The replies are repeated every second because the real hosts keep sending true replies and the cache entries expire. Typical error: swapping IP and MAC in the forged packets.
Quiz 7
During an ARP poisoning attack between client C and a telnet server, the attacker M forgets to enable IP forwarding. What happens?
- A) Nothing: the switch delivers the frames to the router and M only copies them
- B) The router immediately corrects its ARP cache and the attack stops with no visible effect
- C) The session continues normally, because TCP in the client retransmits the segments to the real MAC address of the router
- D) The frames of C arrive at M but are not forwarded: the telnet session stalls and then fails, so the attack becomes a denial of service and is noticed
Show the result
Answer D.
Show the full solution
After the poisoning, C writes the attacker's MAC as destination in every frame for the server, so the frames reach M, not the router. If the kernel of M does not forward IP packets, they are dropped there: the TCP segments are never acknowledged, the client retransmits to the same wrong MAC, and the connection stalls and finally breaks (Man-in-the-Middle Attack with ARP PoisoningLab 7 shows that Telnet sends user name and password in clear, so with a hub a tcpdump on the attacker is enough, while with a switch the attacker needs ARP poisoning (false ARP replies repeated every second) and IP forwarding to sit in the middle and read the session in Wireshark with Follow TCP stream.Man-in-the-Middle Attack with ARP Poisoning →, section on common mistakes). A is false because the switch delivers frames only by destination MAC, and that MAC is M's. B is false: ARP has no authentication, nothing is corrected until the next true reply, and a retransmission does not change the ARP cache. C is false because the destination MAC comes from the poisoned ARP cache, not from the TCP layer. With forwarding enabled the traffic passes through M unchanged (passive attack) or modified (active attack) and nobody notices. Typical error: forgetting that the attacker must also forward the packets.
Quiz 8
Two sites, A () and B (), are joined by an IPsec ESP tunnel between the border routers (site A) and (site B), in tunnel mode. A host of A sends a packet to (source ). What can a router of the public Internet see in the packet it forwards?
- A) Source , destination , protocol (ESP); the original packet, with its addresses, is encrypted inside the payload
- B) Source , destination , protocol ; only the payload is encrypted
- C) Source , destination , protocol (AH); the original packet is in clear
- D) Source , destination , with the original header unchanged, because tunnel mode keeps it
Show the result
Answer A.
Show the full solution
In tunnel mode the whole original IP packet (header included) is protected and becomes the payload of a new IP packet with a new header between the two tunnel endpoints (VPN and IPsecA VPN is a private network built over a public one: a VPN server admitted by the firewall authenticates outside users, and protected IP packets are encapsulated as the payload of other IP packets (IP tunnelling) using IPsec (AH, ESP, tunnel or transport mode, one-way Security Associations) or an SSL/TLS tunnel through TUN/TAP virtual interfaces.VPN and IPsec →). With ESP (IP protocol ) the inner packet is also encrypted, so the Internet sees only and protocol : the addresses and are private and could not be routed anyway. B and D describe transport mode, where the original header is kept in clear (so traffic analysis is possible); in tunnel mode the original header is always encapsulated. C has protocol , which is AH: AH gives only integrity and authentication, not confidentiality, and the question says ESP. Typical error: believing that tunnel mode keeps the original header.
Quiz 9
A VPN gateway uses ESP in tunnel mode over a path with MTU bytes. Overheads: new IP header bytes, ESP header , initialisation vector , ESP trailer (pad length and next header), integrity code ; the cipher has blocks of bytes and the padding makes the sum (inner packet padding trailer) a multiple of . What is the largest inner packet, in bytes, that fits in the MTU with no fragmentation?
- A)
- B)
- C)
- D)
Show the result
Answer C.
Show the full solution
Let be the inner packet length and the padding. The outer packet is The quantity must be a multiple of (VPN and IPsecA VPN is a private network built over a public one: a VPN server admitted by the firewall authenticates outside users, and protected IP packets are encapsulated as the payload of other IP packets (IP tunnelling) using IPsec (AH, ESP, tunnel or transport mode, one-way Security Associations) or an SSL/TLS tunnel through TUN/TAP virtual interfaces.VPN and IPsec →, numeric example on ESP): the largest multiple of not above is . Then , and since is already a multiple of , and . Check: gives an outer packet of ; needs and gives .
A subtracts only the new IP header (). B subtracts the fixed overhead but forgets that the padded length must be a multiple of (, which would need padding). D lowers the multiple of one step too much (). Typical error: ignoring the padding to the cipher block.
Quiz 10
Which statement about IPsec is correct?
- A) AH (protocol ) gives confidentiality, while ESP (protocol ) gives only integrity
- B) ESP gives confidentiality in addition to integrity and authentication, and a Security Association is one-way, so two SAs are needed for traffic in both directions
- C) A single Security Association protects traffic in both directions, because the SPI identifies both directions
- D) In transport mode the original IP header is encrypted and hidden from the routers
Show the result
Answer B.
Show the full solution
AH (IP protocol ) gives source authentication and integrity; ESP (protocol ) gives also confidentiality (encryption): A swaps them (VPN and IPsecA VPN is a private network built over a public one: a VPN server admitted by the firewall authenticates outside users, and protected IP packets are encapsulated as the payload of other IP packets (IP tunnelling) using IPsec (AH, ESP, tunnel or transport mode, one-way Security Associations) or an SSL/TLS tunnel through TUN/TAP virtual interfaces.VPN and IPsec →). A Security Association (SA) is a one-way logical connection with its own SPI, keys, protocols and sequence counter (used against replay): bidirectional traffic needs two SAs, so C is false. In transport mode the original IP header is kept and not protected (routers must read it): D describes tunnel mode, and even there the outer header is in clear, since routers need it. Typical errors: counting one SA for bidirectional traffic, confusing AH with ESP, forgetting that the header stays in clear in transport mode. For the security goals involved see Network Security - Threats and AttacksA threat is any event that can violate a security goal (confidentiality, integrity, availability, accountability, privacy) and its realisation is an attack; security services and mechanisms counter the threats, and sniffing and spoofing underlie the main network attacks, DoS and man-in-the-middle.Network Security - Threats and Attacks →.
Exercise 1 (points 12)
A point-to-point link joins a sender S and a receiver R. The bit rate is Mbit/s and the one-way propagation delay is ms. Data frames have bit, of which bit are header; acknowledgments (ACK) have bit. R sends the ACK as soon as it has completely received a frame. Processing times are negligible.
(a) (2 points) Compute the transmission times and , the time needed to send a frame and receive its ACK, and the pipe capacity in frames. What is the utilization of Stop-and-Wait without errors? What is the smallest window that allows continuous transmission with Go-Back-N or Selective Repeat?
(b) (2 points) Go-Back-N with window . S numbers the frames and sends them back to back as long as the window allows; the first transmission starts at . The ACK is cumulative: means "frame is the next expected", and R discards out-of-order frames, answering again with . The timeout is ms, counted from the start of the transmission of each frame. Only the first transmission of frame 3 is lost; every other frame and every ACK arrives. Find: (i) the instant at which S goes back, and how many frames it retransmits; (ii) the instant at which S starts the first transmission of frame ; (iii) the instant at which frame is delivered to the upper layer of R.
(c) (1 point) Same scenario with Selective Repeat, : R stores out-of-order frames, acknowledges every correctly received frame individually and delivers frames to the upper layer only in order; S keeps one timer per frame ( ms, counted as in (b)) and the window slides to the oldest unacknowledged frame. Give the same three quantities (i), (ii), (iii).
(d) (2 points) Now every transmission (frame or ACK) fails independently with probability . With the minimum timeouts of the course, compute the utilization and the efficiency of Stop-and-Wait, of Go-Back-N with and of Selective Repeat.
(e) (5 points) A TCP sender on another path estimates the retransmission timeout with the rules of the course: ; ; ; . The initial values are ms and ms. The first three measured samples are ms, ms, ms.
- (e1) (2 points) Compute , and for .
- (e2) (1 point) With the old rule "the RTO of a segment is twice the previous sample", which of segments and would suffer a spurious timeout? Does the estimate of (e1) avoid it? Which does TCP actually use after the third sample?
- (e3) (2 points) The next segment is lost. It is sent at and the timeout starts from the of (e2), doubling at each consecutive timeout. Find the instants of its first three retransmissions. The ACK that finally arrives after the third retransmission: is its sample used? Then the first valid sample after the loss is ms: compute the new , and .
Show the result
(a) ms, ms, ms; pipe capacity frames; Stop-and-Wait utilization (about percent); minimum window .
(b) (i) S goes back at ms and retransmits frames (frames to ); (ii) frame starts at ms; (iii) frame is delivered at ms.
(c) (i) timeout at ms and frame retransmitted (frame ); (ii) frame starts at ms; (iii) frame is delivered at ms (together with frames to ).
(d) Stop-and-Wait: , . Go-Back-N: , . Selective Repeat: , .
(e1) : , , ms. : , , ms. : , , ms. (e2) Old rule: segment no (), segment yes (). With the estimate no segment times out (, ). s. (e3) Retransmissions at s, s and s. The sample of the final ACK is discarded (Karn). New values: ms, ms, ms (and is still s).
Show the full solution
(a) Times (ARQ Protocols - Stop-and-Wait, Go-Back-N and Selective RepeatARQ (Automatic Repeat reQuest) makes an error-prone link reliable: the receiver acknowledges (ACK) frames received correctly and the sender retransmits when the timeout expires. Timeouts (against deadlock) and sequence numbers (against duplicates) are needed. With t_G = t_F + 2 tau_p + t_A and error probability p: Stop-and-Wait rho = t_F(1-p)/t_G; Go-Back-N with window N >= t_G/t_F rho = (1-p)/(1+(N-1)p); Selective Repeat rho = 1-p. Efficiency eta = rho I/F. The optimal window is the pipe capacity in packets. For Selective Repeat there is also an optimal frame length: with overhead o and bit error probability P_b, x_opt is about o/2 + sqrt(o/P_b) (shorter frames when the channel errs more).ARQ Protocols - Stop-and-Wait, Go-Back-N and Selective Repeat →): ms; ms. A successful transmission occupies the frame, its propagation, the ACK and its propagation back: The pipe capacity is frames: while S waits for the first ACK it could have sent frames. With Stop-and-Wait only one frame is sent per cycle: , i.e. the link is used about percent of the time (as in Network Performance AnalysisNetwork performance is measured by traffic metrics (bitrate R0, the link maximum; throughput S <= R0, data delivered successfully; goodput at the application layer), delay (end-to-end d = d_proc + d_queue + d_trans + d_prop with d_trans = L/R and d_prop = d/v; jitter; RTT), pipe capacity (BDP = rate times delay) and reliability (PER, PDR, PLR). The throughput of a path is that of its bottleneck link, the minimum bitrate, remembering that shared links split their capacity.Network Performance Analysis → for the bandwidth-delay product). Transmission is continuous if the first ACK returns before S has finished the window: , i.e. , so the smallest window is (the next integer above, not : with frames S would wait ms, i.e. ). The timeout must also be at least ms, which is the value given in (b).
(b) Frame is transmitted during . It reaches R completely at ; the ACK leaves at that instant, takes ms and travels ms, so arrives at S at ms (): ms for frame , for frame , for frame .
First pass. The window is at the start. Frames to occupy . arrives at (window ), at (), at (). Frame starts at , frame at and frame at : each is allowed, so transmission is continuous. Frame is lost (it started at ms): R keeps receiving frames , but expects , so it discards them and repeats ; stays and the window stays , so at ms frame cannot be sent.
(i) The timer of frame started at and expires at ms: S goes back and retransmits from frame onward all the frames it had sent, i.e. ( frames, although to had arrived correctly: the inefficiency of Go-Back-N). They occupy : frame at , frame at , ..., frame at .
(ii) Frame arrives at R at ms and is delivered; reaches S at ms (window ). S finishes the retransmissions at ms and starts frame at ms; from then on transmission is continuous again (each later ACK arrives just in time).
(iii) Frame was retransmitted at ms and is fully received at ms, in order after frames to : delivered at ms. Frames are delivered at ms.
Typical errors: counting one retransmission instead of the whole window; starting the timer when the frame ends; forgetting that frames to are discarded at R although correct; letting S send frame before the go-back.
(c) The first pass is identical (frames to sent, frame lost). Now R stores frames to and acknowledges each individually; the window does not slide beyond because the oldest frame is not acknowledged: at S has the window full, as before.
(i) At ms the timer of frame expires: S retransmits only frame during ( frame). The timers of frames to do not expire, because their individual ACKs arrive at ms, before .
(ii) Frame is received at ms; the ACK reaches S at ms. Now frames to are all acknowledged and the window slides to : S starts frame at ms. Between and ms S is idle (window full), but it restarts ms earlier than with Go-Back-N.
(iii) At ms R receives frame and finds frames to consecutive in its buffer, so it delivers them all at once: frame at ms, ms earlier than with Go-Back-N ().
Cross-check: frame is delivered at ms with Selective Repeat and at ms with Go-Back-N.
- Stop-and-Wait: each failed attempt costs , , so and .
- Go-Back-N with (a failed attempt costs ): , .
- Selective Repeat (a failed attempt costs ): , .
The ranking is the usual one: Selective Repeat is the best, Go-Back-N loses a lot because it resends the whole window, Stop-and-Wait is limited by the pipe capacity () even before the errors. Typical errors: using for Selective Repeat; forgetting the factor in .
- : ; ; ms.
- : ; ; ms.
- : ; ; ms.
(e2) The RTO used for segment is the one computed after sample . Old rule: segment has ms, larger than its : no timeout; segment has ms, smaller than : the timer fires while the ACK is still on its way, a spurious timeout (the previous sample was low and the rule ignores the variability). With the estimate of (e1): segment has , segment has : no spurious timeout, because adds a margin that grows with the variability. In practice the sender uses s: the lower bound of s dominates.
(e3) The first transmission at times out at s: retransmission at s, and the RTO doubles to s (exponential backoff). It times out again at s: retransmission at s, RTO s. Then retransmission at s (next RTO s). When an ACK arrives after the third retransmission, S cannot tell whether it acknowledges the original or one of the three copies, so the sample would be wrong: Karn's algorithm discards it (SRTT and MAD are not updated, they stay and ). The first valid sample ms gives and the timer would still be s. Typical errors: using the sample of the retransmitted segment; using instead of in the MAD; forgetting the s minimum and the doubling.
Exercise 2 (points 8)
(a) (3 points) A router R has three interfaces: eth0 , eth1 and eth2 . Its routing table is:
| row | network | netmask | next hop |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 |
For each of the following destinations say whether the delivery is direct or indirect and, if indirect, which row is used, the next hop and the output interface: , , , , , , , .
(b) (3 points) Five routers A, B, C, D, E are joined by five links with these costs: A-B , A-C , B-C , C-D , D-E . They run distance vector in synchronous rounds: at round each router knows only the cost of its direct links; in each round every router receives the vectors that its neighbours had at the end of the previous round and updates its own with the Bellman-Ford rule. (i) Write the distance vectors of A (towards B, C, D, E) and of E (towards A, B, C, D) at rounds . (ii) After how many rounds do all tables stop changing? Write the routing table of A (destination, cost, next hop) at convergence.
(c) (2 points) The routers of (b) have converged. Then the link D-E fails. D deletes its entry for E; the last vector of C said that E costs . From then on only D and C exchange vectors, alternately starting with D (D updates using C's last vector, then C updates using D's new vector, and so on); A and B send nothing in this interval. A cost greater than counts as infinity. Write the cost of E computed at each step until D and C both consider E unreachable. What happens meanwhile to packets for E? What does split horizon with poison reverse change?
Show the result
(a)
| destination | delivery | row | next hop | interface |
|---|---|---|---|---|
| direct | none | none | eth0 | |
| indirect | 4 | eth2 | ||
| indirect | 3 | eth2 | ||
| indirect | 2 | eth2 | ||
| indirect | 1 | eth2 | ||
| indirect | 5 | eth2 | ||
| indirect | 6 (default) | eth2 | ||
| direct | none | none | eth2 |
(b) (i) Vector of A towards (B, C, D, E): round : ; round : ; round : ; round : . Vector of E towards (A, B, C, D): round : ; round : ; round : ; round : . (ii) All tables change until round and stay the same at round (convergence after rounds, confirmed by round ). Table of A: B cost via B; C cost via B; D cost via B; E cost via B.
(c) Costs of E: D , C , D , C , D , C , D (infinity, step ), then C hears infinity: step . Packets for E loop between D and C until their TTL expires. With split horizon with poison reverse the problem disappears: C announces infinity to D at once, D marks E unreachable at step and C at step .
Show the full solution
(a) Procedure (Forwarding and Routing TablesForwarding moves each packet one hop at a time toward its destination; it is direct when the destination is on a local network (ARP gives its MAC) and indirect otherwise (the packet goes to the next hop or default gateway given by the routing table). With netmasks, delivery is direct on interface x if the destination AND the mask equals the interface address AND the mask; otherwise the table is scanned from the longest mask (longest prefix match) and the default route 0.0.0.0/0 always matches; route aggregation shortens tables.Forwarding and Routing Tables →): first check whether the destination belongs to the network of an interface; if not, scan the table starting from the longest netmask; the default row matches everything and is tried last. Networks of the interfaces (Subnetting, VLSM and SupernettingSubnetting splits an address block into smaller subnets by lengthening the mask (2^s subnets when s bits are borrowed), supernetting does the opposite by shortening the prefix to merge contiguous blocks; design rules for variable-size subnets are power-of-two sizes M with M at least hosts plus 2, prefix 32 minus log2 M, and start addresses divisible by M (largest subnet first), while 2^j blocks of prefix n aggregate into one block of prefix n minus j only if contiguous and aligned.Subnetting, VLSM and Supernetting →): eth0 : the third byte keeps bits, so the block is -; eth1: (-); eth2 : blocks of , network (hosts to , broadcast ). The rows cover: row 1 () -; row 2 () -; row 3 () - (an exception inside row 2); row 4 () all of ; row 5 () -. All next hops () lie in the network of eth2, so every indirect packet leaves from eth2.
- : third byte is in -: direct on eth0. It also matches row 4, but direct delivery has precedence.
- : not in eth1 ( only), not in rows 1-3 () nor 5; only row 4 () and the default match; the longest is row 4: next hop .
- : third byte . It matches row 3 (-), row 2 (-), row 1 (-), row 4 and the default. The longest prefix is row 3 (): next hop .
- : matches row 2 (-), row 1, row 4 and the default, not row 3 (): the longest is row 2 (): next hop .
- : third byte : matches row 1 (-), row 4 and the default, not rows 2-3: row 1 (): next hop .
- : row 5 () and the default: row 5, next hop .
- : , so only the default row: next hop .
- : belongs to : direct on eth2 (it is a neighbour router: ARP asks for its MAC).
Typical errors: choosing the first matching row instead of the longest prefix; using row 4 for (direct delivery comes first); using the wrong mask when computing the AND (the keeps only bits of the third byte).
(b) (Routing Algorithms - Link State and Distance VectorRouting finds least-cost paths in a weighted graph where routers are nodes and networks between routers are edges. Link state floods each router's local links (LSPs) so every router knows the whole graph and runs Dijkstra; distance vector has each router exchange its distance vector with neighbours only and update it with Bellman-Ford, D(A,w)=min(D(A,w), D(A,Y)+d(Y,w)), which converges in at most n-1 rounds but suffers from count to infinity (limited infinity of 16, hold down, triggered updates, split horizon, poison reverse); path vector announces whole paths, chooses by policy and detects loops by finding itself in the path.Routing Algorithms - Link State and Distance Vector →). The update is over the neighbours of . Neighbours: A has B and C; B has A and C; C has B, D and A; D has C and E; E has D.
Round 0 (direct links only). A: B , C . E: D . Round 1 (neighbours' round-0 vectors). C's vector is and B's is , so A obtains: C via B; D via C; E still unknown (: neither B's nor C's round-0 vector contains E). E receives D's vector : C via D. Round 2 (round-1 vectors). B's round-1 vector has D and A's D is via C: now via B. C's round-1 vector contains E (via D): A gets E via C. E receives D's round-1 vector (, , ): A , B . Round 3. A hears B's round-2 vector (E ): E via B, better than via C. E hears D's round-2 vector (A ): A . Round 4. No vector changes.
| round | A: B, C, D, E | E: A, B, C, D |
|---|---|---|
| 0 | ||
| 1 | ||
| 2 | ||
| 3 |
Round finds the shortest paths of at most links: the longest shortest path (A to E, with links) is found at round ; round shows no change. The result equals Dijkstra's. Table of A at convergence: B (next hop B), C (next hop B: beats the direct link of cost ), D (next hop B), E (next hop B). Typical errors: stopping at the first round with no change in A (E still changes), keeping the direct cost for C, using the vectors of the current round instead of the previous one.
(c) After the failure the stale entries are via D (and D has none). Step by step, with cost - (Routing Algorithms - Link State and Distance VectorRouting finds least-cost paths in a weighted graph where routers are nodes and networks between routers are edges. Link state floods each router's local links (LSPs) so every router knows the whole graph and runs Dijkstra; distance vector has each router exchange its distance vector with neighbours only and update it with Bellman-Ford, D(A,w)=min(D(A,w), D(A,Y)+d(Y,w)), which converges in at most n-1 rounds but suffers from count to infinity (limited infinity of 16, hold down, triggered updates, split horizon, poison reverse); path vector announces whole paths, chooses by policy and detects loops by finding itself in the path.Routing Algorithms - Link State and Distance Vector →, count to infinity):
- D uses C's last vector (E ): via C.
- C uses D's new vector: its next hop for E is D, so it must follow it: via D.
- D: .
- C: .
- D: .
- C: .
- D: : infinity. D declares E unreachable.
- C hears infinity from D: : unreachable.
The cost grows by at each message, and the estimate is wrong but finite for steps; during this time a packet for E that reaches D is sent to C, and C returns it to D (a two-hop loop) until its TTL reaches and a router drops it (IPv4 Datagram and FragmentationIPv4 is a connectionless, unreliable best-effort service; the header is 20 to 60 bytes (HLen counts 4-byte words), TTL limits hops, Protocol identifies the payload (1 ICMP, 6 TCP, 17 UDP) and the checksum covers only the header; a datagram larger than the link MTU is fragmented (only the payload is split, offsets are in units of 8 bytes, MF is 1 in all fragments but the last) and reassembled only at the destination.IPv4 Datagram and Fragmentation →). Split horizon with poison reverse: C announces to D "E costs infinity" (because C's route to E goes through D), so D, which has lost its only direct route, gets no false alternative: D marks E unreachable at the first update and C does at the second. It removes this two-hop loop but not every loop, so RIP combines it with a limited infinity, hold down and triggered updates (Internet Routing Protocols - RIP, OSPF and BGPInternet routing is hierarchical for scalability and administrative autonomy: each ISP is an autonomous system (AS) and uses an interior protocol inside it, either RIP (distance vector, hop count with maximum 15, updates about every 30 s, over UDP port 520) or OSPF (link state with Dijkstra, areas attached to backbone area 0, five LSA types, carried directly in IP), while BGP4 (path vector over TCP port 179, eBGP between ASes and iBGP inside) connects ASes with policy-based route choice and loop avoidance by discarding paths that contain the own AS.Internet Routing Protocols - RIP, OSPF and BGP →). Typical errors: letting C keep cost after the failure; stopping the count at instead of at the first cost above .
Self-assessment grid
| exercise | points | what must be there for full points | typical errors |
|---|---|---|---|
| Quiz 1 | 1 | payload , , fragments, last offset , Total Length | offset in bytes; per fragment; header forgotten |
| Quiz 2 | 1 | TTL and checksum change at each hop | checksum forgotten; Identification or addresses changed |
| Quiz 3 | 1 | indirect delivery; ARP request for the gateway; frame to the gateway MAC, IP destination unchanged | ARP for the final destination; broadcast data frame |
| Quiz 4 | 1 | rebinding at percent h, i.e. 16:00, in broadcast | unicast renewal at 13:00; expiry at 17:00 |
| Quiz 5 | 1 | NAPT rewrites IP and port; different NAT ports tell the sessions apart | Basic NAT behaviour; private address in the reply |
| Quiz 6 | 1 | each victim receives "impersonated IP is at attacker MAC", both directions | IP and MAC swapped; one direction only |
| Quiz 7 | 1 | without forwarding the session stalls (denial of service) | believing the attack stays hidden |
| Quiz 8 | 1 | new outer header between the gateways, protocol , inner packet encrypted | tunnel mode keeping the original header |
| Quiz 9 | 1 | , multiple of : | padding ignored; only the IP header subtracted |
| Quiz 10 | 1 | ESP also encrypts; one-way SAs, two needed | AH and ESP swapped; one SA for both directions |
| Exercise 1(a) | 2 | , , ms; pipe ; ; | rounding the window down to ; forgetting |
| Exercise 1(b) | 2 | go-back at ms, frames, frame at ms, frame delivered at ms | one retransmission only; timer from the end of the frame |
| Exercise 1(c) | 1 | frame retransmitted, frame at ms, frames - delivered at ms | sliding the window before frame is acknowledged |
| Exercise 1(d) | 2 | : , , ; with the factor | for Selective Repeat; factor forgotten |
| Exercise 1(e1) | 2 | ms with the old SRTT in the MAD | instead of |
| Exercise 1(e2) | 1 | segment spurious with the old rule; s | forgetting the s minimum |
| Exercise 1(e3) | 2 | retransmissions at s; Karn discards the sample; ms | using the retransmitted sample; no doubling |
| Exercise 2(a) | 3 | direct for and ; longest prefix for the other six | first match instead of longest; direct delivery not first |
| Exercise 2(b) | 3 | vectors of A and E at rounds -; convergence at round ; table of A all via B | stopping too early; direct cost kept for C |
| Exercise 2(c) | 2 | ; loop until TTL expires; poison reverse stops it at once | restarting from cost ; stopping at |
Total points: (quizzes) . The theory module (quizzes) is meant for about minutes without notes; the practical module for about hours.