天天看点

comp3331-9331-16s2-midterm复习

文章目录

  • ​​http1.0和http1.1​​
  • ​​服务器​​
  • ​​p2p​​
  • ​​使用udp的协议​​
  • ​​web cache​​
  • ​​TCP和isn​​
  • ​​google的域名污染​​
  • ​​p2p​​
  • ​​rdt(可靠数据连接)​​
  • ​​法1 使用定义计算​​
  • ​​法2​​
  • ​​sequence number​​
  • ​​GBN的发送窗口大小,应该小于等于7,即最大窗口大小<=(2^n)-1​​
  • ​​选择重传SR的发送窗口大小,应该小于等于4,即最大窗口大小<=2^(n-1)​​
  • ​​再次理解窗口w size和序号n​​
  • ​​(c)​​
  • ​​电路交换和分组交换​​
  • ​​16s2真题​​

http1.0和http1.1

comp3331-9331-16s2-midterm复习
  • 1个tcp的连接就是1个tcp的socket
  • socket和rtt的区别
  • web sever的additional welcome socket.

服务器

和客户端编程相比,服务器编程就要复杂一些。

服务器进程首先要绑定一个端口并监听来自其他客户端的连接。如果某个客户端连接过来了,服务器就与该客户端建立Socket连接,随后的通信就靠这个Socket连接了。

所以,服务器会打开固定端口(比如80)监听,每来一个客户端连接,就创建该Socket连接。由于服务器会有大量来自客户端的连接,所以,服务器要能够区分一个Socket连接是和哪个客户端绑定的。一个Socket依赖4项:服务器地址、服务器端口、客户端地址、客户端端口来唯一确定一个Socket。

但是服务器还需要同时响应多个客户端的请求,所以,每个连接都需要一个新的进程或者新的线程来处理,否则,服务器一次就只能服务一个客户端了。

comp3331-9331-16s2-midterm复习

p2p

comp3331-9331-16s2-midterm复习

使用udp的协议

comp3331-9331-16s2-midterm复习

There’s a general rule:

If you haven’t got a reason why TCP won’t work, then use TCP.

If you think you’ve got a reason that TCP won’t work, you’re probably wrong.

  • dns:DNS has always been designed to use both UDP and TCP port 53 from the start 1 , with UDP being the default, and fall back to using TCP when it is unable to communicate on UDP, typically when the packet size is too large to push through in a single UDP packet.
  • BitTorrent is TCP-based, and use a port from the random ports range. So, there is no port officially reserved for Torrent, but you can be sure that it is TCP. There is no UDP traffic, as it is a peer to peer file transfer so it requires reliability. It uses TCP as its transport protocol and uses UDP for control packets. (​

    ​The *BitTorrent* protocol has been extended to use *UDP* with the uTP - uTorrent transport protocol (BEP29) extension.​

    ​)
  • Email uses TCP. Either POP (TCP/25) or IMAP (TCP/143) or IMAP over SSL (TCP/993).
  • FPS游戏:同学吃鸡嘛?速度
  • http,ftp

web cache

comp3331-9331-16s2-midterm复习
  1. http明确支持缓存
  2. 动态生成的页面,不可以缓存。(拿我最近做的一个爬虫展示一下)

TCP和isn

comp3331-9331-16s2-midterm复习

为什么syn和fin消耗一个序列?

因为(龟腚) 😏

实际上payload或者说data是没有传送一个字节的。必须通过ack的number变化,来知道成功收到了syn或者fin,如果fin不占用一个字节,回复fin的ack和和之前最后一次传的包,number一样。那到底是发之前的包?还是要关闭连接呢?

google的域名污染

comp3331-9331-16s2-midterm复习
  1. Can you precisely outline the steps that Alice would have to undertake to launch the

    aforementioned attack? You must explicitly provide the DNS records that she will have to configure and explicitly state which servers these records must be stored/updated in.

www.searchzilla.com 9.9.9.9 A long-TTL
www.searchzilla.com ns1.google.com NS long-TTL
ns1.google.com 9.9.9.10 A long-TTL
www.google.com 9.9.9.9 A long-TTL      
comp3331-9331-16s2-midterm复习
  1. What must a robust DNS server implementation do to counter this attack?
