南加利福尼亞大學
南加利福尼亞大學(University of Southern California),又譯南加州大學,簡稱南加大(USC),是美國西海岸最古老的頂尖私立研究型大學,世界著名高等學府,位于美國加利福尼亞州洛杉磯市,1880年由監(jiān)理會創(chuàng)立,是美國大學協(xié)...
南加利福尼亞大學CS353 Assignment1課業(yè)解析
題意:
建立一個聊天系統(tǒng),支持客戶端之間的通訊
解析:
任務(wù)的主要目的是對客戶端-服務(wù)器網(wǎng)絡(luò)模型的應(yīng)用程序的實踐,需要使用python3.5以上進行開發(fā)。
任務(wù)分為三個步驟
part1:一臺客戶端和一臺服務(wù)器??蛻魴C和服務(wù)器之間使用UDp嵌套字來進行信息交換。服務(wù)器在指定的端口運行,客戶端鏈接到服務(wù)器后使用客戶端的名稱發(fā)送注冊信息,之后等待用戶的輸入。同時需要實現(xiàn)以下的命令行指令: 服務(wù)端指令:-p portno(服務(wù)器的端口號) -l logfile(日志文件名字) 客戶端指令:-s serverIp(服務(wù)器的地址) -p portno(客戶端連接到服務(wù)器的端口) -l logfile(日志文件名) -n myname(客戶端的名字) 并且在客戶端輸入exit,應(yīng)該終止客戶端,在服務(wù)端上按下ctrl+C終止服務(wù)器。
part 2:多客戶端和一臺服務(wù)器。將part-one進行擴展,為了支持多客戶端之間的信息交換,需要fork一個線程為每個客戶端建立鏈接,這樣就能同時處理。而且需要添加額外的消息類型表明消息來自或發(fā)送到哪個客戶機。
part3:多客戶端和多服務(wù)端。多個服務(wù)器之間以TCp socket建立一個網(wǎng)絡(luò),客戶端能夠通過服務(wù)器連接到另一個服務(wù)器的客戶機,從而實現(xiàn)聊天系統(tǒng)。
涉及知識點:TCp,UDp,python
更多可加微信討論
微信號:aaaapple1208
CS 353: programming Assignment 1
Introduction:
In this assignment you will build a chat system to support messaging between clients. For
example,the sample topology below shows a network of servers. The clients are
connected to the server overlay that allows direct and indirect communication described
below:
1. Communication of clients within the same server: If Client1 wants to talk to
Client2,it rendezvous through server A as shown: (Client1→ServerA→Client2)
2. Communication of clients across servers: If Client1 wants to talk to Client3,the
message is transmitted to server,which then transmits it to ServerB which
forwards it to Client3 as shown: (Client1→ServerA→ServerB→Client3)
The main goal of this assignment is to give you hands-on experience in developing an
application using the client-server networking model. In this assignment you will learn
how to program with both UDp and TCp sockets and develop hands-on experience in
how to support higher level application requirements such as transmitting and receiving
messages from distributed clients. The connections between a server and clients will be
UDp based and the connection between servers will be TCp based.
This assignment also provides insights into the Internet’s best-effort packet forwarding
and routing process. This assignment must be developed in python 3.5+ and is
organized into three parts.
THE pARTS
I. One Client and One Server: Develop a chat server and client application using UDp
sockets to exchange information across the network. The server runs on a port
specified at the command line. The client connects to the server and sends a register
message with a client name and then waits for the user input.
Command Line Options:
> server –p portno –l logfile
where
-p portno the port number for the chat server
-l logfile name of the logfile
> client –s serverIp –p portno –l logfile –n myname
where
-s
-n
If nothing is specified on the command line the server and client programs
should print the usage instructions and quit.
Typing exit in the client terminal,should terminate the client. Entering Ctrl+C in
the server terminal should terminate the server.
Message Types:
The client messages to the server MUST be formatted as follows:
1. register
The server messages to the client MUST be formatted as follows:
1. welcome
Required Terminal Output:
The following lines of output displayed on the terminal:
client input:
> client.py -s
>exit
client output:
client1# connected to server and registered
client1# waiting for messages..
client1# exit
server input:
>server.py -p
> (Ctrl+C)
server output:
client1 registered from host
Required Log Files:
The following lines of output MUST be present in the logfiles. You can also
print additional debugging information in the logfiles,but prepend debugging
information with the keyword “DEBUG” so we can ignore it during grading.
The text in the angled brackets below should be replaced with the results from the
communication between the client and server. Do not include the angled brackets
in the output
Server Logfile
server started on at port …
client connection from host
received register
terminating server…
Client Logfile
connecting to the server at port
sending register message
received welcome
terminating client…
II. Multiple Clients and One Server: Extend the above server and client programs
to support exchange of messages across the network between multiple clients
rendezvousing at the server. You will need to fork a thread for each client
connection so that you can handle them concurrently . The client and server
should support two additional message types,namely sendto and recvfrom .
Additionally,the server should log messages received for unknown clients.
Note: the server and client command line remains the same and hence is not repeated
below.
Message Types:
The client messages to the server MUST be formatted as follows:
1. sendto
The server messages to the client MUST be formatted as follows:
1. recvfrom
Required Terminal Output:
The following lines of output displayed on the terminal:
client1 input: >client.py -s
>sendto client2 hello there
>exit
client1 output:
client1# connected to server and registered
client1# waiting for messages..
client1# sendto client2 hello there
client1# exit
client2 input:
>client.py -s
>exit
client2 output:
client2# connected to server and registered
client2# waiting for messages..
client2# recvfrom client1 hello there
client2# exit
server input: >server.py -p
> (Ctrl+C)
server output:
client1 registered from host
client2 registered from host
terminating server...
Required output:
The following lines of output MUST be present in the logfiles. You can also print
additional output in the logfiles,but prepend debugging information with the
keyword “DEBUG” so we can ignore it during grading. The text in the angled
brackets below should be replaced with the results from the communication
between the client and server
Server Logfile
server started on at port …
client connection from host
received register
from host
received register
from
recvfrom
Client1 Logfile
connecting to the server at port sending register message
received welcome
sendto
Client2 Logfile
connecting to the server at port sending register message
received welcome
recvfrom
III. Multiple Clients and Multiple Servers: Extend the server program to support
TCp socket connections from one or more servers to create a chat server
overlay network. Clients can now chat to other indirectly connected clients on
the chat server overlay.
When a server receives a sendto message from a client,it should forward the
message to the receiving client if it is locally connected or forward the
message to all connected servers if the client is not local. Each receiving
server processes the message similarly,that is,it will forward it to the client
if it is connected locally or if the client addressed in the message is not
located at the current server,it will forward the message to all other
connected servers. The command line options for the client program remain
the same. The command line options for the server program are extended
below.
Note: Clients will send messages only to the known entities inside the
overlay network
Command Line Options:
> server –s serveroverlayIp –t serveroverlayport –o overlayport –p portno –l
logfile
Where
-s serveroverlayIp: This parameter is the Ip address of the server that
you want to connect to (Optional).
-t serveroverlayport: This parameter is the port number of the same
server which you want to connect to via TCp (Optional).
-o overlayport: This parameter is the port which will be used by other
servers to connect to you via TCp (Mandatory).
-p portno: This parameter is the port number over which clients will
connect with you via UDp (Mandatory).
-l logfile: Name of the log file (Mandatory).
All the arguments are not mandatory for a server to spawn. For example,if the first
server is being spawned,it will not have a –s and –t options since it does not want
to connect to anyone (No other servers exist as of now).
However,from second server onward,-s and –t will be necessary in order to
create the connections. The mandatory arguments are –o,-p,and –l
Required Terminal Output:
The following lines of output displayed on the terminal:
ServerA input:
>server.py -o
> (Ctrl+C)
ServerA output:
server overlay started at port
client1 registered from host
server joined overlay host
ServerB input
>server.py -s
> (Ctrl+C)
ServerB output
server overlay started at port
client2 registered from host
Client input and output shall be the same as part II
Required output:
The following lines of output MUST be present in the logfiles. You can also print
additional output in the logfiles,but prepend debugging information with the
keyword “DEBUG” so we can ignore it during grading. The text in the angled
brackets below should be replaced with the results from the communication
between the client and server
ServerA Logfile
server started on at port
server overlay started at port
client connection from host
received register
client connection from host
received register
sendto
recvfrom
server joined overlay from host
sendto
sending message to server overlay “message string”
terminating server…
ServerB Logfile
server started on at port …
server overlay started at port
client connection from host
received register
sendto
recvfrom
terminating server…
Client1 Logfile
connecting to the server at port
sending register message
received welcome
sendto
terminating client…
Client2 Logfile
connecting to the server at port
sending register message
received welcome
recvfrom
terminating client...
Code and Collaboration policy
You are encouraged to refer to the socket programming tutorials. You can discuss the assignment
and coding strategies with your classmates. However,your solution must be coded and written by
yourself. please refer to the plagiarism policy in the course syllabus.
The submissions will be run through code similarity tests. Any flagged submissions will result in a
failing score. Keeping your code private is your responsibility.
You are strongly encouraged to pair and test your client and server implementations with your
peers in class.
Submission Instructions
You can develop and test your code on your own machines. Create a compressed tar file which
includes a README and the source code.
To submit,create a folder called LASTNAME_FIRSTNAME with the above files. Tar the folder
LASTNAME_FIRSTNAME. Submit the tar file on blackboard.
The README must contain: your USC ID,compiling instructions,additional notes on usage if
needed. (e.g. The default Ip address used for grading is 127.0.0.1[localhost]. If you wish to use any
other addresses,please specify)
You must use python 3.5+. Make sure you add the directives to support direct execution. The
directory structure should look like this
LASTNAME_FIRSTNAME
->Client.py
->Server.py
->README.txt
We will then run your programs using a suite of test inputs. After running the program,we will
grade your work based on the log file output. It is recommended that your implementation be
somewhat modular. This means that you should follow good programming practices—keep
functions relatively short,use descriptive variable names.
Deadline
Due on Sep 29th
Expected Output
Server1 console:
Server2 console:
Client 1 console:
Client2 console:
Server1 logfile:
Server2 logfile:
Client1 logfile:
Client2 logfile:
本文地址:http://v5tt.cn/liuxue/43750.html
轉(zhuǎn)載說明:文章《南加利福尼亞大學CS353 Assignment1作業(yè)輔導(dǎo)》由【留求藝】原創(chuàng)發(fā)布(部分轉(zhuǎn)載內(nèi)容均有注明出處,如有侵權(quán)請告知),轉(zhuǎn)載請注明文章來源。
南加利福尼亞大學(University of Southern California),又譯南加州大學,簡稱南加大(USC),是美國西海岸最古老的頂尖私立研究型大學,世界著名高等學府,位于美國加利福尼亞州洛杉磯市,1880年由監(jiān)理會創(chuàng)立,是美國大學協(xié)...
南加利福尼亞大學(University of Southern California),又譯南加州大學,簡稱南加大(USC),是美國西海岸最古老的頂尖私立研究型大學,世界著名高等學府,位于美國加利福尼亞州洛杉磯市,1880年由監(jiān)理會創(chuàng)立,是美國大學協(xié)...
美國留學南加利福尼亞大學介紹...
南加利福尼亞大學,簡稱南加州大學,是美國西海岸歷史最悠久的頂尖私立研究型大學。...
南加利福尼亞大學(又譯南加州大學,簡稱USC)計算機科學專業(yè)的學生經(jīng)常需要完成各種類型的作業(yè)。...
南加利福尼亞大學即我們常說的南加州大學,屬于美國綜排前三十的院校,也是國內(nèi)學子最愛申請的院校之一。...
南加利福尼亞大學CS353 Assignment1課業(yè)解析 題意: 建立一個聊天系統(tǒng),支持客戶端之間的通訊 解析: 任務(wù)的主要目的是對客戶端-服務(wù)器網(wǎng)絡(luò)模型的應(yīng)用程序的實踐,需要使用Python3.5以上進行開發(fā)。...
南加州大學世界大學排名:2025年QS世界大學排名第125名,2024年南加州大學世界大學排名QS位列第116名,2024年南加州大學世界大學排名USnews位列第28名,在各大世界大學排名體系中,南加州大學始終以其卓越的學術(shù)實力穩(wěn)居前列,......
南加州大學是美國第一所授予電影藝術(shù)學士學位的大學,其電影藝術(shù)學院(USC School of Cinematic Arts)被譽為“離好萊塢最近的學校”,平均每兩年就有一位校友獲得奧斯卡提名。...
2023年QS大學排名學科榜出爐,在傳播與媒介研究領(lǐng)域,阿姆斯特丹大學連續(xù)六年位居首位,南加州大學和倫敦政治經(jīng)濟學院仍穩(wěn)居第2、3名。斯坦福大學升至第4(2022年第6),5-10位分別是德州大學奧斯汀分校、南洋理工大學、賓夕......
從事留學10年以上,幫助過很多的國內(nèi)學生處理留學申請,簽證,生活,學習等各方面的問題,有豐富的留學咨詢和實戰(zhàn)經(jīng)驗。憑借著個人豐富的生活歷程和申請經(jīng)驗,會準確的指導(dǎo)學生海外申請和學習生活的相關(guān)注意事項,成功幫助眾多學子完成夢校留學的夢想。