---
# System prepended metadata

title: Computer Network HW4

---

# Computer Network HW4

## R24

* 10 interfaces; 4 forwarding tables.

## R25

* 40 / (40 + 20 + 20) = 50%

## P1

* a

  | Destination address | interface |
  | - | - |
  | H3 | 3 |
 
* b
  * No, because forwarding rule is only based on destination address

## P2

* a
  * No, you can only transmit one packet at a time over a shared bus

* b
  * No, as discussed in the text, only one memory read/write can be done at a time over the shared system bus
* c
  * No, in this case the two packets would have to be sent over the same output bus at the
same time, which is not possible

## P3

* a
  * (n-1)D
* b
  * (n-1)D
* c
  * 0

## P4

* The minimal number of time slots needed is 3. The scheduling is as follows.
Slot 1: send X in top input queue, send Y in middle input queue.
Slot 2: send X in middle input queue, send Y in bottom input queue
Slot 3: send Z in bottom input queue. 

* Largest number of slots is still 3. Actually, based on the assumption that a non-empty
input queue is never idle, we see that the first time slot always consists of sending X in
the top input queue and Y in either middle or bottom input queue, and in the second time
slot, we can always send two more datagram, and the last datagram can be sent in third
time slot.

## P5

* a
  | Prefix Match | Link Interface |
  | - | - |
  | 11100000 00000000 | 0 |
  | 11100000 00000001 | 1 |
  | 1110000 | 2 |
  | 1110001 | 3 |
  | others |  3 |
  
* b
  * Prefix match for first address is 5th entry: link interface 3
  * Prefix match for second address is 1st entry: link interface 0
  * Prefix match for third address is 4th entry: link interface 2

## P6

| Destination Address Range | Link Interface |
| - | - |
| 00000000 - 00111111 | 0 |
| 01000000 - 01111111 | 1 |
| 10000000 - 10011111 | 2 |
| 10100000 - 11111111 | 3 |

number of addresses for interface 0 = $2^6 = 64$

number of addresses for interface 1 = $2^6 = 64$

number of addresses for interface 2 = $2^5 = 32$

number of addresses for interface 3 = $2^6 + 2^5 = 96$

## P7

| Destination Address Range | Link Interface |
| - | - |
| 11000000 - 11111111 (64 address) | 0 |
| 10100000 - 10111111 (32 address) | 1 |
| 10000000 - 10011111 (32 address) | 2 |
| 00000000 - 01111111 (128 address) | 3 |

## P8

* 223.1.17.0/26
* 223.1.17.128/25
* 223.1.17.192/28

## P9

* a.b.c.d/26

## P11

* Any IP address in range 192.168.56.128 to 192.168.56.191.
* Four equal size subnets: 192.168.56.32/29, 192.168.56.40/29, 128.119.40.48/29,
192.168.56.56/29.

## P12

* a
  * Subnet A: 214.97.255/24 (256 addresses)
  * Subnet B: 214.97.254.0/25 - 214.97.254.0/29 (128-8 = 120 addresses)
  * Subnet C: 214.97.254.128/25 (128 addresses)
  * Subnet D: 214.97.254.0/31 (2 addresses)
  * Subnet E: 214.97.254.2/31 (2 addresses)
  * Subnet F: 214.97.254.4/30 (4 addresses)

* b
  * Router 1
    | Longest Prefix Match | Outgoing Interface |
    | - | - |
    | 11010110 01100001 11111111 | Subnet A |
    | 11010110 01100001 11111110 0000000 | Subnet D |
    | 11010110 01100001 11111110 000001  | Subnet F |
    
  * Router 2
    | Longest Prefix Match | Outgoing Interface |
    | - | - |
    | 11010110 01100001 11111111 0000000 | Subnet D |
    | 11010110 01100001 11111110 0 | Subnet B |
    | 11010110 01100001 11111110 0000001 | Subnet E |
    
  * Router 3
    | Longest Prefix Match | Outgoing Interface |
    | - | - |
    | 11010110 01100001 11111111 000001 | Subnet F |
    | 11010110 01100001 11111110 0000001 | Subnet E |
    | 11010110 01100001 11111110 1 | Subnet C |
    
## P14

* The maximum size of data field in each fragment = 480 (because there are 20 bytes IP
header). Thus the number of required fragments $=\lceil \frac{1600 - 20}{480} \rceil = 4$

  Each fragment will have Identification number 291. Each fragment except the last one
will be of size 500 bytes (including IP header). The last datagram will be of size 160
bytes (including IP header). The offsets of the 4 fragments will be 0, 60, 120, 180. Each
of the first 3 fragments will have flag=1; the last fragment will have flag=0