comp3331-9331-16s2-midterm复习

p2p

comp3331-9331-16s2-midterm复习

答案太长了,我们直接看16s2

前提条件:服务器的下载可以忽略不计。

C/S模式:只有服务器上传,每个客户端下载。

所以服务器要上传N份,以的速率,每个客户端下载一份,最小带宽的客户端是客户端的限制。

comp3331-9331-16s2-midterm复习

p2p模式:

是服务器的上传时间

表示最小带宽的下载时间

整体的上传时间。如果有k个用户离开了,显然:

comp3331-9331-16s2-midterm复习

rdt(可靠数据连接)

  • through:Again, network throughput refers to​

    ​how much data can be transferred from source to destination within a given timeframe.​

    ​Throughput measures how many packets arrive at their destinations successfully. For the most part, throughput capacity is measured in bits per second, but it can also be measured in data per second.
  • utilisation:在一段时间内使用线路的时间占比。
  • bandwith:线路能提供的服务
  • bandwith是理论上的,throughput是实际上的。在单位时间从源到目的主机传输的bit数。
comp3331-9331-16s2-midterm复习

window size:一次可以同时发送多少个包

使用率的计算:如图,注意找对周期。

throughput:

法1 使用定义计算

法2

实际带宽(吞吐量)/理论带宽 = 使用率

sequence number

rdt

stop-and-wait

pipeline

gbn

sr

理解gbn和rs之前,需要理解滑动窗口协议

sw = 1 rw =1 s-w

sw >1 rw=1 gbn

sw>1 rw>1 sr

在发送方,有n个bit作为sequence number,每个包的编号,(例如:如果是4个bit,则有编号,0000,0001,…,1111,这些编号为0或者1表示发送没发送

0 ~ )

窗口大小的原则:可以有n个bit作为sequence的number,但是相应的窗口大小为:

comp3331-9331-16s2-midterm复习

利用 和

为什么?

GBN的发送窗口大小,应该小于等于7,即最大窗口大小<=(2^n)-1

先看如果大于7,会是什么情况:假设窗口大小等于8:

发送方给接收方发送了帧编号0A,1A,2A,3A,4A,5A,6A,7A,共计8个帧,接收方均收到,并处理后提交给网络层,并向发送方回馈ACK 0A~7A,并期待下一轮的8个帧0B~7B      

然而回馈电路被雷劈了,所以ACK全部丢失,接收方等了好久,没等到确认,认定自己工作失误,发出去的东西没有到达地点,于是重发了之前的0A~7A号帧

但是接收方不知道自己的信道被劈了啊!他还以为自己的ACK(A系列)被对方接收到了,还在喜滋滋等着第二波新帧,没想到来的居然还是上一批老人物。但是接收方脸盲啊,不把熟人当兄弟,一看来的还是八位大爷,打头的正好编号和自己需要的一样,也看不出是不是新来的,就还是全部接收并传给了网络层

这不就出错了吗!

所以我们得想办法防止这种事出现:

窗口如果等于7,就不会有这种狗东行为出现:

发送方发出0A,1A,2A,3A,4A,5A,6A共计7个帧,接收方还是接收并发送A系列的ACK,且依旧全部丢失,发送方超时重传0A~6A

但是这次情况不同了!

接收方发现来的人虽然数量没变,但是编号对不上了啊!自己等的带队的是7爷,怎么来的是0爷?来的人不对,混日子的不是我的兄弟,不收!

于是数据传输断裂,但至少不会出错了……最后黑锅由闪电完美背起,鼓掌

选择重传SR的发送窗口大小,应该小于等于4,即最大窗口大小<=2^(n-1)

为什么同样是滑动窗口,你GBN的就可以比我大,我就得比你小?你说你演的比我好,要不你上来咱们比比?刚刚我来的时候还有小朋友问我……不对,串场了

问题的关键在于:选择重传是可以“跳着传”的。

现在我们看,如果SR和GBN的窗口大小一样,会是什么情况

