Computer network === < Contributor `25077667` `Koul` `lamb` `daven`> ## 友情網站 ernestchu's blog: [CSE350 Computer Network](https://ernestchu.github.io/courses/cse350-computer-network/introduction.html) ## 投影片: * [Chapter 1](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_1_V7.01.pdf) * [Chapter 2](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_2_V7.01.pdf) * [Chapter 3](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_3_V7.01.pdf) * [Chapter 4](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_4_V7.01.pdf) * [Chapter 5](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_5_V7.01.pdf) * [Chapter 6](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_6_V7.01.pdf) * [Chapter 7](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_7_V7.01.pdf) * [Chapter 8](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_8_V7.01.pdf) * [Chapter 9](https://github.com/25077667/NSYSU_Computer_Network/blob/main/slides/Chapter_9_V7.01.pdf) ## The network core * mesh of interconnected routers * **store and forward** * entire packet must arrive at router before it can be trasmitted on next link * **end-end delay** * assume $L$ bits per packet , $R$ bps * delay $= 2L/R$ :::info - **RTT: Round trip time (2R)** ::: - 這個2R是甚麼 * queuing * in < out = underflow * in > out = overflow Routing & forwarding routing = 決定封包走哪條路。由軟體決定,費時 forwarding = 按照決定的路丟出去。**由硬體決定**,快 > [name=楊志璿] 硬體決定?未必吧? > 等等問一下好了 * circuit switching * FDM(frequency division multiplexing,分頻多工) * 以frequency為切分(Frequency division) * TDM(time division multiplexing,分時多工) * 以 Time 為切分(Time division、Time sharing) * 同時做 FDM, TDM * 當今4 , 5G網路(TDMA + FDMA + CDMA ) * Orthonormal Frequency division multiple access * CDMA * Code-division multiple access * 用編碼區分 * * packet switching * 當今line,messanger * 比較便宜,比較慢 * **考:為何可以同時支援的user多於circuit switching** * 為何 : with circuit switching, 100kps must be reserved for each user at all times,but packet switching doesn't. When there are 10 or fewer active users, users' packets flow through the link essentially without delay,while there are more than 10 simultanesously active users,...,and the output queue begin to grow(參考自課本P.58 59) * **VoIP (Voice over Internet Protocol)** * 可能會壅塞,因此需要protocols,提供可靠傳輸 * ISP * Cross global ISP link is called peering link.eg.網外互打 * Ineternet eXchange Port(IXP) * regional net * content service provider eg.google * loss * queue 滿了,決定要drop * * delay * **$D_{proccessing}$+$D_{queueing}$+$D_{transmission}$+$D_{propagation}$** * **必考1-45 順序重要,順序如上proc及queue可以相反** * >[name=楊志璿] What is 順序? why? * queueing delay **大概率考1-48** * 這圖很反直覺(Counterintuitive),會考 * burst -> die * swarm -> drop * ![](https://i.imgur.com/vD0Qnoi.jpg) * traceroute : provides delay measurement from source to router along end-end Internet path towards destination. * sends three packets that will reach router i on path towards destination * router i will return packets to sender * sender times interval between transmission and reply * throughput **重要1-53** * 通量 * throughput : rate at which bits transferred between sender/receiver * bottleneck link : link on end-end path that constrains end-end throughput * flow control * 不要去很塞的地方 * congestion control * 依照塞不塞的情況,升降流量 ## Protocal layers, service models * layering, modulization * divide and conquer * updating of system * easy of maintenance * disadvantage * efficiency * internet protocol stack * **必考1-60** * ![](https://i.imgur.com/ad4dlMF.jpg) * [OSI 7 層小故事](https://cloud.tencent.com/developer/article/1102684) * 五層 * application * SFTP, HTTP, SMTP * transport * TCP, UDP, ICMP * network * IP * link **前兩項必考** * Ethernet(CSMA/CD), IEEE 802.11(CSMA/CA), PPP * physical * wire * **必考演算法** * dijkstra * bellman-ford * 為啥? * 期中考考,期末考考! * OSI 差異 ==不一定會考,不想讓你考一百分的時候考:100:== * presentation * Encoding, Encryption, compression * session * Synchronization, checkpoint, recovery of data exchange * Encapsulation **每年必考** * 各層只看得懂各自層的檔頭 * 包個檔頭,使下層知道要幫你做什麼事 * 若在同一個子網路下,可以減少需要向上的層數(他講的) * Cerf and Kahn's internetworking principles * minimalism, autonomy - no internal changes required to interconnect networks * best effort service model * stateless routers * decentralized control # ch 2 * client-server architecture * server * always-on host * permanent IP address * data centers for scaling * client * communicate with server * may be intermittently(間歇地) connected * may have dynamic IP address * do not communicate directly with each other * P2P architecture * no way on server * self scalablity * new peersing new service capacity, as well as new service demands * 沒有純粹的p2p,還是要有server的幫助。 * > why? [name=楊志璿] * Because most of the piers have dynamic IP addresses. A server helps them find each other. Even if every pier has a static IP address, still, piers come and go. How can they connect to newbies without the help of the server? * Socket * The API between the transport layer and application layer. * addressing processes * port: 一個 host 有個unique 32-bits(IPv4) IP addr but 有很多process在同一個host上跑 so 額外給更多位元 process id以識別同host 上的process (也不全然是 pid) * App-layer protocol defines * message syntax(語法) * what field in message and how field are delineated(劃定) * message semantics(語意) * meaning of information in fields > [throughput vs bandwidth](https://www.dnsstuff.com/network-throughput-bandwidth#bandwidth-vs-throughput) >> TL;DR: bandwidth 網路通道實際容量, throughput 單位時間傳輸packet數量 * QoS * Quality of service * 效率與公平的衝突 * TCP service * reliable transport * flow control: 傳送者不能造成接收者的壅塞 * Congestion control: 傳送者不能造成中間網路壅塞 * UDP service * unreliable data transfer * does not provide reliability, flow control, congestion control, timing, throughput guarantee, security, or connection setup **Why we have TCP, but there is still an UDP?必考** * Ans: * 先從兩個角度來看: * UDP 因為不管制,所以可以搶贏 TCP。 * if only UDP 因不講求 QoS, throughtput等管控,大家都搶即無法顧及品質。 * SSL * an app layer * 幫TCP加密 * Web, HTTP * statelesss * 現在狀況與之前無關,即不須記錄過去狀態 * 若需要維持狀態一致,就用 Cookie * substate: * 可以忍耐短時間內兩人狀態不一致,最終會收斂到接近 * non-persistent and persistent HTTP * persistent 一次送完 * non-persistent 分次送完 **RTT 2-25 會考** persistent: ```sequence A - B: Hello Note right of A: 一個RTT B - A: Hello A - B: request01 我要OOXX十個 Note right of A: 第二個RTT B - A: OOXX A - B: request02 B - A: OOXX... ``` * **cache 好處會考2-38,2-40** * 減少 runtime * 減少 traffic * DNS * 因為以前在設計 network layer 的時候沒有設計 DNS,所以放到應用層 * Confuse? * A name could map into multiple IP address * Alias <-> canonical[專有名詞] Hierarchy: :::spoiler ```graphviz digraph G { nodesep=1.0 // increases the separation between nodes node [color=Red,fontname=Courier,shape=box] //All nodes will this shape and colour edge [color=Blue, style=dashed] //All the lines look like this {Root_DNS}->{org com tw} org->{Teacher1 Teacher2} com->{google yahoo} tw -> {gov edu} } ``` ::: * Local DNS - default DNS server - usually faster, but not always, because of less entries - TLD server caching -> substate - Update/notify spec RFC 2136 Global root name server: [wiki](https://zh.wikipedia.org/zh-tw/%E6%A0%B9%E7%B6%B2%E5%9F%9F%E5%90%8D%E7%A8%B1%E4%BC%BA%E6%9C%8D%E5%99%A8) :::info 什麼時候用 Proxy? 什麼時候用 Agent? ::: **會考 DNS records: 2-66~69** * DNS records: * RR format(resource record): * name: * value: 要傳達訊息的存放欄位 * type: * A: 告知對方直接 IP * NS: 告知別人可能知道 * CNAME: 告知此專有名詞在本地的名稱 * MX: 告知郵件伺服器的名稱 * ttl: time to live * P2P * tit-for-tat **會考 TCP UDP 差異** * UDP & TCP socket programming: * UDP : bind destination address and destination port * User Datagram Protocol * TCP : bind both destination & source address and port ## Chapter 3 **考 congestion control 擁塞控制** * transport layer vs network layer * transport: communication between processes * network : communication between hosts **會考demultiplexing multiplexing** ![](https://i.imgur.com/yHTvMqb.jpg) IPv4 在意封包效率 IPv6 在意封包一致性 **考3-31,3-33圖(課本P.244)每個步驟遮掉要自己填空** * error scenario ![](https://i.imgur.com/9RZuNxR.jpg) ![](https://i.imgur.com/ytSBITU.jpg) **3-45** * 考畫圖 ![](https://i.imgur.com/T8SdlUg.jpg) **3-46** * Go-back-N * 只能照順序送 * 一個沒收到,全部重傳 * 簡單暴力 * Selective Repeat * 可以告訴要重傳哪一個 * 減少重傳次數 * 增加管理困難 **3-48** 解釋圖 ![](https://i.imgur.com/AtXVfg8.jpg) * base : 最早的已發送但尚未接收ACK的封包序列 * nextseqnum : 最小的尚未發送的封包序列 * 初始狀態 : 將base和nextseqnum設為1 * 傳輸階段(rdt_send(data)) : 若nextseqnum在windows的範圍內(代表windows尚有空間),則將編號nextseqnum的資料打包並傳送出去, 若base等於nextseqnum,代表此時的nextseqnum是"現在"最早送出且尚未收到ACK的封包序列,則啟動計時器,而不論是否啟動計時器,每次皆須將nextseqnum + 1; 若nextseqnum超出了windows範圍,則返回資料給上層,暗示windows已滿 * 超時階段(timeout) : 此時序列base的已送出封包尚未獲得來自接收方的ACK,則按照GBN的規則,所有已送出但仍未收到ACK的封包進行重傳 * 接收到ACK且沒有損毀(rdt_rcv(rcvpkt)&&notcorrupt(rcvpkt)) : 將base設為所收到ACK回傳的序列+1(因為累計確認的原則,代表在此序列之前的所有封包皆是已經接收無誤),並確認base是否等於nextseqnum(可能代表資料已經傳輸完畢),則停止計時器,否則重啟計時器 * 接收到ACK但有損毀(rdt_rcv(rcvpkt)&&corrupt(rcvpkt)) : 不做任何處理 **3-53** 考圖 考sender window ![](https://i.imgur.com/URzOmb8.jpg) TCP封包中 optional的部分導致長度不一 **3-70**表格必考 所有TCP都是用這個技巧 邏輯好理解 ACK太多導致網路上都是ACK沒有該送的資料 * 事件一 : 接收方所收到的封包,其序號是預期收到的序號且資料確認無誤 * 延遲發出ACK,至多等待500ms,若等待時間結束前沒有封包抵達,則發出ACK * 目的 : 減少送出的ACK數量(comulative ACK) * 事件二 : 抵達的封包是預期收到的序號且資料無誤,此時也有一個ACK在等待發出(事件一) * 立刻發出ACK,已確認這兩個封包正確抵達 * 事件三 : 序號大於預期序號的封包抵達(非照順序抵達) * 立刻發出ACK,指示下一個預期抵達的封包序號 * 事件四 : 能夠填充因為事件三引起的空缺的部分或全部的封包已抵達 * 若此封包位於序列號的 "低位" ,立即發出ACK表示此序號(含)以前的封包皆已接收無誤(comulative ACK) **3-100,3-101非常非常的重要** 要會畫 解釋 太極生兩儀,兩儀生四象,四象生八卦 ![](https://i.imgur.com/u9nhJSe.jpg) * Tahoe:time out(知道網路很爛)掉到1再繼續expotential成長到 ssthreshold後線性成長 * Reno:time out 或是 dupulicate ACK(知道網路很爛)掉到一半,再線性成長。 * time out 表示目前最大window size維持不住 ![](https://i.imgur.com/rCan321.jpg) * cwnd(壅塞控制窗口) : 限制一個TCP發送方往網路中發送的流量值 * 補充 : 壅塞控制中假設rwnd(接收方buffer)足夠大,以至於可以忽略接收方windows的限制 * ssthresh(慢啟動閥值) : 自定義的一個閥值,當在slow start階段,cwnd超過ssthresh時,轉移狀態至congestion avoidance(壅塞避免)狀態 * MSS(maximum segment size) * dupACKcount : 多餘的重複ACK * 懶人包 * slow start處理一般傳輸(cwnd小於ssthresh時)和超時 * congestion avoidance處理一般傳輸(cwnd大於ssthresh時) * fast recovery處理中間封包丟失(3個多餘的ACK發生時) * 初始化 * 將cwnd值設為1MSS,ssthresh設為64KB(範例),dupACKcount設為0,並進入slow start(慢啟動階段)階段 * slow start(慢啟動階段) * 收到new ACK : 將cwnd值翻倍,並以此cwnd的值的數量繼續傳輸 * 收到3個重複的ACK(不含new ACK的第一次) : 將ssthresh值設為當前cwnd值的一半,cwnd設為1MSS,dupACKcount設為0,並轉移至fast recovery(快速恢復)狀態且重新傳送封包 * cwnd >= ssthresh : 轉移至congestion avoidance(壅塞避免)狀態 * 超時(timeout) : 將sstresh值設為當前cwnd值的一半,cwnd設為1MSS,dupACKcount設為0,並重新傳送封包 * congestion avoidance(壅塞避免) * 收到new ACK : 將cwnd值加上一個MSS值,並以此cwnd的值的數量繼續傳輸 * 收到3個重複的ACK(不含new ACK的第一次) : 將ssthresh值設為當前cwnd值的一半,cwnd設為1MSS,dupACKcount設為0,並轉移至fast recovery(快速恢復)狀態且重新傳送封包 * 超時(timeout) : 將sstresh值設為當前cwnd值的一半,cwnd設為1MSS,dupACKcount設為0,並轉移至slow start(慢啟動階段)狀態且重新傳送封包 * fast recovery(快速恢復) * 收到new ACK : 將cwnd值設為ssthresh,dupACKcount設0,並轉移至congestion avoidance(壅塞避免)狀態 * 收到重複的ACK : 將cwnd值加上一個MSS值,並以此cwnd的值的數量繼續傳輸 * 超時(timeout) : 將ssthresh值設為當前cwnd值的一半,cwnd設為1MSS,dupACKcount設為0,並轉移至slow start(慢啟動階段)狀態且重新傳送封包 **3-105從來不考** ## Ch4 Routing issue **4-12考architecture或input/output port** 至少考一邊 **4-16從來不考** **必考4-22 HOL問題** 跟長榮塞運河一樣 前面有人不能走,你也不能走 **4-34必考 考你填格子** **4-46 4-47 48 47 49 50 ** 可能會隨便考 他說都是一樣的 表示法不同 封裝考四個例子 router (input protocol nat openflow 3example 演算法X2 畫圖 推 速都扣 ## Ch5 **IDP** 5-35 **OSPF** 5-31, 5-32, 5-33 intra-AS, inter-AS **eBGP, iGBP** 會考 **link state** 很可能會考 **AS-PATH, NEXT-HOP** 5-44 **SDN概念會考** 5-57, 5-59 **不會考ISRP** **control plane data plane** **6-23** CSMA CSMA/CD CSMA/CA是什麼,會考