Assignment 1 Introductory Socket Programming (Python代写,北美程序代写,美国程序代写,CS436代写)

The goal of this assignment is to gain experience with both TCP and UDP socket programming in a client-server environment (Figure 1). You will use Python or any other programming language to design and implement a client program (client) and a server program (server) to communicate between themselves.

联系我们
微信: biyeprodaixie 欢迎联系咨询

本次CS代写的主要涉及如下领域: Python代写,北美程序代写,美国程序代写,CS436代写

Assignment 1

Computer Networks (CS 436/636) Winter 2022

Introductory Socket Programming

Work on this assignment is to be completed individually

 

  1. Assignment Objective

The goal of this assignment is to gain experience with both TCP and UDP socket programming in a client-server environment (Figure 1). You will use Python or any other programming language to design and implement a client program (client) and a server program (server) to communicate between themselves.

 

 

 
 
  1. Assignment Specifications
    1. Summary

In this assignment, the client will send requests to the server to reverse strings (taken as a com- mand line input) over the network using sockets.

This assignment uses a two-stage communication process. In the negotiation stage, the client and the server negotiate through a fixed negotiation port (<n_port>) of the server, a random port (<r_port>) for later use. Later in the transaction stage, the client connects to the server through the negotiated random port (<r_port>) for actual data transfer.

    1. Signaling

The signaling in this project is done in two stages as shown in Figure 2.

Stage 1. Negotiation using TCP sockets: In this stage, the client creates a TCP connection with the server using <server_address> as the server address and <n_port> as the negotiation port on the server (where the server is listening). The client sends a request to get the random port number from the server where it will send the actual request (i.e., the string to be reversed). To initiate this negotiation, the client sends a request code (<req_code>), an integer (e.g., 13), after creating the TCP connection. If the client fails to send the intended <req_code>, the server closes the TCP connection and continues listening on <n_port> for subsequent client requests. Once

 

 

 
 
the server verifies the <req_code>, it replies back with a random port number <r_port> where it will be listening for the actual request. After receiving this <r_port>, the client closes the TCP connection with the server.

Stage 2. Transaction using UDP sockets: In this stage, the client creates a UDP socket to the server in <r_port> and sends the <msg> containing a string. On the other side, the server re- ceives the string and sends the reversed string back to the client. Once received, the client prints out the reversed string and exits. Note that the server should continue listening on its <n_port> for subsequent client requests. For simplicity, we assume, there will be only one client in the system at a time. So, the server does not need to handle simultaneous client connections.

    1. Client Program (client)

You should implement a client program, named client. It will take four command line inputs:

<server_address>, <n_port>, <req_code>, and <msg> in the given order.

    1. Server Program (server)

You should also implement a server program, named server. The server will take <n_port> and

<req_code> as a command line parameters.

 

    1. Example Execution
      • Run server: python Server.py <n_port> <req_code>
      • Run client: python Client.py <server address> <n_port> <req_code> 'A man, a plan, a canal— Panama!'
  1. Hints

Below are some points to remember while coding/debugging to avoid trivial problems.

  • You can use and adapt the sample codes of TCP/UDP socket programming in Python slides (last few slides Chapter 2).
  • Use port id greater than 1024, since ports 0-1023 are already reserved for different pur- poses (e.g., HTTP @ 80, SMTP @ 25)
 
  • Make sure that the server is running before you run the client.
  • You must be able to run the client and the server on two different machines in the un- dergrad environment linux.student.cs.
  • If both the server and the client are running in the same system, 127.0.0.1 or localhost can be used as the destination host address.
  • You can use help on network programming from any book or from the Internet, if you properly refer to the source in your programs. But remember, you cannot share your program or work with any other student.
  1. Procedures
    1. Due Date
    2. Hand in Instructions

Submit all your files in a single compressed file (.zip, .tar etc.) using LEARN in dedicated Dropbox. The filename should include your username and/or student ID.

You must hand in the following files / documents:

  • Source code files.
  • README file: this file must contain instructions on how to run your program, which under- grad machines your program was built and tested on, and what version of make and com- pilers you are using.

Your implementation will be tested on the machines available in the undergrad environment

linux.student.cs.

 

    1. Documentation

Since there is no external documentation required for this assignment, you are expected to have a reasonable amount of internal code documentation (to help the markers read your code).

You will lose marks if your code is unreadable, sloppy, or not efficient.

    1. Evaluation

Work on this assignment is to be completed individually.

  1. Additional Notes:
  • You must ensure that both <n_port> and <r_port> are available. Just selecting a random port does not ensure that the port is not being used by another program.
  • All codes must be tested in the linux.student.cs environment prior to submission.
  • Make sure that no additional (manual) input is required to run any of the server or client other than what is required above.