Download HW1 Solution

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

TCP congestion control wikipedia , lookup

Airborne Networking wikipedia , lookup

Drift plus penalty wikipedia , lookup

Computer network wikipedia , lookup

Net bias wikipedia , lookup

Asynchronous Transfer Mode wikipedia , lookup

Network tap wikipedia , lookup

AppleTalk wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Backpressure routing wikipedia , lookup

Point-to-Point Protocol over Ethernet wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Multiprotocol Label Switching wikipedia , lookup

CAN bus wikipedia , lookup

Serial digital interface wikipedia , lookup

Spanning Tree Protocol wikipedia , lookup

RapidIO wikipedia , lookup

Deep packet inspection wikipedia , lookup

Routing in delay-tolerant networking wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Wake-on-LAN wikipedia , lookup

IEEE 1355 wikipedia , lookup

Transcript
Problem Set 1, CS/EE 143, Fall 2016
Prof. Steven Low. TA: Daniel Guo
∗
Due date: October 11 on class
Problems marked as “Exercise” are for exercise only and DO NOT contribute to the score. Problems
marked as “Challenge” are optional, and contribute to the score as bonus points. The total contribution
from homework to the course grade is capped by 50%.
Solutions for assignments and exercise problems on covered topics will be posted after the assignments
are graded.
0
Survey Problem
How long did this assignment take?
1
Introduction to Internet
1.1
W&P, P1.1 (Exercise)
How many hosts can one have on the Internet if each one needs a distinct IP address?
[Solution] Since the IP(v4) address is 4-byte, there can potentially be 232 distinct addresses.
1.2
Adapted from W&P, P1.3
8 Points. Imagine that all routers have 17 ports. There are 216 hosts to be connected. Assume you
can organize the hosts and routers any way you like. Your goal is to (i) design the network structure so
as to minimize the number of routers required, and (ii) based on the network design in (i), assign the
addresses to minimize the size (number of entries) of the routing table required in each router.
(a) 4 Points. Describe your network structure and explain why your design gives the minimum number
of routers.
(b) 4 Points. Describe your scheme for assigning addresses and routing. Explain why your design
gives the minimum routing table size in each router.
There exist theoretical lower bounds on the number of routers and the size of the routing table. Point
out these lower bounds explicitly in your solution, and use them to verify your design.
[Solution] The routers will be arranged in a tree topology, with each of 16 of the ports representing
the next half-byte in the network address. The 17th port would be the link to the parent router. The
∗ Courtesy
to: Changhong Zhao ([email protected])
1
root router would have a dead 17th port, and so there would be a routing table of size 16 on the first
router, and 17 on every other router. This would be of the form:
• (prefix, halfbyte, unmatched) routes to the port indexed by halfbyte, where prefix is the total
specified address on the parent router that points to this router on its 17th port;
• default route goes to port 17;
• the root router is just: (halfbyte, unmatched) routes to the port indexed by halfbyte.
The total number of routers we use is 212 + 28 + 24 + 20 = 4369.
This is optimal because:
(a) Consider all the routers and hosts as vertex and links as edge. Then in the result graph, it should
be a tree, otherwise we can further remove edges and/or vertexes to simplify the graph. Assume we
have N routers. For each router, we have 17 ports. For each host, we have 1 port. The total number
of edges should be no less than the total number of vertex minus 1, which is (N + 216 − 1) to provide
connectivity. Also we have the number of edges should be no larger than half of the total ports, which
is (17N + 216 )/2. Hence we have (17N + 216 )/2 ≥ (N + 216 − 1), so N ≥ 4368.9.
(b) The routing table at every router except the root has only 17 entries, which is minimum with a
router fanout of 17.
1.3
W&P, P1.4 (Exercise)
Assume that a host A in Berkeley sends packets with a bit rate of 100Mbps to a host B in Boston.
Assume also that it takes 130ms for the first acknowledgment to come back after A sends the first
packet. Say that A sends one packet of 1Kbyte and then waits for an acknowledgment before sending
the next packet, and so on. What is the long-term average bit rate of the connection? Assume now
that A sends N packets before it waits for the first acknowledgment. Express the long-term average bit
rate of the connection as a function of N . [Note: 1 Mbps = 106 bits per second; 1 ms = 1 millisecond
= 10−3 second.]
[Solution] It takes 1KB/100Mbps = 0.08ms to transmit one packet. When N = 1, the connection
transfers 1 packet per RTT, i.e., 1KB per 130.08ms ∼ 130ms. This represents a throughput of 1KB/0.13s
= 61.5 kbps. (If you use 1KB = 1,024 bits instead of 1,000 bits, then the throughput will be 63 kbps.)
It is OK to ignore the packet transmission time (0.08ms) since it is order of magnitude smaller than
the propagation delay of 130ms.
When N is small enough (see below), the sender sends N packets, and then stops and waits for the first
ACK which arrives after one RTT of 130.08ms ∼ 130ms. Therefore the throughput is N KB/130ms =
61.5N kbps.
1 KB
Let K be the largest integer such that K 100Mbps
≤ 130.08 ms, i.e., K = 1, 626. When N ≥ K, the
sender would have already received the first ACK when it finishes transmitting N packets, and therefore
can immediately transmit the N + 1st packet. In this case, the throughput is 100Mbps.
In summary, the throughput is:
(
61.5N kbps
throughput =
100 Mbps
1.4
if N < 1, 626
if N ≥ 1, 626
= min {61.5N kbps, 100 Mbps}
B&G, 2.9: Horizontal and vertical parity checks
4 Points. A horizontal and vertical parity check of size K by L takes (K − 1) binary sequences each of
2
length (L − 1) bits and outputs K binary sequences each of length L bits such that if these sequences
are arranged into an K by L matrix, then each row and each column will have an even number of 1’s.
The parity check works as follows. To send (K − 1) data sequences each of length (L − 1) bits, the
sender sends the K by L matrix. The receiver checks the parity of each row and each column. If there
is any row or column that has odd parity, an error is detected.
(a) 2 Points. Give an example of a pattern of six errors that cannot be detected by horizontal and
vertical parity checks.
(b) 2 Points. Find the number of different patterns of four errors that will not be detected by horizontal
and vertical parity checks.
[Solution] (a) Any 6 bit errors in the following entry of the K × L matrix will not be detected: (i1 , j1 ),
(i1 , j2 ), (i2 , j2 ), (i2 , j3 ), (i3 , j3 ), (i3 , j1 ), because every row and every column has zero or 2 bit errors
which maintains valid parity of the matrix.
(b) Any 4 bit errors distributed such that every row and every column has zero or 2 bit errors will not
be detected. There are
1
K
L
= KL(K − 1)(L − 1)
2
2
4
such configurations.
1.5
Adapted from B&G, P3.1 (Exercise)
Customers arrive at a fast food restaurant at a rate of five per minute and wait to receive their order
for an average of 10 minutes. Customers eat in the restaurant with probability 1/2 and take out their
order without eating with probability 1/2. A meal requires an average of 20 minutes. What is the
average number of customers in the restaurant?
[Solution] For customers who take out their orders, the average time spent in the restaurant is 10
minutes; for those who eat in, the average time spent is 30 minutes. Therefore, the average time spent
in the restaurant over all customers equals 20 minutes. Applying Littles law, this means the average
number of customers in the restaurant equals 20 × 5 = 100.
1.6
Capacity constrained network design
3 Points. Two nodes A and B need to be connected via a communication link. On average, it is
estimated that 1000 packets will arrive at A destined for B each second, each packet having an average
size of 1 Kbyte. There are two design choices: (i) you build a single link with rate 10Mbps between
A and B, (ii) you build two parallel 5Mbps links, and send a packet arriving at A randomly via either
link. Assume each link is equipped with an infinite sized buffer. Assuming the M/M/1 formula for the
delay on a link, compute the average packet delay in each case. Which design choice is better? Can
you explain why? You may ignore packet propagation times.
[Solution] In case (i), the link service rate equals 10Mbps/8Kb = 1250 pkts/sec. Therefore, the mean
delay equals 1/(1250-1000) = 4 ms.
In case (ii), each link has a service rate of 625 pkts/sec, and sees an arrival rate of 500 pkts/sec. The
mean delay therefore is 1/(625-500) = 8ms.
The first design choice is better since if you double the arrival rate as well as the service rate in an
M/M/1 queue, the average waiting time decreases by a factor of 1/2.
3
1.7
W&P: P2.6 (Exercise)
Consider a router in the backbone of the Internet. Assume that the router has 24 ports, each attached
to a 1Gbps link. Say that each link is used at 15% of its capacity by connections that have an average
throughput of 200kbps. How many connections go through the router at any given time? Say that the
connections last an average of 1 minute. How many new connections are set up that go through the
router in any given second, on average?
[Solution] Aggregate average throughput per link is
1Gbps × 15% = 150Mbps.
Hence average number of connections per link is 150Mbps/200kbps = 750, and average number of
connections at the router is 750 × 24 = 18, 000.
Then Littles Law implies the number of new connections set up at the router:
λ = N/T = 18, 000/60 = 300 connections/sec.
1.8
W&P, P2.7
4 Points. We would like to transfer 20 KB (1 Byte=8 bits) file across a network from node A to node
F. Packets have a length of 1 KB (neglecting header). The path from node A to node F passes through
5 links, and 4 intermediate nodes. Each of the links is a 10 km optical fiber with a rate of 10 Mbps
(assume speed of light in optical fiber is 2.0 × 108 m/s). The 4 intermediate nodes are store-and-forward
devices, and each intermediate node must perform a 50 µs routing table look up after receiving a packet
before it can begin sending it on the outgoing link. How long does it take to send the entire file across
the network?
[Solution] Look at the time diagram Figure 1.
Figure 1: Time diagram of packets transferred through 5 links and 4 intermediate nodes.
4
Let:
link propagation delay = T1 = 10 km / (2 × 108 m/s) = 0.05 ms
packet transmission time = T2 = 1kB/10Mbps = 0.8 ms
node processing time = T3 = 0.05 ms.
Assume A starts transmission at time 0, then:
The time at which B receives and finishes processing first packet is TB = T1 + T2 + T3 .
The time at which C receives and finishes processing first packet is TC = TB + T1 + T2 + T3 = 2TB .
The time at which D receives and finishes processing first packet is TD = 3TB .
The time at which F receives the first packet is TF = 4TB + T1 + T2 since F does not need to look up
the routing table.
Therefore, the time at which F receives all 20 packets is
TF + 19T2
1.9
=
4(T1 + T2 + T3 ) + T1 + 20T2
=
5T1 + 24T2 + 4T3
=
5 × 0.05 + 24 × 0.8 + 4 × 0.05 = 19.65 ms.
W&P, P2.9
3 Points. Consider the case of GSM cell phones. GSM operates at 270.88 Kbps and uses a spectrum
spanning 200 KHz. What is the theoretical SNR (in dB) that these phones need for operation? In
reality, the phones use a SNR of 10 dB. Use Shannons theorem to calculate the theoretical capacity
of the channel, under this signal-to-noise ratio. How does the utilized capacity compare with the
theoretical capacity?
[Solution]
(a) By Shannon’s formula C = W log2 (1 + SNR), we have
270.88kbps = 200kHz log2 (1 + SNR).
Hence, required SNR is 2
270.88
200
− 1 = 1.557 = 10 log10 (1.557) dB = 1.9 dB.
(b) With SNR = 10 dB, Shannon capacity = 200kHz log2 (1 + 10) = 692 kbps. Therefore, the utilization
is 270.88/692 = 39%.
1.10
IP addresses (Exercise)
Consider an IPv4 subnet with private IP address space 166.111.8.0/24. If each IP interface in the subnet
needs a distinct IP address, then how many IP interfaces can there be in the subnet? [Hint: to obtain
the right answer, please look up what is a broadcast address online.]
[Solution] There is a total of 28 = 256 IP addresses in this subnet. One of these IP addresses (the one
whose last 8 digits are all 1) should be reserved for broadcasting, leaving 255 IP addresses for physical
interfaces. Hence, a maximum number of 255 IP interfaces is allowed in the subnet.
5
2
Ethernet
2.1
W&P, P3.2 (Exercise)
Consider the Slotted ALOHA MAC protocol. There are N nodes sharing a medium, and time is divided
into slots. Each packet takes up a single slot. If a node has a packet to send, it attempts transmission
with a certain probability. The transmission succeeds if no other node attempts transmission in that
slot.
Now, suppose that we want to give differentiated services to these nodes, i.e., we want different nodes
to get a different share of the medium. The scheme we choose works as follows: If node i has a packet
to send, it will try to send the packet with probability pi . Assume that every node has a packet to
send all times. In such a situation, will the nodes indeed get a share of the medium in the ratio of their
probability of access?
[Solution] Consider a given slot. Since every node has a packet to send and transmits with probability
pi , the probability of success for any node i is
Y
pi
β
pi (1 − pj ) =
1 − pi
j6=i
where β :=
QN
j=1 (1
− pj ) is independent of any user j.
Therefore, the share of the media any user i gets is proportional to
2.2
pi
1−pi ,
not to pi .
W&P, P3.4
4 Points. Consider a commercial 10 Mbps Ethernet configuration with one hub (i.e., all end stations
are in a single collision domain).
(a) 2 Point. Find the Ethernet efficiency for transporting 512 byte packets (including Ethernet overhead) assuming that the propagation delay between the communicating end stations is always 25.6 µs,
and that there are many pairs of end stations trying to communicate.
(b) 2 Points. Recall that the maximum efficiency of Slotted Aloha is 1/e. Find the threshold for the
frame size (including Ethernet overhead) such that Ethernet is more efficient than Slotted Aloha if the
fixed frame size is larger than this threshold. Explain why Ethernet becomes less efficient as the frame
size becomes smaller.
[Solution]
(a) Following the derivation of efficiency of the text, we have
η=
1
1 + 3.4A
A :=
PROP
.
TRANS
where
Now
TRANS = packet transmission time =
Therefore A =
25.6 µs
409.6 µs
512 × 8 bits
= 409.6 µs.
10 Mbps
= 0.0625, and hence efficiency
η=
1
= 82%.
1 + 3.4 × 0.0625
6
(b) Let the Ethernet frame size be s bits, then
TRANS =
and
s bits
s
=
µs
10 Mbps
10
A=
PROP
10PROP
=
.
TRANS
s
η=
1
1 + 3.4 ×
We want s such that
10PROP
s
≥
1
e
which implies
s≥
34 PROP
34 × 25.6
=
= 506.6 bits.
e−1
2.718 − 1
A smaller frame size implies a larger A, which implies a smaller efficiency. Note that on average, an
interval of length 2(e − 1)PROP gets wasted between successful transmissions. A smaller frame size
implies therefore that the fraction of time spent transmitting data successfully is smaller.
2.3
W&P, P3.5 (Exercise)
Ethernet standards require a minimum frame size of 512 bits in order to ensure that a node can detect
any possible collision while it is still transmitting. This corresponds to the number of bits that can be
transmitted at 10 Mbps in one roundtrip time. It only takes one propagation delay, however, for the
first bit of an Ethernet frame to traverse the entire length of the network, and during this time, 256 bits
are transmitted. Why, then, is it necessary that the minimum frame size be 512 bits instead of 256?
[Solution] A station detects collision by listening and comparing what it hears on the wire with what
it transmits. Therefore, if it transmits for a round-trip time, it can compare the signal it detects on
the wire with what it just transmitted onto the wire, and a collision is detected if they are different. If
it transmits only for 12 RTT, it would have stopped transmitting before the signal from the other end
reaches it, and hence miss the detection. This is illustrated in Figure 3.
2.4
Switch vs Hub, W&P, P3.7
6 Points. In the network shown in Figure 4, all of the devices want to transmit at an average rate
of R Mbps, with equal amounts of traffic going to every other node. Assume that all of the links are
half-duplex and operate at 100Mbps and that the medium access control protocol is perfectly efficient.
Thus, each link can only be used in one direction at a time, at 100Mbps. There is no delay to switch
from one direction to the other.
1. 3 Points. What is the maximum value of R?
2. 3 Points. The hub is now replaced with another switch. What is the maximum value of R now?
[Solution] Denote the flows on links as in Figure 5.
(a) There are two potential bottlenecks: the switch-hub link or the hub.
Switch-hub link bottleneck:
Each node generates 7 flows, each of rate R/7, to each of the other nodes. Therefore the rate crossing
the link from switch to link is
R
16
X=
×4×4=
R.
7
7
7
Figure 2: Diagram demonstrating why the minimum frame should be transmitted for RTT in order to
successfully detect collision.
Figure 3: An ethernet. Each circle represents a host, that wants to send an aggregate of R Mbps traffic,
evenly to other hosts.
Figure 4: Flows in the hub-switch ethernet.
8
The rate crossing the link from hub to switch is
Y = 4R
since the hub repeats all input flows on all links except from they come from. Then we have
X + Y ≤ 100 Mbps =⇒ R ≤ 15.9 Mbps.
Hub bottleneck:
Take any link, say, from hub to node A. The total rate of traffic on this link is the sum of all input
traffic to the link except its own:
SA = 3R + X = (3 +
16
37
)R =
R.
7
7
This traffic shares the link with the traffic from A to hub, which has the rate R. Therefore,
SA + R ≤ 100 Mbps =⇒ (
37
+ 1)R ≤ 100 Mbps =⇒ R ≤ 15.9 Mbps.
7
Hence, both bottlenecks impose the same upper bound for R.
(b) When the hub is replace with a switch, then X = Y and the switch-switch link is the only bottleneck.
2X =
2.5
32
R ≤ 100 Mbps =⇒ R ≤ 21.875 Mbps.
7
Spanning Tree Protocol, W&P, P3.6
6 Points. Consider the network topology shown in Figure 6, where 1, 2, . . . , 8 denote 8 switches
interconnecting 9 Ethernets.
Figure 5: Each circle represents a switch, interconnecting 9 Ethernets.
1. 3 Points. Determine which links get deactivated after the Spanning Tree protocol runs, and
indicate them on the diagram by putting a small X through the deactivated links.
2. 3 Points. A disgruntled employee wishes to disrupt the network, so she plans on unplugging
central bridge switch 8. How does this affect the spanning tree and the paths that Ethernet
packets follow?
9
[Solution]
(a) The STP operates as follows:
1. The bridge with the smallest ID will be the root (Bridge 1).
2. Each bridge finds a shortest path to the root, where link cost is simply hop count (# bridges en
route to root). The port on a bridge through which it roots is called a root port (RP).
3. A tie is broken by choosing the port / path where the next hop (bridge) has a smallest ID.
4. Each LAN segment will choose a bridge towards the root; the port on the bridge thats chosen by
the LAN segment is called a designated port (DP).
5. A tie is broken by the LAN choosing a bridge with the smallest ID.
In Figure 7:
BP: blocked port
DP: designated port (incoming chosen by LAN)
RP: root port (outgoing chosen by bridge).
Figure 6: Spanning Tree Protocol.
Note that LAN chooses Bridge 2 over 8 because of smaller bridge ID.
(b) Since Bridge 8 has no DP (it only has 1 RP which will be used by Bridge 8 to send / receive from
the root; the rest are all blocked ports), no LAN segment will use Bridge 8 to send or receive Ethernet
10
frames. Therefore, removing Bridge 8 has no effect on the spanning tree, except that it has one fewer
leaf node now.
2.6
Aloha (Challenge)
(a) (Equal Share). Assume that n hosts share a medium using the slotted ALOHA protocol: at
every time slot, each host attempts to send a packet with probability p. A host succeeds to send a
packet at a given time slot if and only if it is the only host that sends a packet at that time slot.
1. 2 Points. What is the probability that a host sends a packet successfully at a give time slot?
2. 2 Points. What is the probability P{a packet sent} that a packet be sent at a given time slot?
3. 4 Points. What choice of p maximizes the probability P{a packet sent}? How does this maximum
probability behave as n → ∞?
(b) (Unequal Share). Assume that n hosts share a medium using the slotted ALOHA protocol, but
at every time slot, each host attempts to send a packet with a different probability. More specifically,
let N := {1, . . . , n} denote the collection of hosts and assume that host i attempts to send a packet
with probability pi ∈ (0, 1) at every time slot for i = 1, . . . , n.
1. 2 Points. What is the probability Pi := P{i sends a packet successfully} that host i ∈ N sends
a packet successfully at a given time slot?
2. 2 Points. What is the ratio P1 : P2 : P3 : · · · : Pn ? This ratio characterizes the share of medium
among the hosts. Is the share of medium proportional to the probabilities pi that hosts attempt
to send packets, i.e., is the ratio P1 : P2 : P3 : · · · : Pn equal to p1 : p2 : p3 : · · · : pn ?
Pn
Pn
3. 5 Points. Assume i=1 pi = 1 and let P := i=1 Pi denote the probability that a packet gets
successfully transmitted at a given time slot. Prove that (p1 , p2 , p3 , . . . , pn ) = (1/n, 1/n, . . . , 1/n)
minimizes P , i.e., (1/n, 1/n, . . . , 1/n) is the solution to
min
n
X
i=1
pi
Y
(1 − pj )
j6=i
s.t. 0 ≤ pi ≤ 1,
n
X
pi = 1.
i = 1, . . . , n;
i=1
It means that equal share of the medium minimizes the throughput.
[Solution]
(a) Answers given in the lecture/textbook.
(b)
1.
Pi = p i
Y
(1 − pj )
j6=i
2.
p2
p3
pn
p1
:
:
: ··· :
1 − p1 1 − p2 1 − p3
1 − pn
This is not proportional to the attempting probabilities in general.
P 1 : P2 : P3 : · · · : Pn =
11
3. Consider the nontrivial case where n ≥ 3. Let P (p) :=
p = (p1 , . . . , pn ) 6= ( n1 , . . . , n1 ) which satisfies
n
X
pi = 1
Pn
i=1
pi
Q
j6=i (1
− pj ). Consider any
and
i=1
0 ≤ pi ≤ 1,
∀i
Let M := maxi=1,...,n pi , and m := mini=1,...,n pi . Hence we have M > n1 > m. Without loss of
M +m
generality, let p1 = M and p2 = m, then p = (M, m, . . . , pn ). Let p0 = ( M +m
2 ,
2 , . . . , pn ). It
0
is sufficient to show P (p) > P (p ). We have


n
n


Y
X
Y
P (p) − P (p0 ) =
[M (1 − m) + (1 − M )m]
(1 − pj ) + (1 − m)(1 − M )
pi
(1 − pj )


j=3
i=3
j6=1,2,i


n
n


Y
M +m
M +m Y
M +m 2X
(1 −
)
(1 − pj ) + (1 −
)
pi
(1 − pj )
− 2×


2
2
2
j=3
i=3
j6=1,2,i


n
n
Y
X
Y
(M + m)2
(1 − pj ) −
pi
(1 − pj )
− M m 2
=
4
j=3
i=3
j6=1,2,i


n
n
n
X
Y
X
Y
(M + m)2
>
pi
(1 − pj ) −
pi
(1 − pj )
(1)
− M m 2
4
i=3
j=3
i=3
j6=1,2,i


n
n
X
Y
X
Y
(M + m)2
pi (1 − pi )
(1 − pj ) −
pi
(1 − pj )
=
− M m 2
4
i=3
i=3
j6=1,2,i
j6=1,2,i


n
X
Y
(M + m)2
=
(1 − pj )
− M m  (1 − 2pi )pi
4
i=3
j6=1,2,i
≥ 0
(2)
Pn
where the inequality in (1) is because (M + m)2 − 4M m > 0 for M 6= m and i=3 pi < 1, and
the inequality in (2) is because pi ≤ 21 since otherwise pi > M , which leads to a contradiction.
12