|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjist.swans.mac.Mac802_11
public class Mac802_11
Implementation of IEEE 802_11b. Please refer to the standards document. For consistency, many of the variable names, constants and equations are taken directly from the specification.
Nested Class Summary | |
---|---|
private static class |
Mac802_11.SeqEntry
Local class to used manage sequence number records. |
Nested classes/interfaces inherited from interface jist.swans.mac.MacInterface |
---|
MacInterface.Mac802_11 |
Field Summary | |
---|---|
protected int |
bandwidth
link bandwidth (units: bytes/second). |
protected long |
bo
backoff time remaining. |
protected long |
boStart
backoff start time. |
protected short |
cw
current contention window size. |
static short |
CW_MAX
Maximum collision window (for backoff). |
static short |
CW_MIN
Minimum collision window (for backoff). |
static long |
DIFS
Distributed inter frame space. |
static boolean |
DSSS
Physical specification constant: 802_11b-1999 Supplement 2_4GHz Direct Sequence. |
static long |
EIFS
Extended inter frame space. |
static boolean |
FHSS
Physical specification constant: 802_11b-1999 2_4GHz Frequency Hopping. |
protected MacAddress |
localAddr
mac address of this interface. |
protected byte |
longRetry
long retry counter. |
static byte |
MAC_MODE_DIFS
mac mode: waiting for difs or eifs timer. |
static byte |
MAC_MODE_SBO
mac mode: waiting for backoff. |
static byte |
MAC_MODE_SIDLE
mac mode: idle. |
static byte |
MAC_MODE_SNAV
mac mode: waiting for virtual carrier sense. |
static byte |
MAC_MODE_SNAV_RTS
mac mode: waiting for virtual carrier sense to RTS. |
static byte |
MAC_MODE_SWFACK
mac mode: waiting for ACK packet. |
static byte |
MAC_MODE_SWFCTS
mac mode: waiting for CTS packet. |
static byte |
MAC_MODE_SWFDATA
mac mode: waiting for DATA packet. |
static byte |
MAC_MODE_XACK
mac mode: transmitting ACK packet. |
static byte |
MAC_MODE_XBROADCAST
mac mode: transmitting broadcast DATA packet. |
static byte |
MAC_MODE_XCTS
mac mode: transmitting CTS packet. |
static byte |
MAC_MODE_XRTS
mac mode: transmitting RTS packet. |
static byte |
MAC_MODE_XUNICAST
mac mode: transmitting unicast DATA packet. |
protected byte |
mode
current mac mode. |
protected long |
nav
virtual carrier sense; next time when network available. |
protected boolean |
needEifs
whether last reception had an error. |
protected NetInterface |
netEntity
Network upcall entity interface. |
protected byte |
netId
network interface number. |
protected Message |
packet
packet currently being transmitted. |
protected MacAddress |
packetNextHop
next hop of packet current being transmitted. |
static long |
PIFS
Point coordination inter frame space. |
static long |
PLCP_HEADER
Length of PLCP Header at 1Mb/s. |
static long |
PREAMBLE
Length of PHY preamble. |
protected boolean |
promisc
whether mac is in promiscuous mode. |
static long |
PROPAGATION
Air propagation delay. |
protected RadioInterface |
radioEntity
Radio downcall entity reference. |
protected byte |
radioMode
radio mode used for carrier sense. |
static byte |
RETRY_LIMIT_LONG
Retransmissions attempted for long packets (those with RTS). |
static byte |
RETRY_LIMIT_SHORT
Retransmissions attempted for short packets (those without RTS). |
static long |
RX_TX_TURNAROUND
Receive-Transmit turnaround time. |
protected MacInterface.Mac802_11 |
self
Self-referencing mac entity reference. |
protected short |
seq
sequence number counter. |
static short |
SEQ_CACHE_SIZE
Sequence number cache size. |
static short |
SEQ_INVALID
Invalid sequence number. |
protected Mac802_11.SeqEntry |
seqCache
received sequence number cache list. |
protected byte |
seqCacheSize
size of received sequence number cache list. |
protected byte |
shortRetry
short retry counter. |
static long |
SIFS
Short interframe space. |
static long |
SLOT_TIME
Minimum time to sense medium. |
static long |
SYNCHRONIZATION
PHY synchronization time. |
static int |
THRESHOLD_FRAGMENT
Threshold packet size for fragmentation. |
static int |
THRESHOLD_RTS
Threshold packet size to activate RTS. |
protected byte |
timerId
timer identifier. |
static long |
TX_DIFS
Transmit start DIFS. |
static long |
TX_SIFS
Transmit start SIFS. |
Constructor Summary | |
---|---|
Mac802_11(MacAddress addr,
RadioInfo radioInfo)
Instantiate new 802_11b entity. |
Method Summary | |
---|---|
private void |
backoff()
Perform backoff. |
private void |
cancelTimer()
Cancel timer event, by incrementing the timer identifer. |
void |
cfDone(boolean backoff,
boolean delPacket)
Collision free send sequence complete. |
private void |
clearBackoff()
Reset backoff counter to zero. |
private void |
decCW()
Decrease Collision Windows. |
private void |
doDifs()
|
static java.lang.String |
getModeString(byte mode)
|
MacInterface.Mac802_11 |
getProxy()
Return proxy entity of this mac. |
private short |
getSeqEntry(MacAddress from)
Return latest seen sequence number from given address. |
private boolean |
hasBackoff()
Return whether there is a backoff. |
boolean |
hasPacket()
Return whether mac currently has a packet to send. |
private void |
idle()
|
private void |
incCW()
Increase Collision Window. |
private short |
incSeq()
Increment local sequence counter. |
boolean |
isAwaitingResponse()
Return whether the mac is currently waiting for a response. |
private boolean |
isBroadcast()
Return whether current packet is to be broadcast. |
private boolean |
isCarrierIdle()
Determine whether channel is idle according to both physical and virtual carrier sense. |
private boolean |
isRadioIdle()
|
boolean |
isTransmitting()
Return whether the mac is currently transmitting. |
private void |
pauseBackoff()
Pause the current backoff (invoked when the channel becomes busy). |
void |
peek(Message msg)
Radio has locked onto a packet signal; mac may have a peek. |
private void |
radioBusy()
|
private void |
radioIdle()
|
void |
receive(Message msg)
Radio has received a packet for mac to process. |
private void |
receiveAck(MacMessage.Ack ack)
|
private void |
receiveCts(MacMessage.Cts cts)
|
private void |
receiveData(MacMessage.Data msg)
|
private void |
receiveForeign(MacMessage msg)
|
private void |
receivePacket(MacMessage msg)
|
private void |
receiveRts(MacMessage.Rts rts)
|
private void |
resetNav()
Clear the virtual carrier sense (network allocation vector). |
private void |
retry()
|
private void |
retryNo()
|
private void |
retryYes()
|
void |
send(Message msg,
MacAddress nextHop)
Network layer would like to send the following packet. |
private void |
sendAck(MacMessage.Data data)
|
private void |
sendCts(MacMessage.Rts rts)
|
private void |
sendData(boolean afterCts)
|
private void |
sendDataBroadcast()
|
private void |
sendDataUnicast(boolean afterCts)
|
private void |
sendPacket()
|
private void |
sendRts()
|
private void |
setBackoff()
Set new random backoff, if current backoff timer has elapsed. |
private void |
setMode(byte mode)
Set the current mac mode. |
void |
setNetEntity(NetInterface net,
byte netid)
Hook up with the network entity. |
void |
setPromiscuous(boolean promisc)
Set promiscuous mode (whether to pass all packets through). |
void |
setRadioEntity(RadioInterface radio)
Hook up with the radio entity. |
void |
setRadioMode(byte mode)
Update mac regarding new mode of its radio. |
private boolean |
shouldFragment()
Return whether current packet requires fragmentation. |
private boolean |
shouldRTS()
Return whether current packet large enough to require RTS. |
void |
startTimer(long delay,
byte mode)
Initiate a timer event. |
void |
timeout(int timerId)
Process mac timeout. |
private long |
transmitTime(Message msg)
Compute packet transmission time at current bandwidth. |
private void |
updateSeqEntry(MacAddress from,
short seq)
Update latest sequence number entry for given address. |
private boolean |
waitingNav()
Return whether the virtual carrier sense (network allocation vector) indicates that the channel is reserved. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean DSSS
public static final boolean FHSS
public static final long PREAMBLE
public static final long PLCP_HEADER
public static final long SYNCHRONIZATION
public static final long RX_TX_TURNAROUND
public static final long PROPAGATION
public static final long SLOT_TIME
public static final long SIFS
public static final long PIFS
public static final long DIFS
public static final long TX_SIFS
public static final long TX_DIFS
public static final long EIFS
public static final int THRESHOLD_RTS
public static final int THRESHOLD_FRAGMENT
public static final byte RETRY_LIMIT_SHORT
public static final byte RETRY_LIMIT_LONG
public static final short CW_MIN
public static final short CW_MAX
public static final short SEQ_INVALID
public static final short SEQ_CACHE_SIZE
public static final byte MAC_MODE_SIDLE
public static final byte MAC_MODE_DIFS
public static final byte MAC_MODE_SBO
public static final byte MAC_MODE_SNAV
public static final byte MAC_MODE_SNAV_RTS
public static final byte MAC_MODE_SWFCTS
public static final byte MAC_MODE_SWFDATA
public static final byte MAC_MODE_SWFACK
public static final byte MAC_MODE_XRTS
public static final byte MAC_MODE_XCTS
public static final byte MAC_MODE_XUNICAST
public static final byte MAC_MODE_XBROADCAST
public static final byte MAC_MODE_XACK
protected final MacInterface.Mac802_11 self
protected RadioInterface radioEntity
protected NetInterface netEntity
protected byte netId
protected final int bandwidth
protected MacAddress localAddr
protected boolean promisc
protected byte mode
protected byte radioMode
protected boolean needEifs
protected byte timerId
protected long bo
protected long boStart
protected short cw
protected long nav
protected short seq
protected Mac802_11.SeqEntry seqCache
protected byte seqCacheSize
protected byte shortRetry
protected byte longRetry
protected Message packet
protected MacAddress packetNextHop
Constructor Detail |
---|
public Mac802_11(MacAddress addr, RadioInfo radioInfo)
addr
- local mac addressradioInfo
- radio propertiesMethod Detail |
---|
public static java.lang.String getModeString(byte mode)
public MacInterface.Mac802_11 getProxy()
public void setRadioEntity(RadioInterface radio)
radio
- radio entitypublic void setNetEntity(NetInterface net, byte netid)
net
- network entitynetid
- network interface numberpublic void setPromiscuous(boolean promisc)
promisc
- promiscuous flagprivate void setMode(byte mode)
mode
- new mac modepublic boolean isAwaitingResponse()
public boolean isTransmitting()
public boolean hasPacket()
private boolean isBroadcast()
private boolean shouldRTS()
private boolean shouldFragment()
private long transmitTime(Message msg)
msg
- packet to transmit
private boolean hasBackoff()
private void clearBackoff()
private void setBackoff()
private void pauseBackoff()
private void backoff()
private void incCW()
private void decCW()
private boolean waitingNav()
private void resetNav()
private boolean isCarrierIdle()
private short incSeq()
private short getSeqEntry(MacAddress from)
from
- source address
private void updateSeqEntry(MacAddress from, short seq)
from
- source addressseq
- latest sequence numberpublic void send(Message msg, MacAddress nextHop)
MacInterface
send
in interface MacInterface
msg
- packet to sendnextHop
- destination macprivate void doDifs()
public void cfDone(boolean backoff, boolean delPacket)
MacInterface.Mac802_11
cfDone
in interface MacInterface.Mac802_11
backoff
- is a backoff requireddelPacket
- is processing for this packet completeprivate void sendPacket()
private void sendRts()
private void sendCts(MacMessage.Rts rts)
private void sendData(boolean afterCts)
private void sendDataBroadcast()
private void sendDataUnicast(boolean afterCts)
private void sendAck(MacMessage.Data data)
private void retry()
private void retryYes()
private void retryNo()
public void peek(Message msg)
MacInterface
peek
in interface MacInterface
msg
- packet currently in flightpublic void receive(Message msg)
MacInterface
receive
in interface MacInterface
msg
- packet receivedprivate void receivePacket(MacMessage msg)
private void receiveRts(MacMessage.Rts rts)
private void receiveCts(MacMessage.Cts cts)
private void receiveAck(MacMessage.Ack ack)
private void receiveData(MacMessage.Data msg)
private void receiveForeign(MacMessage msg)
public void setRadioMode(byte mode)
MacInterface
setRadioMode
in interface MacInterface
mode
- new radio modeprivate boolean isRadioIdle()
private void radioBusy()
private void radioIdle()
public void startTimer(long delay, byte mode)
MacInterface.Mac802_11
startTimer
in interface MacInterface.Mac802_11
delay
- timer durationmode
- new modeprivate void cancelTimer()
private void idle()
public void timeout(int timerId)
MacInterface.Mac802_11
timeout
in interface MacInterface.Mac802_11
timerId
- timer identifier
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |