天天看點

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

繼續閱讀