Contact me through ( email@example.com ) so that we can talk about this
In this week’s lab, you will send messages between machines using TCP. Start from the template tcp.py and your code from last week. In this lab, the server receives the messages using your code from last week. The client code that sends the messages is provided in the template.
This is a team assignment; each team should be two members unless a different size is approved by the instructor.
The program has at least the following methods; you should add others to improve the modularity of your procedures.
This method is provided in its entirety in the template.
Prompts the user for the network operation to perform (tcp send or tcp receive) and then calls the selected function with appropriate argument values (as specified in the constants at the start of the program)
• This method is invoked with a main() function call at the end of the program.
tcp_send(server_host, server_port, message)
This method is provided in its entirety in the template.
This method creates a single TCP connection to the already-waiting server and sends multiple files to the server. It checks the single-character status received from the server and displays it to the user.
o server_host: string with destination IP address or host name
o server_port: integer designating destination port number
This port will likely have to be above the “system” range (above 13).
o Prompt the user for the number of lines to send. Pack and send this number as a four-byte big-endian unsigned integer
o Prompt the user for each line. Send each line as it is written.
o Await the status byte sent by the server. Report the status to the user (e.g. “File accepted”)
o Close sockets and exit.
o Ask client if he/she would like to send another message.
Listen for a TCP connection on a specified port, receive and display multiple messages from a single client over a single socket, and send a one-character response.
Multiple files will be sent, each as a separate message over the same TCP channel.
For each file uploaded, the same format is used as in last week’s lab: the client first sends four (big-endian) bytes indicating the number of lines as a binary number. The client then sends each of the lines as ASCII text, terminated only by ‘n’.
Multiple messages are sent over the same TCP connection. The server saves the file with a sequential number — 1.txt for the first upload, .txt for the second upload, etc. The client sends a message with zero lines to indicate that it is done sending messages.
The server responds with the single ASCII character ‘A’ to indicate it accepts the file, or ‘Q’ to indicate it is quitting if the file contains zero lines. You may optionally save the zero-line message or not.
The server then waits for the client to send the next file, or closes the connection if the file contained zero lines.
o listen_port: integer designating receiving port number
This port will likely have to be above the “system” range (above 13). Port numbers in the system range (-13) can usually only be opened by a program running as Administrator or root.
o Connect to the specified listening port
o Accept a connection
o Until a zero-line message is received:
Receive a message
Save the message, the first message to the file 1.txt, the next message to the file .txt, etc. Files uploaded over previous socket connections are overwritten.
Send a single-character response.
o Close the sockets
The provided next_byte function is shown below. This method is also included in the template tcp.py. Unlike the “magic” method you used in your designs, this method requires a tcp data connection to operate. As described in the procedure below, you will need to pass extra arguments to get the data socket to the next_byte calls. Do not use global variables.
1. def next_byte(data_socket):
3. Read the next byte from the socket data_socket.
5. Read the next byte from the sender, received over the network.
6. If the byte has not yet arrived, this method blocks (waits)
7. until the byte arrives.
8. If the sender is done sending and is waiting for your response, this method blocks indefinitely.
1. :param data_socket: The socket to read from. The data_socket argument should be an open tcp
11. data connection (either a client socket or a server data socket), not a tcp
1. server’s listening socket.
13. :return: the next byte, as a bytes object with a single byte in it
16. return data_socket.recv(1)
This method is included in the tcp.py template.
1. Download the skeleton Python template: tcp.py
. Edit the header of the file to include your team members’ names, the proper date, etc.
3. Adapt your design from last week to the body of tcp.py. You will need to pass extra arguments to get the data socket to the next_byte calls. Do not use global variables!
. Design the code to implement the new features required for the receiver for this week, including the ability to receive multiple messages and to send the required one-character responses.
5. Test that you are able to get ANY information through the TCP connection
6. (optional) Use Wireshark to view the messages as they travel between nodes. You may want to filter the messages with a filter like ip.addr==220.127.116.11, where you replace 18.104.22.168 with the IP address of the other machine. This might help with debugging. (Although returning to last week’s testing next_byte method might help even more)
7. Work out any bugs in your algorithm so the server meets the specification
Divide up the primary responsibility for parts of the program in an equitable way. Each team member should be given at least one method to write, if there is more than one method added to this week’s code. In the comments for the method, include the author of the method like this: :author: Phileas Fogg
Test your software by running two copies of the program on two different systems (network nodes). For debugging purposes, you may wish to test your program on your local machine with localhost
“PLACE THIS ORDER OR A SIMILAR ORDER WITH ESSAY PAPER LTD AND GET AN AMAZING DISCOUNT”