$24.99
Grading
We will test and grade your program on the stu server. Please make sure that your programs run correctly on stu. Moreover, you can use libraries installed in public folders of stu (e.g. /usr/lib) only.
We accept submission of Python 3 (3.8), Java, or C/C++ program, and we recommend that you use Python 3 for your assignments. Programming languages other than Python 3, Java, and C/C++ are not allowed. For Python 3, we use the python3 program installed in folder /usr/bin on stu for grading. If you use Java or C/C++, we will compile and run your program for grading using the default compilers on stu (openjdk 17 installed in /usr/local/jdk/bin, or gcc 9.4.0 installed in /usr/bin). For C/C++ users, we will link your program with zlib during compilation. The grading script infers your programming language from the file extension name (.py, .java, .c). Therefore, please ensure your files have the correct extension names. For a Java program, the class name should be consistent with the source file name, and please implement the static main() method so that the program can be executed as a standalone process after compilation.
We will grade your program based on its correctness only. A grading script will be used to test your program, and no manual grading will be provided.
Program Submission
For individual submission, please submit a zip file that contains source programs and submit it to the Assignment_2_student_submission folder of LumiNUS Files.
• Please name your zip file as <Matric number>.zip, where <Matric number> refers to your matric number that starts with the letter A. Note that your student number’s first and last letters should be capital letters. One example file name would be A0112345X.zip.
two source pro grams,
• Your zip file should only containAlice.py and Bob.py. If you use Java, C, or C++, replace “.py” with “.java”, “.c”, or “.cpp”, respectively. Do not put your programs under any subfolders (or package paths).
Special Instructions for Group Submission
• Designate one person to submit the zip file for group work instead of two different persons submitting the same file twice.
• The file name should contain the student numbers of two members and be named as <Matricnumber1>-<Matricnumber2>.zip. An example would be A0165432XA0123456Y.zip.
• Do not change the designated submitter! If the group needs to upload a new version, it should be done by the same designated submitter as well.
We will deduct 1 mark for every type of failure to follow instructions (e.g. wrong program name, wrong zip file name, folder structure).
Grading Rubric
no man ual grad
We will grade your programs based on their correctness only. A grading script will be used to test your programs, and ing will be provided. The grading script infers your programming language from the file extension name (.py, .java, .c). Therefore, please ensure your files have the correct extension names. For a Java program, the class name should be consistent with the source file name. Please implement the public static main() method so that the program can be executed as a standalone process after compilation.
no ad di tional
1. [1 point] Programs are free from syntax errors and can be successfully executed (or compiled for Java/C/C++). Program execution follows the specified commands strictly. Source files are correctly named, and there are
sub fold ers in side the zip file.
2. [1 point] Programs can successfully send chat messages from Alice to Bob in a perfectly reliable channel (i.e. no error at all).
3. [2 points] Programs can successfully send messages from Alice to Bob in the presence of packet corruptions.
4. [2 points] Programs can successfully send messages from Alice to Bob in the presence of packet losses.
5. [1 point] Programs can successfully send messages from Alice to Bob in the presence of both packet corruptions and packet losses.
NOTE:
• The chat messages received by Bob must be identical to the ones sent by Alice to claim a successful transmission.
• The total size of input messages to Alice is guaranteed to be no larger than 5,000 bytes (including newline characters).
• During grading, Alice and Bob processes will be forced to terminate 10 seconds after Alice is started. The grading script will then compare the output of Bob against the input of Alice. Please ensure your programs are efficient enough to meet the above criteria.
re move all de bug mes sages
CAUTION: The grading script grades your program according to what Bob prints out on the screen. Thus, make sure that youbefore you submit your solution. No points will be awarded in each test case if your output does not conform to the expected result.
Question and Answer
We will not de bug pro grams for you.
If you have any doubts about this assignment, please post your questions on LumiNUS forum before consulting the teaching team.
A Word of Advice
Do not post your solution in any public domain on the Internet or share it with friends, even after this semester.
Overall Architecture
There are three programs involved in this assignment, Alice, UnreliNET and Bob (see Figure 1 below).
• The UnreliNET program is used to simulate the unreliable transmission channel (in both directions) that randomly corrupt or drop packets. You can assume that UnreliNET always delivers packets in order.
Figure 1: UnreliNET Simulates Unreliable Network
Your task is to de
The UnreliNET program is complete and provided in the assignment.velop the Alice and Bob programs so that Bob will receive chat messages successfully in the presence of packet corruption and packet loss.
UnreliNET Program
To run UnreliNET on sunfire, type the following command:
java UnreliNET <P_DATA_CORRUPT> <P_DATA_LOSS>
<P_ACK_CORRUPT> <P_ACK_LOSS> <unreliNetPort> <rcvPort> For example:
java UnreliNET 0.3 0.2 0.1 0.05 9000 9001
The above command makes UnreliNET listen on port 9000 of localhost and forwards all received data packets to Bob running on the same host with port 9001, with 30% chance of packet corruption and 20% chance of packet loss. The UnreliNET program also forwards ACK/NAK packets back to Alice, with a 10% packet corruption rate and a 5% packet loss rate.
max imum pay
Note that UnreliNET only accepts packets with a load of 64 bytes (inclusive of user-defined header/trailer fields). It will drop any packet beyond this size limit and show an error message on the screen.
Packet Error Rate
[0, 0.3].
If you have trouble getting your code to work, set the parameters to 0 first for debugging purposes.
Alice Program
stan dard in
• Alice will read chat messages from put and send them to UnreliNET
(which will then forward to Bob as appropriate).
ASCII char ac ters
• The chat messages contain only, and there is no empty message (i.e. blank line).
no de
• There’s lay regarding the input to Alice.
To run Alice on stu, type the following command:
python3 Alice.py <unreliNetPort>
<unreliNetPort> is the port number UnreliNET is listening to. For example:
python3 Alice.py 9000
Bob Program
stan
• Bob receives chat messages from Alice (via UnreliNET) and prints them to-
dard out put.
The command to run the Python version of Bob is:
python3 Bob.py <rcvPort> For example:
python3 Bob.py 9001
With the above command, Bob listens to port 9001 of localhost and prints all received messages to the standard output.
Some tips are given below:
1. Bob should only print messages that are correctly received from Alice, no more, no less.
re move all de bug mes sages be fore sub mis sion
2. Make sure you do not print anything irrelevant to standard output. In particular, remember to.
Running All Three Programs
For this assignment, you will always run UnreliNET, Alice and Bob programs on the
same host.
1. You should launch Bob first.
2. Followed by UnreliNET in the second window.
3. Finally, launch Alice in a third window to start data transmission.
should
• The Alice and Bob programs not communicate directly – all traffic has to go through the UnreliNET program.
• Alice should terminate once all input is read from the user and adequately forwarded (i.e. the input stream is closed and Bob successfully receives everything in the input stream).
• There is no need for Bob to detect the end of transmission and terminate. If you need to manually terminate it, press <Ctrl> + c.
Testing Your Programs
To test your program, please use your SoC UNIX ID and password to log on to stu as instructed in Assignment 0.
If you test your server manually, please select a port number greater than 1024 because the OS usually restricts the usage of ports lower than 1024. If you get a BindException: Address already in use (or similar errors for other languages), please try a different port number.
For the convenience of testing, you can use the file redirection feature to let Alice read from a file (rather than from keyboard input).
For example, you can run Alice as follows:
python3 Alice.py <unreliNetPort> < input.txt
You can replace input.txt with another file name if you wish.
In the same way, you can let Bob print to a file (rather than print on screen - just for the convenience of testing):
python3 Bob.py <rcvPort> > output.txt
Remember to flush the output buffer so that data will be written to output.txt.
Finally, you can compare input.txt to output.txt by issuing the following command:
cmp input.txt output.txt
This line compares two files byte by byte and prints the differences if found. If the two files are binary equivalent, nothing will be printed on the screen. This method is useful to detect unexpected outputs such as hidden characters.
A sample input.txt is provided for your testing.
hid den
in the same
di rec
To use the grading script, please upload your programs and the test folder given in the package to stu. Make sure that your programs and the test folder are tory. Then, you can run the following command to test your programs: bash test/RunTest.sh
By default, the script runs through all test cases. You can also choose to run a certain test case by specifying the case number in the command:
bash test/RunTest.sh 2
To stop a test, press <Ctrl> + c. If pressing the key combination once does not work, hold the keys until the script exits.
Self-defined Header/Trailer Fields at Application Layer
1. Sequence number
2. Checksum
You are reminded again that each packet Alice or Bob sends should contain at most 64 bytesofpayloaddata(inclusiveofuser-definedheader/trailerfields), or UnreliNET will drop it.
Computing Checksum
To detect bit errors, Alice should compute the checksum for every outgoing packet. Please refer to Assignment 0 exercise 1 on how to compute the checksum.
Timer and Timeout Value