Kamin Whitehouse :: cs457 Sp '07



Syllabus Slides Schedule
Programming Assignment #1
What You will need to impelemnt a CSMA/CA protocol on wireless nodes for both the base station and the mobile stations.

You may implement a scenario with multiple transmitters and receivers for extra credit worth 10% of the grade for the project. This scenario should demonstrate how CSMA/CA fails, in the sense that data packets can collide.
Where The code for the project can be found in this zip file.
Your final implementation should produce results similar to the applet from the Kurose & Ross website called "802.11 CSMA/CA WITH Hidden Terminals (Chapter 6)".
How You would need to modify the BaseStation.java and MobileStation.java classes in the code provided.

In BaseStation.java you will be implementing two functions: activeAction and receptionAction. These two functions implement the CSMA/CA protocol at the base station. The activeAction function keeps track of the state of the base station and it makes calls to receptionAction which is a another state machine that handles the reception of packets.

In MobileStation.java you will be implementing three functions: activeAction, receptionAction, and BEB. activeAction and receptionAction serve the same purpose as the functions in BaseStation.java, namely maintaining the state of the device and handling packet receptions. BEB is the exponential backoff which will be called by activeAction and receptionAction when necessary.

In more detail, you should implement the following:

BaseStation.java:

The activeAction method is part of the state machine responsible for implementing the protocol. The state variable should be used to maintain the current state of the object. This can be updated correctly by using the changeState(x) method, where x is the new state. In order to send a packet, the procedure is myChannel.receptionAction(emmitedPacket).

Appropriate delays before each case is allowed to proceed:
SIFS_before_emitCTS 3
emitCTS 15
SIFS_beforercvPKT 3
rcvPKT 61
SIFS_before_emitACk 3
emitACK 10


receptionAction needs to handle incoming packets to the node. In the node is idle, you should check that the packet in not corrupted and the packet type is RTS. If this is so, set the currentSender to the owner of the incoming packet and change state to SIFS_before_emitCTS. The other option is that we are currently receiving a packet and should check for a corrupted packet and the current owner should be the current packet's owner and the packet type should be PKT. If this is so, change state to SIFS_before_emitACK. If not, go back to idle and remove current sender.

MobileStation.java

Appropriate delays before parts of each case are allowed to proceed:
DIFS_beforeCountdown 5
countdown 5
emitRTS 15
SIFS_before_rcvCTS 3
rcvCTS 16
SIFS_before_emitPKT 3
emitPKT 60
SIFS_before_rcvACK 3
rcvACK 11


activeAction:
If the node is in an idle state and there are packets to send. Check to see if the channel is busy and that nav is not zero and if either fail, perform a random backoff. So long as there are packets to send, change to the DIFS_beforeCountdown state. Once in the DIFS_beforeCountdown state, see if enough time has elapsed before moving along to the next state. You should also check if either the channel is busy or nav is not zero and if so, change to the DIFS_beforeCountdownState. Within the coundown state, if enough time has elapsed, decrement the backoff value (backoffValue) and change to the current state. You should also check if either the channel is busy or nav is not zero and if so, change to the countdown state. Case emitRTS will wait for its time and make a call to receptionAction to send the packet and change to a new state. SIFS_before_rcvCTS only needs to wait and then change to the next state. rcvCTS will wait then call the random backoff before going back to the DIFS_beforeCountdown state. SIFS_before_rcvPKT will simple wait then change to the next state. emitPKT is responsible for transmitting the packet after the required wait then moving on to the SIFS_before_rcvACk state. This state simply waits and then moves on. rcvACK will wait and then perform a random backoff before going back to DIFS_beforeCountdown.

receptionAction:
Both the idle and DIFS_beforeCountdown states do the same thing. They check for a corrupted packet and that packet.getNav() is larger then the nav variable. If so, set nav to the packet's nav. If the state is rcvCTS then check for a corrupted packet and the owner is the current node (this) and the packet type is CTS. If so, change state to SIFS_before_emitPKT. If something fails, backoff and change to state DIFS_beforeCountdown. The last case that must be handled is rcvACK, so check for a corrupted packet and the owner is the current node (this) and the packet type is ACK. If so, decrement (packetToSend) because we are done and if there are more packets to send, set CWorder to 3 and backoff randomly before changing to the DIFS_beforeCountdown state. If there are no more packets to transmit, go to the idle state. If something was wrong, backoff and change to the DIFS_beforeCountdown state.

You should hand in all of the files in a zipped folder, along with some documentation to help the graders understand your code. The files should compile with the standard java compiler.

Submit your project via the Toolkit website for the CS and ECE sections. Your submission should contain the names and student IDs of the team members along with the code.
Why RTS/CTS/ACK sequence correct -- 5 points
Correctly placed delays -- 3 points
Deferring based on CTS and ACK messages to other nodes -- 2 points
Demonstrating collisions on the main packet by allowing multiple nodes to act as receivers (ie. the extra credit) -- 1 point
When This assignment is due at midnight on April 26th.


Kamin Whitehouse
Computer Science Department
The University of Virginia
217 Olsson Hall
Charlottesville, Virginia 94720