Internet and Security - Exam of 9 September 2020
Questa pagina non ha ancora la versione ripasso: qui sotto c'è il testo completo.
In questa pagina 3
This is the part 2 (numerical exercises) of the written exam of 9 September 2020 (session 4, academic year 2019/2020) of the Internet course taught at the Department of Information Engineering, University of Padua (Master degree on ICT for Internet and Multimedia Engineering, in English). It is not an exam of this course, but the exercises have the same structure and the same topics as the practical module of Internet and Security. The theory part (part 1) of that exam is not public. The sheet contains two exercises, points, plus optional extra point; the duration and the allowed material are not printed.
The sheet reports only the final results (printed in blue), without any solution: every step below was derived from the notes of the course and then checked against the official results, with Python scripts (event simulation of the queues, round-by-round simulation of TCP, longest prefix match and fragmentation with the ipaddress module). All the official results are reproduced; for one of them (Exercise 1, Question 4) the convention that gives the official value has to be stated explicitly, see the solution.
Official exam format of Internet and Security (University of Padua, 9 credits, in English): a written test in two modules, theory (questions on the course) and practice (network configuration exercises like those seen in class), then a laboratory test. There are four attempts (June and July, September, January or February). A student with at least 18 out of 30 in the written test may ask for an oral exam on the whole programme, and the oral exam may also be imposed to clarify a doubt.
Exercise 1 (points 12)
Consider the network shown in the figure below, where the intermediate routers R1, R2 and R3 implement a packet-switched network paradigm with datagram (store-and-forward) approach. Every router operates with independent queues for every output interface.
Description of the figure. Server A (whose output queue is drawn on the left, holding the packets D, D, E, E, with the last one on the left) is connected to router R1 by link . R1 is connected to R2 by link . R2 is connected to three other nodes: host B by link , host C by link , and router R3 by link . R3 is connected to host E by link and to host D by link .
| Link | Endpoints | Capacity | Propagation delay |
|---|---|---|---|
| A - R1 | Mbps | ms | |
| R1 - R2 | Mbps | ms | |
| R2 - B | Mbps | ms | |
| R2 - C | Mbps | ms | |
| R2 - R3 | Mbps | ms | |
| R3 - D | Mbps | ms | |
| R3 - E | Mbps | ms |
Question 1 (4 pt.) At time , the output queue of server A has four packets towards respectively E, E, D, D (D is the last sent). Considering packets of length Byte and Byte, and assuming that packet transmissions start at time for all nodes, calculate the instant of time the four packets arrive to their intended destinations.
Assume now that a TCP connection is established between server A to host B (neglect the effect of any other parallel transmission within the network). Server A transmits TCP segments of size Byte. The size of the opening and acknowledgment segments is negligible, so it is the header at every single layer. Assume that the initial value of the is Byte, the slow start threshold is KByte, and the receive window is MByte. Determine what follows.
Question 2 (2 pt.) Find the Round Trip Time (RTT) and the value of the TCP sender window that would allow for a continuous stream of segments between server A and host B.
Question 3 (3 pt.) Determine the total time it takes to transfer a message of KByte (from TCP connection setup to reception of last ACK), assuming that the data exchange starts as soon as possible. Neglect processing and queuing delays.
Question 4 (3 pt.) Repeat the previous calculation assuming that, instead of TCP, Stop&Wait (S&W) ARQ is used on each link at the data link layer.
Show the result
- Question 1: the arrival instants are ms for the first E packet, ms for the second E packet, ms for the first D packet and ms for the second D packet.
- Question 2: ms; MSS.
- Question 3: ms.
- Question 4: ms.
Show the full solution
Question 1: arrival times. The transmission time of a packet on a link is (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 →). The two packet sizes are B bit and B bit. With the capacities in Mbit/s, bit divided by Mbit/s gives microseconds, so , and so on. Only the links on the paths are needed: E uses ; D uses .
| Packet | on | on | on | on last link |
|---|---|---|---|---|
| E ( bit) | ms | ms | ms | : ms |
| D ( bit) | ms | ms | ms | : ms |
The four packets are in the order in which they leave A. Every router receives a packet completely before retransmitting it (Circuit Switching and Packet SwitchingA switching node can connect input to output in three ways. Circuit switching sets up a dedicated physical connection first (telephone network), delivery time T = 3N t_p + N t_s + M/R. Datagram packet switching splits the message into K packets with a header, each routed independently with store-and-forward, T = N t_p + (N+K-1)(M/K+H)/R, with optimal K = sqrt((N-1)M/H). Virtual circuit has three phases (setup, data, teardown): a dedicated logical connection without dedicated resources, with a local identifier that changes at each hop.Circuit Switching and Packet Switching →), and every output queue serves the packets in the order in which they arrive (FIFO). A packet starts on a link at the later of two instants: when it is ready (it has arrived) and when the link becomes free. It arrives at the next node after the end of its transmission. The three links are shared by all four packets, so queues form there; the last links and are different, so and do not compete on them.
Link (the server sends back to back from ): , , , . Arrival in R1 (): , , , ms.
Link . finds it free and starts at ; the others arrive while it is busy and wait.
| Packet | ready | start | end | arrival in R2 () |
|---|---|---|---|---|
Link .
| Packet | ready | start | end | arrival in R3 () |
|---|---|---|---|---|
Last links. on : , arrives at E at ms. is ready at but is busy until : it transmits and arrives at ms. The D packets use , which is free: , arrival ms; , arrival ms.
Note that the D packets, although sent last, arrive before the second E packet: they have to wait in the queues of and behind the long packets, but the long packet is then slowed down by ( Mbps, ms of transmission), while the D packets leave through the fast and empty . Typical error: assuming that the order of arrival at the destinations is the order of sending, or forgetting the wait of on behind .
Question 2: RTT and . The path of the connection is , that is . A segment is B bit, so ms, ms, ms. The bottleneck is (the slowest link, Mbit/s): ms.
- Delay of a segment from A to B (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 →): ms.
- Return of the ACK: the transmission time of the ACK is negligible, so only the propagation delays count: ms.
The window that keeps the bottleneck always busy is the one that fills the pipe, i.e. the number of segments that the bottleneck sends during one RTT: segments, equivalent to a bandwidth-delay product of bit MSS. Windows are integers and the stream is continuous only if the ACK of the first segment returns before the window is finished, so the window must be rounded up: With segments the window needs ms to be sent, so the sender stops for ms at every round.
Question 3: transfer of KByte. In segments: B B segments (the exact count fits only with KByte B; with B one would get , which is not an integer). The threshold is MSS, and MB is MSS: it never limits the window here (TCP - Connection, Reliability and Flow ControlTCP is the connection-oriented, reliable transport protocol that turns IP's unreliable service into an ordered byte stream without errors or duplicates; the connection opens with a three-way handshake (SYN, SYN+ACK, ACK) and closes with FIN segments, bytes are numbered (sequence number = first byte of the segment, cumulative ACK = next byte expected), the sender may transmit min(rwnd, cwnd) unacknowledged bytes (rwnd, the receiver window in a 16-bit field, is flow control), errors are handled with checksum, ACKs, retransmission timeout and fast retransmit after three duplicate ACKs, and to fill the pipe the window must reach the bandwidth-delay product, with maximum throughput MSS times Wmax over RTT.TCP - Connection, Reliability and Flow Control →).
Connection setup. SYN and SYN+ACK have negligible transmission time, so only the propagation delays count: each takes ms, so ms in total. The third segment of the handshake is the ACK, sent together with the first data segment, so the data start immediately after the ms.
Windows (TCP Congestion ControlCongestion arises when fast links feed a slow one, router queues fill and packets are lost or delayed, possibly up to network collapse; TCP controls its congestion window cwnd using loss feedback (timeout or three duplicate ACKs): slow start doubles cwnd every RTT up to the threshold ssthresh, then congestion avoidance adds 1 MSS per RTT, and on a loss ssthresh becomes W/2; variants differ in reaction to three dupACKs: Tahoe restarts from cwnd=1, Reno uses fast recovery (ssthresh=cwnd/2, cwnd=ssthresh+3, +1 per further dupACK), NewReno handles partial ACKs and recovers several losses in one window, SACK acknowledges received blocks and resends only what is missing.TCP Congestion Control →). starts from MSS. In slow start it doubles at every round: ; at it reaches and congestion avoidance starts, with MSS per round: In each round the sender can send segments.
| Round (window) | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| (MSS) | ||||||
| phase | SS | SS | SS | SS to | CA | CA |
While , the whole window is sent in less than one RTT (for example ms), so the sender has to wait for the first ACK before sending the next window: each of the first five rounds lasts one RTT, and they carry segments. From the sixth round : the transmission is continuous and the remaining segments leave one every ms (the window keeps growing, but nothing changes: the bottleneck is already saturated).
Reading of the terms: are the first five rounds; separates the departure of the first from that of the last of the segments sent continuously; the last is the time for the final segment to reach B and for its ACK to come back to A (the transmission of that segment on the bottleneck is already part of the RTT). Typical errors: forgetting the ms of the handshake or the final RTT; not rounding up; continuing slow start beyond (that would give and a wrong number of rounds).
Question 4: Stop-and-Wait ARQ on every link. Now there is no end-to-end window: each link runs its own S&W (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 →). The sender of a link transmits one frame and waits for its ACK (negligible transmission time) before sending the next, so the link is busy for a cycle :
| Link | cycle | ||
|---|---|---|---|
| ms | |||
| ms | |||
| ms |
The slowest cycle is the one of ( ms, a link efficiency of only percent in the sense of the S&W formula). Packets reach R2 every ms (limit of ; is faster, so R1 never accumulates a queue), but leave R2 only every ms: a queue grows in R2, and the whole flow proceeds at the rhythm of . The first packet reaches R2 at ms and starts at once on . After that, is never idle: it serves packets, one every ms, so the last ACK of the link arrives at R2 at (The last packet is received by B at ms: it starts on at , ends at and arrives at .)
Which convention gives the official value. The official result is ms, exactly ms more than . The difference is : the official solution counts the time at which the last acknowledgment is received by the server A, i.e. the ACK crosses all three links on its way back ( ms after the arrival at B, as in the RTT of Question 2, where the ACK was end-to-end), not only the link-level ACK of the last hop. Under that convention The data transfer has no connection setup in this scenario (there is no TCP), consistently with the official value. If instead only the last link-level ACK were counted, the answer would be ms. S&W is about times slower than TCP ( ms) because each link idles while waiting for its ACK; TCP keeps the bottleneck full with segments in flight. Typical errors: using the cycle of ( ms) or adding the three cycles per packet (a pipeline works in parallel on different links, so only the slowest cycle counts); forgetting that the first packet needs ms to reach the bottleneck.
Exercise 2 (points 8)
A router has the following interface configuration and routing table:
| Network | Netmask | Next hop |
|---|---|---|
| 142.124.123.0 | 255.255.255.128 | 142.124.124.192 |
| 142.124.124.0 | 255.255.255.128 | 142.124.123.201 |
| 142.124.16.0 | 255.255.255.0 | 142.124.124.192 |
| 142.124.19.0 | 255.255.255.128 | 142.124.123.202 |
| 142.124.28.0 | 255.255.255.0 | 142.124.124.192 |
| 142.124.31.0 | 255.255.255.0 | 192.168.0.254 |
| 142.124.8.0 | 255.255.248.0 | 192.168.0.254 |
| 0.0.0.0 | 0.0.0.0 | 192.168.0.254 |
| Interface | IP address | Netmask | MTU [B] |
|---|---|---|---|
| eth0 | 142.124.123.254 | 255.255.255.128 | 1000 |
| eth1 | 142.124.124.254 | 255.255.255.128 | 500 |
| eth2 | 192.168.0.1 | 255.255.255.0 | 1000 |
Question 1 (5 pt.) Indicate how packets with the following destination IP addresses are handled. Indicate if direct or indirect forwarding is used (in case of indirect forwarding, indicate what is the next hop and its corresponding output interface), and whether and why the packet is dropped.
- 142.124.123.200 from eth1. Packet size is 300 B and Don't Fragment bit set to 1.
- 142.124.123.120 from eth0. Packet size is 300 B and Don't Fragment bit set to 1.
- 142.124.19.232 from eth0. Packet size is 400 B and Don't Fragment bit set to 1.
- 142.124.27.230 from eth1. Packet size is 20'000 B and Don't Fragment bit set to 0 (in case IP fragmentation is needed, indicate how many fragments should be sent).
Question 2 (3 pt.) The network administrator of network with IP 142.124.0.0 and netmask 255.255.192.0 wants to partition the network to serve a previous network of 1014 hosts. Define an addressing plan for this network indicating IP addresses and netmask, direct broadcast address, and maximum number of hosts.
EXTRA 1 POINT (OPTIONAL). Assess how many subnetworks of 34 nodes can be defined within the subnetwork created at the previous point, and the corresponding netmask.
Show the result
Question 1:
- 142.124.123.200 from eth1: direct forwarding through eth0.
- 142.124.123.120 from eth0: indirect forwarding through eth1 (next hop 142.124.124.192).
- 142.124.19.232 from eth0: indirect forwarding through eth2 (next hop 192.168.0.254, default route).
- 142.124.27.230 from eth1: indirect forwarding through eth2 (next hop 192.168.0.254, default route); fragments are sent.
Question 2: IP (netmask ); direct broadcast ; maximum number of hosts .
Extra: subnetworks, with netmask ().
Show the full solution
Question 1: forwarding. The procedure is the one of 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 the direct delivery test on every interface (destination AND netmask equal to interface address AND netmask), then, if no interface matches, the table with longest prefix match. Finally the output interface is the one whose network contains the next hop, and the packet size is compared with the MTU of that interface (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 →).
Networks of the interfaces (the AND is needed only on the byte where the mask is not or ; here the mask byte is or ):
- eth0: , mask : AND , so the network is (addresses to ).
- eth1: , mask : the network is (addresses to ).
- eth2: : network .
Output interface of each next hop: is in (since ): eth1; and are in : eth0; is in : eth2. (The routing table rows of the first two networks look like the two interface networks but are the lower halves : not the same networks.)
| Packet | Analysis | Result |
|---|---|---|
| from eth1, B, DF | Direct test on eth0: , AND , equal to the network of eth0 (): it belongs to the network of eth0, so no table lookup is needed. The packet is delivered directly through eth0 (with ARP, 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 →). It is not in the row (). : it passes | direct forwarding through eth0 |
| from eth0, B, DF | Direct test: , so it is not in the network of eth0 (); not in eth1 or eth2. Table: the row matches ( AND , network ); the default row also matches, but has the shortest mask. Next hop , in eth1. MTU : it passes | indirect forwarding, next hop , through eth1 |
| from eth0, B, DF | Direct: no interface. Table: covers only to , and AND : no match (this is the trap, the address looks like that row); no (third byte ); covers third byte to ( AND ): no. Only the default row matches: next hop , on eth2. | indirect forwarding, next hop , through eth2 |
| from eth1, B, DF | Direct: no interface. Table: and no (third byte ); no; : AND , no. Default: next hop , eth2, MTU and DF: fragmentation | indirect forwarding through eth2, fragments |
Fragmentation of the fourth packet. The datagram has B of header and B of payload. Each fragment can have at most B of data, and the data of every fragment except the last must be a multiple of (the offset is in units of B): , so the maximum is B. Then , rounded up: fragments, the first with B of data ( B in total, offsets ) and the last one with B of data ( B in total, offset ). Even without the multiple-of- rule one would get , so the answer does not depend on it here. Typical errors: comparing with the MTU of eth1 (the incoming interface) instead of eth2 (the output one); forgetting the header in the payload; taking the row for the third packet.
Question 2: addressing plan. The network with netmask is : host bits, addresses from to (Network Layer and IPv4 AddressingThe network layer delivers datagrams host to host through routers (encapsulation, routing, forwarding); an IPv4 address is 32 bits split into a network prefix and a host suffix, and modern classless addressing (CIDR) gives a block of 2^(32-n) addresses from a.b.c.d/n, with network and broadcast addresses computed through the netmask.Network Layer and IPv4 Addressing →). A subnet for hosts needs host addresses plus the network address and the direct broadcast address, that is addresses, and the number of host bits satisfies : is too small, is enough (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 →). So and the netmask has bits: (third byte ).
A subnet must start at a multiple of its size ( addresses, so the third byte must be a multiple of ) and lie inside the (third byte from to ): the first possibility, used by the official solution, is
- network address , netmask ;
- direct broadcast: the last address of the block, third byte , fourth byte : ;
- maximum number of hosts: (from to ).
Any of the aligned blocks of the (, , , ) is a correct answer. Typical errors: choosing (too large, hosts) or (only ); comparing with without adding the two reserved addresses (here it makes no difference, either way, but with hosts it would).
Extra point. Subnetworks of nodes inside the : with the two reserved addresses, addresses are needed, and , so host bits and netmask (each subnet has usable addresses). The number of subnets is , with networks (equivalently, ). Typical error: choosing ( hosts only, fewer than ) or counting .
Self-assessment grid
| Exercise | Points | What must be there for full marks | Typical errors |
|---|---|---|---|
| 1, Question 1 | 4 | for each packet and link; tables of ready, start, end and arrival at each hop with FIFO waiting on , and ; the four results , , , ms | wrong order in the queues; forgetting the wait of on ; mixing bytes and bits |
| 1, Question 2 | 2 | path and bottleneck ( ms); delay ms and ACK ms; ms; MSS | counting the transmission of the ACK; rounding down; using the wrong path |
| 1, Question 3 | 3 | , MSS; windows (one RTT each) then continuous from the sixth; ms | forgetting the handshake ( ms) or the final RTT; slow start beyond |
| 1, Question 4 | 3 | per-link cycles , , ms; is the bottleneck; ms, with the convention on the last ACK stated | using the wrong cycle; summing the cycles of the three links per packet; no pipeline term of ms |
| 2, Question 1 | 5 | networks of the interfaces by AND; direct delivery first; longest prefix match; output interface from the next hop; DF and MTU check; fragments of B (last B) | trap row ; applying the table before the direct test; MTU of the wrong interface; offsets not multiple of |
| 2, Question 2 | 3 | , , , netmask , broadcast , hosts, block inside the | or ; broadcast of the wrong block; block not aligned |
| 2, Extra | 1 | , , subnets | ; dividing by |