avrora.sim.radio
Class SimpleAir

java.lang.Object
  extended byavrora.sim.radio.SimpleAir
All Implemented Interfaces:
RadioAir

public class SimpleAir
extends java.lang.Object
implements RadioAir

Very simple implementation of radio air. It assumes a lossless environment where all radios are able to communicate with each other. This simple air is blind to the frequencies used in transmission (i.e. it assumes that all frequencies are really the same).

This class should provide the proper scheduling policy with respect to threads that more complicated radio implementations can use the time scheduling policy and only overload the delivery policy.


Nested Class Summary
protected  class SimpleAir.MeetEvent
           
 
Field Summary
protected  Channel radioChannel
           
protected  java.util.HashSet radios
           
protected  IntervalSynchronizer synchronizer
           
 
Constructor Summary
SimpleAir()
           
 
Method Summary
 void addRadio(Radio r)
          The addRadio() method adds a new radio to this radio model.
 Synchronizer getSynchronizer()
          The getSynchronizer() method gets the synchronizer for this air implementation.
 byte readChannel(Radio r)
          The readChannel() method reads the value of the channel at the current time so that the last 8 bits transmitted (where the bits are 0 if there are no transmissions) are returned.
 void removeRadio(Radio r)
          The removeRadio() method removes a radio from this radio model.
 int sampleRSSI(Radio r)
          The sampleRSSI() method is called by a radio when it wants to sample the RSSI value of the air around it at the current time.
 void transmit(Radio r, Radio.Transmission f)
          The transmit() method is called by a radio when it begins to transmit a packet over the air.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

radios

protected final java.util.HashSet radios

radioChannel

protected final Channel radioChannel

synchronizer

protected final IntervalSynchronizer synchronizer
Constructor Detail

SimpleAir

public SimpleAir()
Method Detail

addRadio

public void addRadio(Radio r)
The addRadio() method adds a new radio to this radio model.

Specified by:
addRadio in interface RadioAir
Parameters:
r - the radio to add to this air implementation

removeRadio

public void removeRadio(Radio r)
The removeRadio() method removes a radio from this radio model.

Specified by:
removeRadio in interface RadioAir
Parameters:
r - the radio to remove from this air implementation

transmit

public void transmit(Radio r,
                     Radio.Transmission f)
The transmit() method is called by a radio when it begins to transmit a packet over the air. The radio packet should be delivered to those radios in range which are listening, according to the radio model.

Specified by:
transmit in interface RadioAir
Parameters:
r - the radio transmitting this packet
f - the radio packet transmitted into the air

sampleRSSI

public int sampleRSSI(Radio r)
The sampleRSSI() method is called by a radio when it wants to sample the RSSI value of the air around it at the current time. The air may need to block (i.e. wait for neighbors) because this thread may be ahead of other threads in global time. The underlying air implementation should use a Synchronizer for this purpose.

Specified by:
sampleRSSI in interface RadioAir
Parameters:
r - the radio sampling the RSSI value
Returns:
an integer value representing the received signal strength indicator

readChannel

public byte readChannel(Radio r)
The readChannel() method reads the value of the channel at the current time so that the last 8 bits transmitted (where the bits are 0 if there are no transmissions) are returned.

Specified by:
readChannel in interface RadioAir
Parameters:
r - the radio sampling the channel
Returns:
the last 8 bits transmitted in the channel

getSynchronizer

public Synchronizer getSynchronizer()
The getSynchronizer() method gets the synchronizer for this air implementation.

Specified by:
getSynchronizer in interface RadioAir
Returns:
a reference to the synchronizer for this radio model.