public class RF
extends java.lang.Object
implements java.lang.Runnable
The RF class uses multicast UDP packets to communicate with other "hosts", which should be forwarded by most routers, and uses a scheme that allows multiple RF instances to be running simultaneously on a computer with a single IP address. All RF instances should see one another's traffic, so multiple instances on a single PC as well as other instances sharing the same network with the PC will behave as if they're in the same collision domain. By default, the UDP multicast address 224.0.1.38 is used (with group 1301), though a different address can be specified to the constructor.
Modifier and Type | Field and Description |
---|---|
static int |
aCWmax
The maximum size of the collision window
|
static int |
aCWmin
The minimum size of the collision window
|
static int |
aMPDUMaximumLength
The maximum number of bytes allowed in an RF packet
|
static int |
aSIFSTime
The SIFS inter-frame spacing time, in milliseconds
|
static int |
aSlotTime
The slot time, in milliseconds
|
static int |
dot11RetryLimit
The maximum nubmer of retransmission attempts
|
Constructor and Description |
---|
RF(java.io.PrintWriter output,
java.lang.String mcastAddr)
The constructor initializes the simulated RF transceiver and prepares it for
use.
|
Modifier and Type | Method and Description |
---|---|
long |
clock()
The RF layer's local clock.
|
boolean |
dataWaiting()
This non-blocking method returns
true if the RF layer has one or more
packets to deliver to the caller. |
boolean |
inUse()
Inspects the shared channel to see if it's currently being used.
|
byte[] |
receive()
This method blocks until an RF packet arrives, then returns its contents as a byte
array.
|
void |
run()
Starts executing the RF thread, which watches for incoming RF packets and queues
them for delivery.
|
int |
transmit(byte[] data)
This routine takes data from the MAC layer and broadcasts it to all units
on the same subnet.
|
void |
transmitAdmin(byte[] msg)
Do not use this.
|
public static final int aSIFSTime
public static final int aSlotTime
public static final int aCWmin
public static final int aCWmax
public static final int aMPDUMaximumLength
public static final int dot11RetryLimit
public RF(java.io.PrintWriter output, java.lang.String mcastAddr)
output
- If not null, RF layer will print diagnostic information to
this PrintWriter.mcastAddr
- String containing the desired multicast IP address. Defaults
to 224.0.1.38 if this argument is null.public void transmitAdmin(byte[] msg)
public long clock()
public boolean inUse()
true
if at least one
host is currently broadcasting, false
otherwise.true
if the channel is in usepublic boolean dataWaiting()
true
if the RF layer has one or more
packets to deliver to the caller. Since the RF layer is broadcast based,
and has no notion of addresses, it will deliver any intact packet that it
observes on the channel. In other words, this method might return true
even if the packet wasn't intended for the MAC layer that called dataWaiting()
.true
if the RF layer has accumulated one or more packetspublic byte[] receive()
receive()
once
dataWaiting()
reveals that a packet has arrived.public void run()
run
in interface java.lang.Runnable
public int transmit(byte[] data)
data
- The array of bytes to transmit