在同样遇到帧丢失的时候,假设我们发送了0~6号帧,并且倒霉的丢掉了2号帧,GBN协议里,接收方没有收到2号帧,就不会发送2号帧的ACK,发送方直接把2到6号全部重传,接收方也不需要担心会不会有重复数据,因为第一批来的3号到6号帧因为少了2号帧,在接收方看来就是一堆废物,直接给丢了去换新的,充分体现了某资本主义大国的浪费作风,需要点名批评。

现在看SR的协议

SR的协议有两个特点:

1.不需要重发错误帧到结尾帧的所有帧,只需要重发错误的2号帧即可,充分体现了社会主义的勤俭节约习惯,点名表扬

2.如果2号帧没有到,那么3~6号虽然会被保留下来,但也不会被传到网络层。一个帧如果能够被传到网络层,前提是比他小的序号的帧都已经被传输到网络层了,类似“让小孩先走”的道理。

所以在2号帧丢失这个问题上,SR和GBN似乎都不会出太大问题

但是还有一种情况:如果和(一)中的问题一样,接收方的ACK全部丢失,会是什么情况?

GBN中,由于直接丢弃+重传,不会受到影响。

但是SR似乎没有这么乐观:假设接收方已经将0A到6A号传给了网络层,但是ACK全部丢失,那么发送方只好重传0A到6A了

但是接收方等待的是7A,0B,1B,2B,3B,4B,5B,一看发送方发来的东西,虽然不是完美贴合我想要的七个葫芦娃们,但是似乎有6个也是编号0到5的……不管来的·是小矮人还是葫芦娃,只要编号对上了,就是我的人……呸,我的帧了。

于是0A到5A又一次被纳入后宫,数据出错

但是如果发送方窗口只有四个呢?

发送方发来了0A到3A,依然没有收到ACK,重发0A~3A

接收方苦等4到7的编号帧,一看发来的一个都没有符合的,不收不收

皆大欢喜,完美!

再次理解窗口w size和序号n

nbit可以组合出 这样个数,但是,实际窗口应该比少,先利用前面的一部分,再利用后面的一部分。循环往复

(c)

只有第4个和第12个包,丢了。

gbn: 4bit, 提供 16个数字,窗口设置为8,所以只使用0-8,1p0️⃣ 8p7️⃣ 9p8️⃣ 10p:0:11p1️⃣p2️⃣13p7️⃣

包序号为# 3以及第包,序号为(2)

comp3331-9331-16s2-midterm复习

电路交换和分组交换

comp3331-9331-16s2-midterm复习

分组交换

16s2真题

  1. DNS
  2. Bittorrent (for file transfer)
  3. E-mail
  4. First person shooter games
  5. HTTP
  6. FTP

    (e) Which of the following is/are true about web caches? (circle ALL that are correct)

  7. A web cache is a network entity that satisfies HTTP requests from clients.
  8. A web cache is both a client and a server at the same time.
  9. HTTP does not explicitly support caching or cache consistency.
  10. All HTTP objects are cacheable.

    (f) Using TCP, a sender has sent out a total of ten data segments, each containing 1000 bytes of

    payload. Assume that the sender’s initial sequence number (ISN) is 5000. After the sender receives a

    packet from the receiver with ACK number 8000, how many TCP data segments (denote their

    sequence numbers), if any does the sender know that the receiver definitely received?

    Answer and short explanation:

    4

    Question 2 – The Poisoning of Google (3 marks)

    Alice works at a search engine startup called Searchzilla (www.searchzilla.com) whose main

    competitor is Google (www.google.com). She would like to crush her competitor in the “non-

    traditional” way by messing up with DNS servers. Recalling from her COMP3331/9331 class that

    DNS servers cache A and NS records from DNS replies, Alice realises she can configure the

    authoritative DNS server of Searchzilla (nspowned.searchzilla.com) to return incorrect results for

    arbitrary domains. If other DNS servers caches Alice’s malicious results, they will return bad results.

    Help Alice complete her master plan to hijack Google’s domain name by writing down exactly what

    Alice’s name server returns upon receiving a DNS query. To be precise, what Alice wants to achieve

    is that when anyone on the Internet types www.google.com in their browser, they should be

    presented with the Searchzilla webpage rather than Google’s. Assume that the Searchzilla web server

    (www.searchzilla.com) is running on 9.9.9.9 and the authoritative name server for Searchzilla,

    nspowned.searchzilla.com is running on 9.9.9.10. Recall that DNS records are of the format <name,

    value, type, ttl>.

    (a) Can you precisely outline the steps that Alice would have to undertake to launch the

    aforementioned attack? You must explicitly provide the DNS records that she will have to configure

    and explicitly state which servers these records must be stored/updated in.

    Answer:

    5

    (b) What must a robust DNS server implementation do to counter this attack?

    Answer:

    Question 3 - Oh why so selfish? (2 marks)

    Consider the peer-to-peer file distribution problem illustrated in the Figure below. The same problem

    has been discussed in the lecture slides as well as in the text. In this problem, there are N peers, and

    peer i has an upload transmission rate of ui bps and a download transmission rate of di bps. The

    upload rate for the server is us bps. The text (and lecture slides) shows that a lower bound for the

    minimum time for all the N peers to download a specific file of size F bits, using peer-to-peer

    distribution, is:

    Question 5 (2 marks)

    us

    u2

    d1

    d2

    u1

    uN

    dN

    Server

    Network (with

    abundant bandwidth)

    File, size F

    us: server upload

    bandwidth

    ui: peer i upload

    bandwidth

    di: peer i download

    bandwidth

    Figure 2: Figure for question 5

    Consider the peer-to-peer file distribution problem illustrated in Figure 2. The same problem

    has been discussed in the lecture as well as in the text. In this problem, there are N

    peers, and

    peer i has an upload transmission rate of u

    i bps and a download transmission rate of d i bps. The

    upload rate for the server is u

    s . The text shows that a lower bound for the minimum time for all

    the N

    peers to download a specific file of size F

    bits, using peer-to-peer distribution, is:

    DP

    2 P

    m

    a x

    (

    F

    u

    s

    ,

    F

    d m

    i n

    ,

    N

    F

    u

    s +

    P

    N

    i =

    1 u

    i

    )

    (1)

    where d m

    i n =

    m

    i n

    i =

    1 , 2 , . . . , N

    d i .

    Note that the above expression has been derived based on the assumption that every peer is

    willing to upload the file (or portions of the file) after it has received it.

    Now, let us assume that peers 1,2,…,k

    (where k

    is a positive integer strictly less than N

    ) are

    selfish peers which will only download files from others but do not upload any portion of the file

    that they have received. Derive an expression for the lower bound of the minimum time for all

    N

    peers to download the file under this revised assumption. Using the expression that you have

    derived, explain whether the delay when there are selfish users will be bigger or smaller than the

    case when all users participate in uploading.

    Hint: The lower bound for the case with selfish peers is of the form

    Ds e l fi s h

    P

    2 P

    m

    a x

    ⇢ F

    u

    s

    ,

    F

    d m

    i n

    , x

    (2)

    and you will need to find what x

    is.

    6

    Note that the above expression has been derived based on the assumption that every peer is willing to

    upload the file (or portions of the file) after it has received it.

    Question 5 (2 marks)

    us

    u2

    d1

    d2

    u1

    uN

    dN

    Server

    Network (with

    abundant bandwidth)

    File, size F

    us: server upload

    bandwidth

    ui: peer i upload

    bandwidth

    di: peer i download

    bandwidth

    Figure 2: Figure for question 5

    6

    Now, let us assume that peers 1,2,…., k (where k is a positive integer strictly less than N) are selfish

    peers which will only download files from others but do not upload any portion of the file that they

    have received. Derive an expression for the lower bound of the minimum time for all N peers to

    download the file under this revised assumption. Using the expression that you have derived, explain

    whether the delay when there are selfish users will be bigger or smaller than the case when all users

    participate in uploading.

    Hint: The lower bound for the case with selfish peers is of the form

    (

    u

    s

    d m

    i n

    u

    s +

    P

    i =

    1 u

    i

    )

    1 , 2 , . . . , N

    d i .

    Note that the above expression has been derived based on the assumption that every peer is

    willing to upload the file (or portions of the file) after it has received it.

    Now, let us assume that peers 1,2,…,k

    (where k

    is a positive integer strictly less than N

    ) are

    selfish peers which will only download files from others but do not upload any portion of the file

    that they have received. Derive an expression for the lower bound of the minimum time for all

    peers to download the file under this revised assumption. Using the expression that you have

    derived, explain whether the delay when there are selfish users will be bigger or smaller than the

    case when all users participate in uploading.

    Hint: The lower bound for the case with selfish peers is of the form

    Ds e l fi s h

    P

    2 P

    m

    a x

    ⇢ F

    u

    s

    ,

    F

    d m

    i n

    , x

    (2)

    and you will need to find what x

    is.

    6

    and you will need to find what x is.

    Answer:

    7

    Question 4 – Sliding Windows (5 marks)

    Suppose that a sender and receiver are connected via a point-to-point link that has 1 Mbps bandwidth

    and a one-way propagation delay of 4.5 ms. Assume that the sender always has data for transmission

    and that the size of each data packet is 125 Bytes. Neglect any headers. Also assume that the size of

    Ack packets is negligible. Answer each of the following for both go-back-n and selective-repeat

    sliding window schemes. You must explain your reasoning in the space provided.

    (a) Assuming that the link is error-free, what should be the size of the window (in terms of number of

    packets) to achieve a throughput of 0.8 Mbps.

    Go-back-n:

    Selective repeat:

    8

    (b) What is the minimum number of bits needed to represent the sequence numbers corresponding to

    the above window size? Recall that an n bit sequence number results in a range of sequence numbers

    from 0 to 2n-1.

    Go-back-n:

    Selective repeat:

    9

    © Suppose that the sender is transmitting a large number of packets to the receiver and there are

    always packets waiting to be transmitted. Suppose the 4th and 12th packet are lost during

    transmission. No other packets or acks are lost. Assume that sequence numbers start at 0. Assuming

    the window size and the minimum sequence number space that you have computed in the previous

    two parts, how many packets get retransmitted and what are their sequence numbers? Explain.

    (NOTE: This question is a bit involved. We suggest that you only attempt this once you have

    finished all other questions)

    Go-back-n:

    10

    Selective repeat:

    11

    Question 5 – Switchapalooza (4 marks)

    SOLVE ONE OF THE FOLLOWING DEPENDING ON YOUR ENROLLMENT. YOU MAY

    RECEIVE ZERO MARKS IF YOU ATTEMPT THE INCORRECT VERSION.

    COMP3331 (UNDERGRADUATE VERSION)

    Consider the network in the figure below. Node A and B are connected to each other through Router

    R. The link between node A and router R has bandwidth T and propagation delay L. The link

    between the router R and node B has bandwidth 2T and propagation delay L/2.

    Consider two cases:

    Case 1) The network is circuit-switched: Assume that the circuit setup between A and B has

    already occurred and that at time t=0, node A begins transmitting a 1 MByte file to node B. As soon

    as the last bit of the file has been transmitted, node A immediately transmits a 2 MByte file to B. The

    last bit of the 1MByte file arrives at node B at time t=0.8 seconds. The last bit of the 2MByte arrives

    at node B at time t=1.8 seconds. Disregard circuit teardown. Hint: A timing diagram may be useful.

    What is L (in msec)? _____________

    What is T (in Mbps)? _____________

    SHOW YOUR WORK BELOW

    A

    B

    Router R

    12

    Case 2) The network is packet-switched: Assume that at time t=0, node A begins transmitting a 1

    KByte packet to node B. As soon as the last bit of the packet has been transmitted, node A

    immediately transmits a 2 KByte packet to B. Assume there is no processing delay at the router. The

    first packet arrives at node B at time t=1.8 milliseconds. The second packet arrives at node B at time

    t=3.4 milliseconds. Hint: A timing diagram may be useful.

    What is L (in msec)? _____________

    What is T (in Mbps)? _____________

    SHOW YOUR WORK BELOW

    13

    COMP9331 (POSTGRADUATE VERSION)

    Consider the network in the figure below. Host A can choose between two different paths to

    communicate with host B. The situation is depicted in Figure 1. Host can choose to send packets via

    either Router 1 or Router 2 to host B. The communication links are of two different types, as

    indicated in the figure. The characteristics of these two types of links are:

    Link type 1: Each link is of length 2000km, propagation speed is 2 x 108 m/s and bandwidth is

    100kbps.

    Link type 2: Each link is of length 4000km, propagation speed is 2 x 108 m/s and bandwidth is

    50kbps.

    Host A wishes to transmit a message of size 4Kbytes to host B. It breaks this message into 4 packets

    of equal size. Neglect any packet headers. Remember that routers work on the store-and-forward

    principle.

    Assume that the processing delay and queuing delay in the routers are negligible.

    (a) If host A chooses to send the packets via Router 1, draw a timing diagram to show the delay

    experienced by the packets. By using this timing diagram, determine the time it takes to move

    the packets from host A to host B, i.e., beginning from the time that host A starts to send the

    first bit of the first packet till the time that host B receives the last bit of the last packet.

    Note: You are required to draw your timing diagram roughly to scale. This will also help you to

    determine the delay.

    Question 4 (7 marks)

    Host A

    Host B

    Router 2

    Router 1

    Link type 1

    Link type 1

    Link type 2

    Link type 1

    Figure 1: Figure for question 4

    Host A can choose between two different paths to communicate with host B . The situation

    is depicted in Figure 1. Host A can choose to send the packets via either Router 1 or 2 to host B .

    The communication links are of two different types, as indicated in Figure 1. The characteristics

    of these two types of links are:

    • Link type 1: Each link is of length 2000km, propagation speed is 2 ⇥

    1 0 8 ms�

    1 and trans-

    mission rate is 100 kbps.

    • Link type 2: Each link is of length 4000km, propagation speed is 2 ⇥

    1 0 8 ms�

    1 and trans-

    mission rate is 50 kbps.

    Host A has received a message of size 4 kbytes to be sent to host B. It breaks this message

    into 4 packets of equal size to be transmitted to host B .

    Assuming that processing delay and queueing delay in the routers are negligible, answer the

    following questions:

    (a) If host A chooses to send the packets via router 1, draw a timing diagram to show the delay

    experienced by the packets. By using this timing diagram, determine the time it takes to

    move the packets from host A to host B , i.e. beginning from the time that host A starts to

    send the first bit of the first packet till the time that host B

    receives the last bit of the last

    packet.

    (b) Repeat part (a) if host A chooses to send the packets via router 2.

    Important note: You are required to draw your timing diagram roughly to scale. This will

    also help you to determine the delay.

    Hint: Routers work on the store-and-forward principle.

    3

    14

    (b) Repeat part (a), if host A chooses to send the packets via Router 2

    END OF EXAM – SEE LAST PAGE FOR BONUS 0.5 MARK

    15

    USE THIS SPACE FOR ROUGH WORK IF REQUIRED

    16

    USE THIS SPACE FOR ROUGH WORK IF REQUIRED

    17

    USE THIS SPACE FOR ROUGH WORK IF REQUIRED

    18

    BONUS 0.5 MARK FOR FILLING THIS

    NOTE: YOU CAN RECEIVE BONUS 0.5 MARK BY TEARING THIS PAGE AND PROVIDING

    FEEDBACK. HOWEVER, MAXIMUM MARKS WILL BE CAPPED AT 20 MARKS.

    THIS FEEDBACK IS ANONYMOUS. DO NOT WRITE YOUR NAME. WE WILL AWARD

    YOU THE 0.5 MARK IF THIS PAGE IS TORN OFF FROM THIS BOOKLET.

    List one thing you liked about this course and would like to see more of or see continued (any topic –

    lectures, labs, assignments, tutorials, topics covered or not covered, etc., etc.):

    List one thing you would like to have changed or have improved about this course:

    Any other comments that you may have regarding the course:

    TEAR THIS PAGE AND RETURN IT SEPARATELY

继续阅读