This project has three goals:
The code of simplex-talk is the basis for this project. Migrate the networking code form simplex-talk into simple-data as needed. To understand this code, refer to Beej's Guide to Network Programming (thank you Brian Hall!).
Copy the [repo]/class/simple-talk folder to your folder [repo]/[user]/simplex-talk folder, compile and run. The makefile does a local run. Please read the makefile and code carefully and experiment by running the server and client on different machines in the lab.
To benefit from this code, as you migrate it, you must read it, grok it, even adore it
Finally, accomplish the task of this project. Copy the template files [repo]/[class]/proj1 to youre [repo]/[user]/proj1 folder, add and commit with message -m "initial commit". Work your changes, committing when you reach a subgoals (at least). Commit on the due date with the message -m "submitted for grading".
NAME simple-data-s, simple-data-c --- client/server pair to send a message SYNOPSIS simple-data-s [-v] [-p port] [-l count] simple-data-c [-v] [-p port] host message DESCRIPTION Server listens on the default port, or port given by the -p option, for a data packet from the client. It prints out the message and number on separate lines and then repeats for count repetitions then exits. It repeats forever if count is 0, which is the default. Client sends a single data packet to the host at given host, with message and number according to the data format. Message is a text message of equal or less than 255 bytes. OPTIONS -l server is to receive count messages and exit. Default is 0, which means to loop forever -p port for client to send to, server to listen on. Default is port 5432. -v verbose ARGUMENTS Host, the name of the host the client will send the data packet to. Message, a 255 or fewer byte text message OUTPUT Without verbose options, server is silent except for printing each message and number on two separate lines. The message is printed between two pipe characters ("|") and any non-printable characters are printed as a dot ("."). [Added 1 Feb 2019: the number is the size of the received packet.] HISTORY New for csc424-182. Simplified csc424-192 for just sending the message
You are to send by TCP a data packet of n+1 bytes, where n is the text message length. The first byte is n, the message size. Note that this means messages are at most 255 bytes long. The null termination byte is not sent among the characters.
0 1 2 ... n
+-----------------+
|len| message |
+-----------------+
The message need not be a string. In testing, it is hard to test a non-string message because command line arguments are necessarily strings. Students often error on their handling of the null string termination character. The string "hello" must be sent as exactly 5 characters, without the null termination character. To print the received message, the server code will put back the null terminator.
The default target does a localhost test. The Makefile understands prerequisites so first the default target (just typing "make") makes sure the dot-c's are compiled, and will compile them if they are not. Then it runs the server. Then it runs the client with hostname "localhost" and message "hello world". The server writes what it receives to the test.out file, which is then compared (using diff) to the test.ref file.
The clean target is then invoked to remove the build products and the test.out file.
"Localhost" is the IP address 127.0.0.1; and it refers to the machine itself. Message to and from localhost go through the socket and layer 4 (TCP/UDP), layer 3 (IP), but are just sent as a local memory copy for layer 2 (which might have been Wifi if the packet really had to get someplace else).
A more fun test is to run the client and server on different machines, so the packet actually travels the Internet. To do this, start an AWS instance, connect to the instane, and note the IP address used in the connect string. Pull your repo onto the instance and then "make run-server".
On your local machine, pull the repo, edit the Makefile changing localhost to the IP address note above, and "make run-client".
Note that a custom security filter rule, allowing TCP port 5432 must be installed for the instance. Else the UPD packet gets dropped at Amazon's gateway.
You can carry out this project using the lab, your own computer, or a combination. But in class I showed how to use Amazon AWS, and think that this is a good time for you to learn how to create an ECC instance (Elastic Cloud Computing).
To review the process:
author: burton rosenberg
created: 25 jan 2018
update: 24 jan 2019