Introduction générale cadre du projet Chapitre : Introduction 7


void SMac : : txFrame ( )



Yüklə 351,68 Kb.
səhifə81/81
tarix09.01.2022
ölçüsü351,68 Kb.
#93754
1   ...   73   74   75   76   77   78   79   80   81
void SMac : : txFrame ( )

{…

assert (nav_state == NAV_STATE_CLEAR)


if (rssi ( ) > 0.5)

{…

setinternalTimeout (passive_preamble_time)



setIdle ( ) ;

return ;

}

else {



switch (proto_state) {
case PROTO_STATE_CONTEND :
  switch (next_state) {

case PROTO_STATE_SEND_SYNC :

startContending (SYNC_CONTEND_TIME) ;

setinternalTimeout (passive_preamble_time) ;

sendSync ( ) ;



break ;

case PROTO_STATE_SEND_RTS :

startContending (RTS_CONTEND_TIME)

setinternalTimeout (total_preamble_time) ;

sendRts ( ) ;

proto_state = PROTO_STATE_WFCTS ;

setProtocolTimeout (TIMEOUT_WFCTS) ;



break ;
case PROTO_STATE_SEND_DATA :

startContending (DATA_CONTEND_TIME) ;

setinternalTimeout (total_preamble_time) ;

sendData ( ) ;



break ;

case PROTO_STATE_SEND_CTS :

sendCts ( ) ;

proto_state = PROTO_STATE_WFDATA ;

setProtocolTimeout (TIMEOUT_WFDATA) ;



break ;

}

break ;


case PROTO_STATE_SEND_DATA :

sendData ( ) ;

proto_state = PROTO_STATE_WFACK ;

setProtocolTimeout (TIMEOUT_WFACK) ;



break ;
case PROTO_STATE_SEND_ACK :

sendAck ( ) ;

} break ;

} return ;

}

...
void SMac : : rxFrame (Packet * msg)



{ ...

if (sched_state == SCHED_STATE_SLEEP)

return ;

else

if (rssi < 0.5) {

setinternalTimeout (passive_preamble_time) }



else

switch (PKT_KIND (msg)) {
case KIND_SYNC :

setinternalTimeout (passive_preamble_time) ;

receiveSync (msg) ;

break ;

case KIND_RTS :

setinternalTimeout (total_preamble_time) ;

receiveRts (msg) ;

break ;

case KIND_CTS :

receiveCts (msg) ;



break ;

case KIND_DATA :

if (msg -> local_to != -1) {

receiveData (msg) }



else

setinternalTimeout (total_preamble_time) ;

receiveData (msg) ;

break ;

case KIND_ACK :

receiveAck (msg) ;



break ;



}



Projet de fin d’études 2005/2006

Yüklə 351,68 Kb.

Dostları ilə paylaş:
1   ...   73   74   75   76   77   78   79   80   81




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©muhaz.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin