I am trying to implement data acknowledgement in x-mac protocol. The algorithm is, after the packet transmission is over, the sending node will wait for an acknowledgement from the receiver. For that I added a new state WAIT_ACK. But during runtime, I can see the node cannot make state transition from WAIT_TX_DATA_OVER
to WAIT_ACK
. I am getting the following error.
<!> Undefined event of type 204 in state 7 (Radio state 2)! -- in module (inet::XMac1) SensorNetworkShowcaseA.sensor3.wlan[0].mac (id=181), at t=0.10677288732s, event #62
Note: XMAC1_DATA_TX_OVER
= 204 and state 7 is WAIT_ACK
case SEND_DATA:
if (msg->getKind() == XMAC1_STOP_PREAMBLES) {
sendDataPacket();
macState = WAIT_TX_DATA_OVER;
return;
}
else if (msg->getKind() == XMAC1_SWITCHING_FINISHED) {
sendDataPacket();
macState = WAIT_TX_DATA_OVER;
return;
}
else {
return;
}
break;
case WAIT_TX_DATA_OVER:
if (msg->getKind() == XMAC1_DATA_TX_OVER) {
scheduleAt(simTime() + (slotDuration / 2), data_ack_timeout);
macState = WAIT_ACK;
radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
changeDisplayColor(GREEN);
}
break;
case WAIT_ACK:
if (msg->getKind() == XMAC1_DATA_TX_OVER) {
delete msg;
return;
}
...
}
break;
Update
In runtime, below is what I can see after the execution stops
INFO (XMac1)SensorNetworkShowcaseA.sensor3.wlan[0].mac: node 0A-AA-00-00-00-04 : State WAIT_TX_DATA_OVER, message XMAC_DATA_TX_OVER, new state WAIT_ACK INFO (ApskScalarRadio)SensorNetworkShowcaseA.sensor3.wlan[0].radio: SensorNetworkShowcaseA.sensor3.wlan[0].radio: Radio mode changed from TRANSMITTER to RECEIVER. INFO (ApskScalarRadio)SensorNetworkShowcaseA.sensor3.wlan[0].radio: SensorNetworkShowcaseA.sensor3.wlan[0].radio: Changing radio reception state from UNDEFINED to IDLE. INFO (ApskScalarRadio)SensorNetworkShowcaseA.sensor3.wlan[0].radio: SensorNetworkShowcaseA.sensor3.wlan[0].radio: Changing radio transmission state from IDLE to UNDEFINED. <!> Undefined event of type 204 in state 7 (Radio state 2)! -- in module (inet::XMac1) SensorNetworkShowcaseA.sensor3.wlan[0].mac (id=181), at t=0.10677288732s, event #62
Based on the information you provided, this should not happen, so something in your assumptions are wrong. Most likely, you are NOT running this code. Make sure that this code is indeed executed (you may build a release version and run the debug version or something else). In these cases I often modify temporarily the error message in the code to see whether code changes are really compiled into the executable, just to be sure that I'm running the indeed the code I assume running.