CS 325 Assignment #3

Broadcasting on the Faux RF Layer

Due Monday, October 9th by 11:59pm
Not accepted after October 12th


Introduction:

For this assignment you will create a multi-threaded application that both broadcasts data via the simulated RF layer, and simultaneously watches for broadcasts from other "hosts". While this assignment isn't officially part of the class project, it will give you experience with some techniques and code that will be required once you start on the 802.11 implementation. In particular: The application you write for this assignment will repeatedly broadcast a "packet" consisting of a simulated MAC address and an eight-byte value representing the current time, but will also watch for transmissions from other applications and display them as they arrive. The application should accept a specific MAC address from the command-line input or, if none is provided, will select a MAC address randomly. For full credit, your program should contain two threads: One that sends packets at random intervals, and a second thread that constantly watches for incoming transmissions and prints them as they arrive. The specifics are spelled out below, following the Resources section.

Resources:

Specifics:

Sample Output

Here's some sample output from a run of my program. I didn't specify a MAC address, so the program chose one randomly (319). The line about the RF layer being initialized is printed by the RF layer itself when the constructor runs. I printed messages from each of my threads so I knew that the "reader" and "writer" were both running. In this example, another host was running (MAC address 39296), so we see the output from my program as it receives packets from host 39296 every few seconds. The clock value is in milliseconds. It doesn't start at zero, but you can subtract one value from another to get an elapsed time. Different hosts might disagree slightly about the current time, but that's ok — we'll deal with that later in the project.

brichards@laptop[201] : java -jar time.jar
Using a random MAC address: 319
(That's 0x13f in hex)
RF layer (v2.2) initialized at Tue Sep 19 19:37:13 PDT 2023 (/192.168.1.62/-16577)
Writer is alive and well
Reader is alive and well
Sent packet: 319 1695177436163    [ 1 63 0 0 1 138 176 114 236 3 ]
Sent packet: 319 1695177437405    [ 1 63 0 0 1 138 176 114 240 221 ]
Received [ 153 128 0 0 1 138 176 115 4 219 ]
Host 39296 says time is 1695177442523
Sent packet: 319 1695177441558    [ 1 63 0 0 1 138 176 115 1 22 ]
Received [ 153 128 0 0 1 138 176 115 32 15 ]
Host 39296 says time is 1695177449487
Sent packet: 319 1695177448967    [ 1 63 0 0 1 138 176 115 30 7 ]
Sent packet: 319 1695177453246    [ 1 63 0 0 1 138 176 115 46 190 ]
Sent packet: 319 1695177456796    [ 1 63 0 0 1 138 176 115 60 156 ]
Received [ 153 128 0 0 1 138 176 115 82 241 ]
Host 39296 says time is 1695177462513
Sent packet: 319 1695177463563    [ 1 63 0 0 1 138 176 115 87 11 ]
Received [ 153 128 0 0 1 138 176 115 105 211 ]
Host 39296 says time is 1695177468371
Sent packet: 319 1695177468541    [ 1 63 0 0 1 138 176 115 106 125 ]
Received [ 153 128 0 0 1 138 176 115 126 94 ]
Host 39296 says time is 1695177473630
Sent packet: 319 1695177472645    [ 1 63 0 0 1 138 176 115 122 133 ]
Sent packet: 319 1695177474826    [ 1 63 0 0 1 138 176 115 131 10 ]
Sent packet: 319 1695177479534    [ 1 63 0 0 1 138 176 115 149 110 ]
Received [ 153 128 0 0 1 138 176 115 178 106 ]
Host 39296 says time is 1695177486954
Sent packet: 319 1695177486364    [ 1 63 0 0 1 138 176 115 176 28 ]
Sent packet: 319 1695177488848    [ 1 63 0 0 1 138 176 115 185 208 ]
Received [ 153 128 0 0 1 138 176 115 199 83 ]
Host 39296 says time is 1695177492307
Sent packet: 319 1695177494324    [ 1 63 0 0 1 138 176 115 207 52 ]
^C

Notes:

Submitting:

I want you to submit your code, as well as a file capturing the output of your program as it sends packets and receives them from other hosts. Zip up your entire project directory and submit that via canvas. Make sure you've submitted everything I'll need to compile and run your code!


Brad Richards, 2023