## P15

* MP3 file size = 5 million bytes. Assume the data is carried in TCP segments, with each
TCP segment also having 20 bytes of header. Then each datagram can carry 1500-
40=1460 bytes of the MP3 file
Number of datagrams required $=\lceil\frac{5*10^6}{1460}\rceil=3425$.  All but the last datagram will be 1,500
bytes; the last datagram will be 960+40 = 1000 bytes. Note that here there is no
fragmentation – the source host does not create datagrams larger than 1500 bytes, and
these datagrams are smaller than the MTUs of the links. 

## P16

* a
  * Home addresses: 192.168.1.1, 192.168.1.2, 192.168.1.3 with the router interface
being 192.168.1.4 

* b
  * NAT Translation Table
    | WAN Side | LAN Side |
    | - | - |
    | 24.34.112.235, 4000 | 192.168.1.1, 3345 |
    | 24.34.112.235, 4001 | 192.168.1.1, 3346 |
    | 24.34.112.235, 4002 | 192.168.1.2, 3445 |
    | 24.34.112.235, 4003 | 192.168.1.2, 3446 |
    | 24.34.112.235, 4004 | 192.168.1.3, 3545 |
    | 24.34.112.235, 4005 | 192.168.1.3, 3546 |

## P19

* S2 Flow Table 
  | Match | Action |
  | - | - |
  | Ingress Port = 1; IP Src = 10.3.\*.\*; IP Dst = 10.1.\*.\* | Forward (2) |
  | Ingress Port = 2; IP Src = 10.1.\*.\*; IP Dst = 10.3.\*.\* | Forward (1) |
  | Ingress Port = 1; IP Dst = 10.2.0.3 | Forward (3) |
  | Ingress Port = 2; IP Dst = 10.2.0.3 | Forward (3) |
  | Ingress Port = 1; IP Dst = 10.2.0.4 | Forward (4) |
  | Ingress Port = 2; IP Dst = 10.2.0.4 | Forward (4) |
  | Ingress Port = 4 | Forward (3) |
  | Ingress Port = 3 | Forward (4) |
  
## P20

* S2 Flow Table
  | Match | Action |
  | - | - |
  | Ingress Port = 3; IP Dst = 10.1.\*.\* | Forward (2) |
  | Ingress Port = 3; IP Dst = 10.3.\*.\* | Forward (2) |
  | Ingress Port = 4; IP Dst = 10.1.\*.\* | Forward (1) |
  | Ingress Port = 4; IP Dst = 10.3.\*.\* | Forward (1) |
 
## P21

* S1 Flow Table
  | Match | Action |
  | - | - |
  | IP Src = 10.2.\*.\*; IP Dst = 10.1.0.1  | Forward (2) |
  | IP Src = 10.2.\*.\*; IP Dst = 10.1.0.2 | Forward (3) |
  | IP Src = 10.2.\*.\*; IP Dst = 10.3.\*.\* | Forward (1) |
  
* S3 Flow Table
  | Match | Action |
  | - | - |
  | IP Src = 10.2.\*.\*; IP Dst = 10.3.0.6  | Forward (1) |
  | IP Src = 10.2.\*.\*; IP Dst = 10.3.0.5 | Forward (2) |
  | IP Src = 10.2.\*.\*; IP Dst = 10.1.\*.\* | Forward (3) |

## P22

* S2 Flow Table
  | Match | Action |
  | - | - |
  | IP Src = 10.1.0.1; IP Dst = 10.2.0.3 | Forward (3) |
  | IP Src = 10.1.0.1; IP Dst = 10.2.0.4 | Forward (4) |
  | IP Src = 10.3.0.6; IP Dst = 10.2.0.3 | Forward (3) |
  | IP Src = 10.3.0.6; IP Dst = 10.2.0.4 | Forward (4) |
  
* S2 Flow Table
  | Match | Action |
  | - | - |
  | IP Src =\*.\*.\*.\*; IP Dst = 10.2.0.3; port = TCP | Forward (3) |
  | IP Src =\*.\*.\*.\*; IP Dst = 10.2.0.4; port = TCP | Forward (4) |
  
* S2 Flow Table
  | Match | Action |
  | - | - |
  | IP Src =\*.\*.\*.\*; IP Dst = 10.2.0.3 | Forward (3) |
  
* S2 Flow Table
  | Match | Action |
  | - | - |
  | IP Src = 10.1.0.1; IP Dst = 10.2.0.3; port = UDP  | Forward (3) |