introduction to computer networks –term project
Post on 30-Dec-2015
33 Views
Preview:
DESCRIPTION
TRANSCRIPT
Introduction以 2~4 位同學一組,設計並實作一網路應用程式。Ex:
聊天室 (1)FTP (2)UDP 檔案傳輸 ( 模擬 TCP 的確認 / 重傳機制 ) (3)網頁代理伺服器 (Web Proxy Server) (4)
聊天室(cont.)Command Summary
Who : list all the user name and related info.tell <user_id#> <message> : send only to
<user_id#> (i.e., socket id)yell <message> : broadcast the message
<message> to all users.name <name>: set my name to <name> and
broacast to all users.
聊天室(cont.)Other detail
Whenever a client comes in, broadcast as follows.*** User '(no name)' entered from 140.114.215.63. ***
Whenever a client leaves, broadcast as follows.*** User 'student0' left. ***
基本防呆 Ex. 暱稱不可重複
聊天室 Demo Scenario% who # All IDs must be distinct between 1 ~ 30. 1 (no name) 140.114.215.62 <- me% name 曾佣躬 *** User from 140.114.215.62 is named ' 曾佣躬 '. ***% who 1 曾佣躬 140.114.215.62 <- me
*** User '(no name)' entered from 140.114.215.63. ***% who 1 曾佣躬 140.114.215.62 <- me 2 (no name) 140.114.215.63 *** User from 140.114.215.63 is named ‘ 金逼哀 '. ***
聊天室 Demo Scenario(Cont.)% who
1 曾佣躬 140.114.215.62 <- me2 金逼哀 140.114.215.63*** User '(no name)' entered from 140.114.215.64. ***
% who1 曾佣躬 140.114.215.62 <- me2 金逼哀 140.114.215.633 (no name) 140.114.215.64
% yell 隨諸到 Term Project 怎麼做?教教我!*** (no name) yelled ***: 歹勢,我也步知稻。 :-(*** 金逼哀 yelled ***: 我豬盜!混容易的啦!
% tell 2 欸!我粉認真,請告訴我啦!*** 金逼哀 told you ***: 好阿!讓偶直接把檔案送給你!
8
FTP [RFC 959]
FTP stands for File Transfer Protocol.Transfer files to/from a remote hostClient/server model
Client side: the side that initiates transfer (either to/from remote)
Server side: remote host
file transferFTP
server
FTPuser
interface
FTPclient
local filesystem
remote filesystem
user at host
9
FTP It utilizes the following two ports:
20: Data port 21: Command port
Important commands USER: Send the user name PASS: Send the password RETR: Retrieve a remote file STOR: Store a file on a remote host PORT: Open a data port PASV: Enter the passive mode
Transfer Mode Active Passive
FTPclient
FTPserver
TCP control connectionport 21
TCP data connectionport 20
12
UDP 檔案傳輸撰寫UDP 檔案傳輸程式,分為UDP Server 與 UDP Client
Client 可向Server「上傳」或「下載」特定檔案。上傳與下載皆要實作。
不需實作類似FTP「顯示路徑與檔案清單」的相關功能
若Client 要求從Server 下載的檔案,Server 無法提供(例如:該檔案找不到),則回傳error。若需上傳檔案至Server,而該檔案已經存在於Server 端,則提示Client 是否覆寫。
13
UDP 檔案傳輸模擬TCP 的確認/重傳機制。(不需實作流量控制)
「應用層」表頭包含欄位: (建議) Sequence Number (32bits) Acknowledgment Number (32 bits) Flags(非必要,用以標示ack flag,8 bits) Application payload size(非必要)
Timeout 觸發之重傳機制不用實作。由於沒有window 與timeout 重傳機制,因此每筆傳輸的資料量大小應為固定大小(如1 byte)。傳輸時,資料送出後,等待Client 回覆ACK,收到ACK 之後再傳送下一筆資料。
14
UDP 檔案傳輸請撰寫一測試 function,用以顯示重傳資料區段 (data segment)的正確性,亦即測試您的seq/ack 機制,可確保檔案完整可靠地傳輸。
實機展示 (demo)時將由助教隨機提供一檔案驗證程式的正確性。
15
UDP 檔案傳輸測試function 中,可測試下述的情況:
(數字代表封包編號) send 1 (傳送端:送封包 1) ack 2 (接收端:下一個希望收到的封包是封包 2)
send 2 (傳送端:送封包 2) ack 3 (接收端:下一個希望收到的封包是封包 3)
send 4 (傳送端:故意漏送封包 3,改送封包 4) ack 3 (接收端:下一個希望收到的封包是封包 3)
send 3 (傳送端:送封包 3) ack 4 (接收端:下一個希望收到的封包是封包 4)
16
Web Proxy Server撰寫一個簡易的Web Proxy Server程式
當連到Web Proxy Server的使用者瀏覽過某個網站上的網頁物件後,這個被瀏覽過的網頁物件會複製一份到Web Proxy Server的快取空間裡,當其他使用者又來連覽相同的網頁物件時,就不透過遠端網路傳輸網頁資料,而是就近在Web Proxy Server的快取空間裡讀取網頁資料,如此可大大的節省頻寬與加快client讀取資料速度
18
Web Proxy Server作業要求
請使用HW1來當web server ,並設計一個Web Proxy Server
當client要連到web server 時,先透過web proxy server ,確認所要求的檔案是否有在proxy server ,沒有的話才連到web server並將檔案download到proxy server ,下一個client連到proxy server 時直接從這裡將網頁傳回給client
19
參考資料RFC 793 : http://www.ietf.org/rfc/rfc0793.txt
TCP 與UDPhttp://www.study-area.org/network/networkfr.htmhttp://www.pcnet.idv.tw/pcnet/network/network_ip_tcp.htm
Hand in your programDeadline: 2009/01/25 PM 23:59:59Write a simple report in text file.A Demo will be held. (1/26, 1/27)Please tar your files (including code and report)
named as 第 X 組 .tar (ex: 第一組 .tar) and login to ftp://140.114.71.32:3212, cs3212/cs321202 Change directory to Term_project and create a directory
named your team, then upload your file in this directory.
top related