# CS-NETWORK HW2 ## https://reurl.cc/x10jb1 ## R1 **List five nonproprietary Internet applications and the application-layer protocols that they use.** ![](https://i.imgur.com/UJFgZRg.png) :::info <ul> <li><strong>The web:</strong> <ul> <li>The web application is a client-server program in which the client runs in a web browser.</li> <li>The web application uses Hyper Text Transfer Protocol (HTTP) as application layer protocol.</li> <li>HTTP is an application protocol for distributive, collaborative, and hypermedia information systems.</li></ul></li> <li><strong>File Transfer:</strong></li> <li>The File Transfer web application is an application that allows services to the users to share files over the web.</li> <li>The File Transfer web application uses the File Transfer Protocol (FTP) as application layer protocol.</li> <li>The FTP is a standard application layer tool in a computer network which is used to transfer files between client and server.</li> <li><strong>Remote Login:</strong> <ul> <li>The Remote login related applications are the applications that are used to control one computer from another computer by the use of a remote.</li> <li>The Remote login related application uses the Telecommunications Network (Telnet) as application layer protocol.</li> <li>Telnet is a bidirectional interactive text oriented communication facility which is used as a protocol on the internet by using a virtual terminal connection.</li></ul></li> <li><strong>E-mail:</strong></li> <li>E-mail applications are used to send emails over the internet.</li> <li>The Simple Mail Transfer Protocol (SMTP) is used in E-mail related applications.</li> <li>The SMTP is only an application layer delivery protocol which is an internet standard for electronic mail transformation.</li> <li><strong>Bit Torrent File Sharing:</strong></li> <li>Bit Torrent file sharing application is a communication protocol that is used for peer to peer file sharing to share and distribute files and data over the internet.</li> <li>The Bit Torrent File sharing applications use Bit Torrent Protocol as application layer protocol.</li> <li>The Bit Torrent Protocol is a protocol that is used for distributing electronic files.</li></ul> ::: :::warning Nonproprietary Internet : 1. not protected under any patent 2. public domain 3. can produce and distribute these applications HTTP, FTP etc ::: ## R2 **What is the difference between network architecture and application architecture?** ![](https://i.imgur.com/TQ1Mu0e.png) :::info Network architecture refers to the organization of the communication process into layers. Application architecture, on the other hand, is designed by an application developer and dictates the broad structure of the application. ::: :::warning 2.1.1 (PDF 116) ::: ## R5 **What information is used by a process running on one host to identify a process running on another host?** :::info The IP address of the destination host and the port number of the socket in the destination process. ::: :::warning Internet layer, Transport layer ::: ## R8 **List the four broad classes of services that a transport protocol can provide. For each of the service classes, indicate if either UDP of TCP (or both) provides such a service.** ![](https://i.imgur.com/xln3YXq.png) ![](https://i.imgur.com/kSWA5bx.png) :::info * Reliable data transfer: - TCP only * A guarantee that a certain value for throughput will be maintained: - Neither TCP nor UDP. * A guarantee that data will be delivered within a specified amount of time: - Neither TCP nor UDP. * Security: - Neither TCP nor UDP. ::: :::success **elastic applications** can make use of as much, or as little, throughput as happens to be available, E-mail, Web, file transfer ::: :::warning 2.1.3 Transport Services Available to Applications (PDF 121) **reliable data transfer, throughput, timing, security** - Reliable data transfer - A guarantee that a certain value for throughput will be maintained - A guarantee that data will be delivered within a specified amount of time - Confidentiality ::: ## R9 **Recall that TCP can be enhanced with SSL to provide process-to-process security services, including encryption. Does SSL operate at the transport layer or the application layer? If the application developer wants TCP to be enhanced with SSL, what does the developer have to do?** ![](https://i.imgur.com/seIQiqw.png) :::info SSL operates at the application layer. The SSL socket takes unencrypted data from the application layer, encrypts it and then passes it to the TCP socket. If the application developer wants TCP to be enhanced with SSL, she has to include the SSL code in the application. ::: :::warning 1. TCP Header has SSL?? 2. Coding ::: ## R11 **What does a stateless protocol mean? Is IMAP stateless? What about SMTP?** ![](https://i.imgur.com/6kilqkO.png) ![](https://i.imgur.com/Ldzfhva.png) :::info * A stateless protocol is a communication protocol in which the receiver must not retain session state from previous requests * SMTP is a stateless protocol as the mail server does not maintain any connection with the client, it does not store any information about the client. If an email is asked to be sent twice, the server will resend it without saying that the email has been sent. * IMAP is a state protocol, because the IMAP server must maintain a folder hierarchy for each of its users, this state information persists across a particular user's successive accesses to the IMAP server. ::: :::warning 2.2.1 (PDF131頁) IMAP(RFC 3501) SMTP(2.3.6, RFC 5321) ::: ## R14 **Telnet into a Web server and send a multiline request message. Include in the request message the If-modified-since: header line to force a response message with the 304 Not Modified status code.** ![](https://i.imgur.com/XZe0CiO.png) :::warning ![](https://i.imgur.com/JREhZps.png) ``` telnet www.cs.nccu.edu.tw 80 GET ~/jang/welcome.html HTTP/1.1 Host: cs.nccu.edu.tw GET ~/jang/welcome.html HTTP/1.1 Host: cs.nccu.edu.tw If-Modified-Since: Wed, 18 Jul 2018 13:43:00 GMT ``` ::: ## R17 **Print out the header of an e-mail message you have recently received. How many Received: header lines are there? Analyze each of the header lines in the message.** :::info 郵件 ID <010001845b3bd689-9650c4fe-1b40-43e9-9dde-1e3efa376fe3-000000@email.amazonses.com> 建立時間: 2022年11月9日 下午3:12 (傳輸時間:1 秒) 寄件者: Amazon Web Services <aws-marketing-email-replies@amazon.com> 收件者: deyenqiu@gmail.com 主旨: 千萬別錯過,立即報名觀賞 AWS re:Invent 現場直播 SPF: PASS,IP 54.240.11.155 瞭解詳情 DKIM: 'PASS',網域 amazon.com。瞭解詳情 DMARC: 'PASS'。瞭解詳情 * SPF 是一套認證機制,可以確認電子郵件是由網欲授權的郵件伺服器寄送出。 * DKIM 是一種電腦數位簽章,採用公鑰與私鑰這種加密驗證法進行。在發送郵件時由發信服務器對郵件以私鑰進行簽章,而在郵件接收服務器上,會透過 DNS 到發信者的網域查詢 DKIM 紀錄,擷取上面記載的公鑰資料,然後對這封郵件做簽章解碼,如果公鑰與私鑰能配對成功,代表郵件確實為原始發信機所發出。 * DMARC用來讓發信端網域通知收件端郵件服務器 ::: :::warning - **Received** - **Message-id** - **From** : - **To** : - **Subject** : - **Date** : - **MIME-version** : - **Return-Path** : ::: ## R21 **Under what circumstances is file downloading through P2P much faster than through a centralized client-server approach? Justify your answer using Equation 2.2.** ![](https://i.imgur.com/kiGEh5P.png) ![](https://i.imgur.com/1StijMo.png) :::warning $U_s$ : Server上傳速度 $d_i$ : User $i$th 下載速度 $U_i$ : User $i$th 上傳速度 - P2P $\dfrac{NF}{U_s + \sum^{N}_{i=1} U_i}$ --- - Clent-server $\dfrac{NF}{U_s}$ ::: ## P1 **True or false?** ### a **A user requests a Web page that consists of some text and three images. For this page, the client will send one request message and receive four response messages.** :::info False. Send 4 receive 4. ::: ### b **Two distinct Web pages (for example, www.mit.edu/research.html and www.mit.edu/students.html ) can be sent over the same persistent connection.** :::info True. Persistent HTTP leaves connection open. ::: ### c **With nonpersistent connections between browser and origin server, it is possible for a single TCP segment to carry two distinct HTTP request messages.** :::info False. Each TCP segment can only carry one request. ::: ### d **The Date: header in the HTTP response message indicates when the object in the response was last modified.** :::info False. Date is request generation time. ::: ### e **HTTP response messages never have an empty message body.** :::info False. 204 No Content. (May give credit if answer was True with explanation on 404 Not Found) ::: ## P2 **SMS, iMessage, and WhatsApp are all smartphone real-time messaging systems. After doing some research on the Internet, for each of these systems write one paragraph about the protocols they use. Then write a paragraph explaining how they differ. ** :::info SMS, IMessage, and WhatsApp are all smartphone real-time messaging systems. After doing some research on the Internet, for each of these systems write one paragraph about the protocols they use. Then write a paragraph explaining how they differ. ::: ## P4 **Consider the following string of ASCII characters that were captured by Wireshark when the browser sent an HTTP GET message (i.e., this is the actual content of an HTTP GET message). The characters```<cr><lf>``` are carriage return and line-feed characters (that is, the italized character string```<cr>```in the text below represents the single carriage-return character that was contained at that point in the HTTP header). Answer the following questions, indicating where in the HTTP GET message below you find the answer.** ![](https://i.imgur.com/mEEKqFT.png) ### a **What is the URL of the document requested by the browser?** :::info http://gaia.cs.umass.edu/cs453/index.html. The Host : field indicates the server's name and /cs453/index.html indicates the file name. ::: ### b **What version of HTTP is the browser running?** :::info The browser is running HTTP version 1.1, as indicated just before the first pair. ::: ### c **Does the browser request a non-persistent or a persistent connection?** :::info The browser is requesting a persistent connection, as indicated by the Connection: keep-alive. ::: ### d **What is the IP address of the host on which the browser is running?** :::info This is a trick question. This information is not contained in an HTTP message anywhere. So there is no way to tell this from looking at the exchange of HTTP messages alone. One would need information from the IP datagrams (that carried the TCP segment that carried the HTTP GET request) to answer this question . ::: ### e **What type of browser initiates this message? Why is the browser type needed in an HTTP request message?** :::info Mozilla/5.0. The browser type information is needed by the server to send different versions of the same object to different types of browsers. ::: ## P5 **The text below shows the reply sent from the server in response to the HTTP GET message in the question above. Answer the following questions, indicating where in the message below you find the answer.** ![](https://i.imgur.com/fjtXsAK.png) ### a **Was the server able to successfully find the document or not? What time was the document reply provided?** :::info The server was able to locate the document successfully. Reason is that The status code of 200 and the phrase OK. The reply was provided on Tuesday, 07 Mar 2006 12:39:45 Greenwich Mean Time. ::: ### b **When was the document last modified?** :::info The document index.html was last modified on Saturday 10 Dec 2005 18:27:46 GMT. ::: ### c **How many bytes are there in the document being returned?** :::info There are 3874 bytes in the document being returned. ::: ### d **What are the first 5 bytes of the document being returned? Did the server agree to a persistent connection?** ![](https://i.imgur.com/gBbW0xA.png) :::info The first five bytes of the returned document are : <!doc. The server agreed to a persistent connection, as indicated by the Connection: Keep-Alive field ::: ## P7 ![](https://i.imgur.com/lRd9cQl.png) ![](https://i.imgur.com/1GRtMvj.png) ![](https://i.imgur.com/YErj6mk.png) ### a :::info 2 TTl + 3 RTTr ::: ### b :::info 2 TTl + 3 RTTr ::: ### c :::info 2 TTl ::: ## P8 ![](https://i.imgur.com/54YrU7B.png) **Referring to Problem P7, suppose the HTML file references eight very small objects on the same server. Neglecting transmission times, how much time elapses with?** ![](https://i.imgur.com/1iVpv0V.png) ![](https://i.imgur.com/GHhILmB.png) ### a **Non-persistent HTTP with no parallel TCP connections?** :::info 18RTT0 + RTT1 + … + RTTn ::: ### b **Non-persistent HTTP with the browser configured for 5 parallel connections?** :::info 6RTT0 + RTT1 + … + RTTn ::: ### c **Persistent HTTP?** ![](https://i.imgur.com/LaLWUYX.png) :::info 3RTT0 + RTT1 + … + RTTn ::: ## P9 ![](https://i.imgur.com/e4rEfpn.png) ![](https://i.imgur.com/Cy9T3sc.png) ### a **Find the total average response time.** :::info 3.6 sec ::: :::warning 2.2.5 Web cahing 1. Router(Internet) HTTP Request/Response : 3s 2. Router(Internet) --- Router(LAN) 3. LAN (課本有說通常很短所以忽略) ![](https://i.imgur.com/udT0a4l.png) ::: ### b **Now suppose a cache is installed in the institutional LAN. Suppose the miss rate is 0.4. Find the total response time.** :::info 1.24 sec ::: :::warning 1. Cache Missing time (traffic intensity少6成) 2. Cache hit time (0s 因為忽略) 0.4 * Cache Missing time + 0.6 * Cache hit time ::: ## P10 ![](https://i.imgur.com/lfOwnBr.png) ### a **Nonpersistent HTTP with serial connections** :::info $2*100ms(TCP\ handshake+HTTP\ webpage) +$ $\dfrac{8*1KB}{1Mbps}(d_{trans})+$ $5*2*100ms*(TCP\ handshake+HTTP\ 5\ images)+$ $5*\dfrac{50*8*1KB}{1Mbps}(5\ images\ d_{trans})$ ::: :::warning 1. 1HTML : ($\dfrac{L_H}{R}$ + 2RTT) 2. 5Image : 5 * ($\dfrac{L_I}{R}$ + 2RTT) ::: ### b **Nonpersistent HTTP with two parallel serial connections** :::info $2*100ms(TCP\ handshake+HTTP\ webpage) +$ $\dfrac{8*1KB}{1Mbps}(d_{trans})+$ $3*2*100ms*(TCP\ handshake+HTTP\ 5\ images)+$ $5*\dfrac{50*8*1KB}{1Mbps}(5\ images\ d_{trans})$ ::: :::warning 1. 1HTML : ($\dfrac{L_H}{R}$ + 2RTT) 2. 5Image : 3 * ($\dfrac{L_I}{R}$ + 2RTT) ::: ### c **Nonpersistent HTTP with six parallel serial connections** :::info $2*100ms(TCP\ handshake+HTTP\ webpage) +$ $\dfrac{8*1KB}{1Mbps}(d_{trans})+$ $2*100ms*(TCP\ handshake+HTTP\ 5\ images)+$ $5*\dfrac{50*8*1KB}{1Mbps}(5\ images\ d_{trans})$ ::: :::warning 1. 1HTML : ($\dfrac{L_H}{R}$ + 2RTT) 2. 5Image : ($\dfrac{L_I}{R}$ + 2RTT) ::: ### d **Persistent HTTP with one connections** :::info $2*100ms(TCP\ handshake+HTTP\ webpage) +$ $\dfrac{8*1KB}{1Mbps}(d_{trans})+$ $5*100ms*(HTTP\ 5\ images)+$ $5*\dfrac{50*8*1KB}{1Mbps}(5\ images\ d_{trans})$ ::: :::warning 1. 1HTML : ($\dfrac{L_H}{R}$ + 2RTT) 2. 5Image : 5($\dfrac{L_I}{R}$ +RTT) ::: ## P11 ![](https://i.imgur.com/zaGqMCR.png) :::info (Ld/R+2RTT)+N*(Li/R+RTT) ::: ## P15 **Read RFC 5321 for SMTP. What does MTA stand for? Consider the following received spam e-mail (modified from a real spam e-mail). Assuming only the originator of this spam e-mail is malicious and all other hosts are honest, identify the malacious host that has generated this spam e-mail.** ![](https://i.imgur.com/Xsyki8f.png) :::info MTA stand for Mail Transfer Agent. MTA is used for exchange mails between two systems. After obeservation of above data, "asusus-4b96 [58.88.21.177]” does not found sender mail ID. If it is spam mail, then originator can be dishonest. So, "asusus-4b96 [58.88.21.177]” is the spam mail. ::: :::warning An honest MTA should report where it receives the message. Since we assume only the originator is dishonest. ::: ## P16 ![](https://i.imgur.com/bA9y5GV.png) :::info SRV (Service) records are custom DNS records. They are used to establish connections between a service and a hostname. ::: ## P17 ### a ![](https://i.imgur.com/o8NdQFp.png) :::info C: dele 1 C: retr 2 S: (blah blah … S: ………..blah) S: . C: dele 2 C: quit S: +OK POP3 server signing off ::: :::warning https://evanmeshberg.wordpress.com/2013/02/24/chapter-2-homework/ ![](https://i.imgur.com/jJTX3Dc.png) ::: ### b ![](https://i.imgur.com/YYtEsGG.png) :::info C: retr 2 S: blah blah … S: ………..blah S: . C: quit S: +OK POP3 server signing off ::: :::warning ![](https://i.imgur.com/zVdnkMD.png) ::: ### c **Suppose you have configured your POP mail client to operate in the download-and-keep mode. Using your transcript in part (b), suppose you retrieve messages 1 and 2, exit POP, and then five minutes later you again access POP to retrieve new e-mail. Suppose that in the five-minute interval <span style=color:red>no new messages have been sent to you</span>. Provide a transcript of this second POP session.** :::info C: list S: 1 498 C: 2 912 S: . C: retr 1 S: blah … S: …blah S: . C: retr2 S: blah blah…blah blah S: . C: quit S: S: +OK POP3 server signing off ::: :::warning https://evanmeshberg.wordpress.com/2013/02/24/chapter-2-homework/ ::: ## P20 ![](https://i.imgur.com/uPJdVxk.png) ![](https://i.imgur.com/fONLmz0.png) ![](https://i.imgur.com/XRONUDH.png) :::warning - Without proxy 1. 2RTT (At the same time) 2. N * L File size 3. Bottleneck $R_b$ --- - Proxy 1. 2RTT 2. Server to Proxy (N size) 3. Proxy to client (NL File size) ::: ## P22 ![](https://i.imgur.com/XkMZ83U.png) :::warning ![](https://i.imgur.com/TiSwwre.png) ![](https://i.imgur.com/JivL3cl.png) F : 檔案大小 $U_s$ : Server上傳速度 $d_i$ : User $i$th 下載速度 $U_i$ : User $i$th 上傳速度 ::: ## P23 ![](https://i.imgur.com/fX6P542.png) ### a :::warning $F$ : file size(bits) $N$ : number of client $U_s$ : combined rate --- $\dfrac{U_s}{N}$ : server to client rate $d_{min}$ : client downloand rate $\dfrac{U_s}{N} \leq d_{min}$ : client receive at rate $\dfrac{U_s}{N}$ each download time? ::: ### b :::warning $\dfrac{U_s}{N}$ : server to client rate $d_{min}$ : client downloand rate $\dfrac{U_s}{N} \geq d_{min}$ : client receive at rate ${d_{min}}$ each download time? ::: ### c :::warning (a) (b) 綜合在一起就是 了 ::: ## P24 ![](https://i.imgur.com/3VvCZNC.png) ![](https://i.imgur.com/TiSwwre.png) ### a :::warning 只考慮Upload Server 端的 upload < P2P upload加總 會卡在Server端 ::: ### b :::warning 只考慮Upload Server 端的 upload > P2P upload加總 ::: ### c :::warning (a) (b) 綜合在一起就是了 ::: ## P26 ![](https://i.imgur.com/dBOsMle.png) ### a ### b ## P27 ![](https://i.imgur.com/nH8kMOr.png) ### a :::warning If you run TCPClient first, then the client will attempt to make a TCP connection with a non-existent server process. ::: ### b :::warning UDP Client doesn't establish a TCP connection with the server. ::: ### c :::warning If you use different port numbers, then the client will attempt to establish a TCP connection with the wrong process or a non-existent process. ::: ## P28 ![](https://i.imgur.com/tYRIZ4U.png) :::warning 課本 <span>UDPClient.py</span> ![](https://i.imgur.com/9TGAMbD.png) 課本 <span>UDPServer.py</span> ![](https://i.imgur.com/EjDoX60.png) :::