COMPSCI 356 Computer Network Architectures: Lab 1 An Echo Server

Introduction

This assignment is a warm-up for the following three labs. You are required to implement a simple echo server individually using Python socket API. An echo server can listen on a specific TCP port, and wait for a client to connect. After a TCP connection is established between the echo server and a client, the client can send arbitrary messages to the server and the server will echo back the same message to the client.

Your task is to implement the echo server as well as the client.

Environment

You are required to finish this lab in Linux or Mac OSX environment.

Starter Code

We provide the skeleton code of the echo server and the client code in one python program. The source code contains a main function which is the entry point of the program, a client class, which implements the client, and a server class, which you should modify to implement the server. You should submit the source code and make sure that it can work.

We also provide you the binary code that includes full functions of both the client and server for you to test your implementation. You can execute the binary code in either the client mode or the server mode with the following command (suppose the file name of the binary code is "echo.pyc"):


python echo.pyc s <port>

            

It will start an echo server and listen on the TCP port whose port number is <port>. For example, "python echo.pyc s 9999" will start an echo server and listen on port 9999.


python echo.pyc c <address>  <port>

            

It will start a client to connect to an echo server whose IP address is <address> and port is <port>. For example, "python echo.pyc c 127.0.0.1 9999" will start a client and try to connect to port 9999 in you own machine. Then you can type any message and press "Enter" to send to the server that is running at your machine's port 9999. The client will print the message received from the server on the screen. You can disconnect the client from the server by terminating the process of the client.

We also provide you a simple test script by Python2.7. You can use it to test your code. To use this script, you can use the following command:


python lab1_test_script.py binary_path (e.g. python lab1_test_script.py ./echo.pyc)
                                    
                
If your code is right, you will see the following output:

Test case for Echo Server

For client1, each test case deserves 2 point. For client2, each test case deserves 0.5 point.

Requirements

How to Submit

You must finish this lab individually. Submit a compressed file on Sakai, together with a README file containing your name in it. Please name the compress file in the format of NetID+first_name+LAST_NAME_lab1.zip, for example, sz001_shengbao_ZHENG_lab1.zip .

Last updated: 01/12/2020