⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 802_11.pc

📁 无线网络仿真工具Glomosim2.03
💻 PC
📖 第 1 页 / 共 5 页
字号:
   case M802_11_X_FRAGMENT:      assert(FALSE); abort();  // Fragmentation Needs to be rewritten. (Jay)//NoFrag       Mac802_11FragTransmitted(node, M802);      break;      case M802_11_X_FRAGACK:      Mac802_11FragAckTransmitted(node, M802);      break;      case M802_11_X_RTS:      Mac802_11RTSTransmitted(node, M802);      break;      case M802_11_X_CTS:      Mac802_11CTSTransmitted(node, M802);      break;      default:      assert(FALSE); abort();      break;   }//switch//}static //inline//void CancelSomeTimersBecauseChannelHasBecomeBusy(   GlomoNode* node,   GlomoMac802_11* M802){   switch (M802->state) {   case M802_11_S_WF_DIFS_OR_EIFS:      Mac802_11SetState(node, M802, M802_11_S_IDLE);      Mac802_11CancelTimer(node, M802);      break;   case M802_11_S_BO:      Mac802_11PauseBackoff(node, M802);      Mac802_11SetState(node, M802, M802_11_S_IDLE);      Mac802_11CancelTimer(node, M802);      break;          case M802_11_S_WFNAV:      // Timer no longer need timer for NAV (may need to      // set the timer if the channel becomes busy again.                  Mac802_11SetState(node, M802, M802_11_S_IDLE);      Mac802_11CancelTimer(node, M802);      break;      default:      // Can't happen or ignore.      break;      }//switch//}//CancelSomeTimersBecauseChannelHasBecomeBusy//static //inline//void ExaminePotentialIncomingMessage(   GlomoNode* node,   GlomoMac802_11* M802,   RadioStatusType radioStatus,   clocktype receiveDuration,   const Message* thePacketIfItGetsThrough){   const M802_11ShortControlFrame* hdr =       (M802_11ShortControlFrame*)thePacketIfItGetsThrough->packet;      assert(radioStatus == RADIO_RECEIVING);      M802->IsInExtendedIfsMode = TRUE;             if (M802->state == M802_11_S_NAV_RTS_CHECK_MODE) {      // The RTS (Request To Send) is getting a CTS so continue the      // NAV wait and cancel the timer that would reset the NAV.            Mac802_11SetState(node, M802, M802_11_S_IDLE);      Mac802_11CancelTimer(node, M802);    }//if//      }//ExaminePotentialIncomingMessage//      static //inline//void RadioStatusIsNowIdleStartSendTimers(   GlomoNode* node,   GlomoMac802_11* M802){   switch (M802->state) {   case M802_11_S_IDLE:      if (NetworkIpOutputQueueIsEmpty(              node, M802->myGlomoMac->interfaceIndex))      {         // Nothing to send. Stay Idle.      } else {         // Start up Sending process again.         // Note: uses current Backoff delay.         AttemptToGoIntoWaitForDifsOrEifsState(node, M802);      }//if//      break;         // In these states, we don't care about the state of the radio.       case M802_11_S_WFCTS:   case M802_11_S_WFDATA:   case M802_11_S_WFACK:       case M802_11_S_WFFRAGACK:                        break;      // These states can't happen.      case M802_11_S_NAV_RTS_CHECK_MODE:   // Currently Disabled.   case M802_11_S_WFNAV:   case M802_11_S_WF_DIFS_OR_EIFS:   case M802_11_S_BO:       default:      assert(FALSE); abort();      break;   }//switch//   }//RadioStatusIsNowIdleStartSendTimers////--------------------------------------------------------------------------//--------------------------------------------------------------------------//--------------------------------------------------------------------------//// Inter-Layer Interface Routines//--------------------------------------------------------------------------// Called when network layer buffers transition from empty.    void Mac802_11NetworkLayerHasPacketToSend(   GlomoNode* node, GlomoMac802_11* M802){         if (M802->state == M802_11_S_IDLE) {      if ((RadioStatus(node, M802) == RADIO_IDLE) &&          (!Mac802_11WaitForNAV(node, M802)))      {         //         // Not holding for NAV and radio is idle,         // so no backoff.         //          assert(M802->BO == 0);      } else {         // Otherwise set backoff.                  Mac802_11SetBackoffIfZero(node, M802);      }//if//            AttemptToGoIntoWaitForDifsOrEifsState(node, M802);               }//if//   }//Mac802_11NetworkLayerHasPacketToSend////--------------------------------------------------------------------------void Mac802_11ReceivePacketFromRadio(   GlomoNode* node,    GlomoMac802_11* M802,    Message* msg){   M802_11ShortControlFrame* hdr = (M802_11ShortControlFrame*)msg->packet;      M802->IsInExtendedIfsMode = FALSE;      /*   * Since in GloMoSim it's possible to have two events occurring   * at the same time, enforce the fact that when a node is   * transmitting, a node can't be receiving a frame at the same time.   */      assert(!Mac802_11IsTransmittingState(M802->state));         if (hdr->destAddr == node->nodeAddr)   {      switch (hdr->frameType) {            case M802_11_CTS:         assert(M802->state == M802_11_S_WFCTS);         Mac802_11CancelTimer(node, M802);                  // This is not in the standard, but ns-2 does.         // Mac802_11DecreaseCW(node, M802);                  M802->SSRC = 0;         Mac802_11TransmitDataFrame(node, M802);         GLOMO_MsgFree(node, msg);         break;            case M802_11_ACK:         assert(M802->state == M802_11_S_WFACK);         Mac802_11CancelTimer(node, M802);         Mac802_11ProcessAck(node, M802, msg);         GLOMO_MsgFree(node, msg);         break;            case M802_11_RTS:         if (Mac802_11IsWaitingForResponseState(M802->state)) {                     } else if ((!Mac802_11WaitForNAV(node, M802)) &&                     (RadioStatus(node, M802) == RADIO_IDLE))         {            // Transmit CTS only if NAV (software carrier sense)            // and the radio says the channel is idle.                        Mac802_11CancelTimer(node, M802);            Mac802_11TransmitCTSFrame(node, M802, msg);         } else {            if (RadioStatus(node, M802) != RADIO_IDLE) {               M802->rtsPacketsIgnoredDueToBusyChannel++;            } else {               assert(Mac802_11WaitForNAV(node, M802));               M802->rtsPacketsIgnoredDueToNAV++;            }//if//         }//if//                  GLOMO_MsgFree(node, msg);         break;            case M802_11_DATA:         // This is not in the standard, but ns-2 does.         // Mac802_11DecreaseCW(node, M802);         // This is not in the standard, but ns-2 does.         // M802->SSRC = 0;                  Mac802_11ProcessFrame(node, M802, msg);         break;            case M802_11_FRAGMENT:         assert(FALSE); abort();  // Fragmentation Needs to be rewritten. (Jay)         Mac802_11ProcessFrag(node, M802, msg);         GLOMO_MsgFree(node, msg);         break;            default:         printf("MAC_802_11: Unknown frame type %d\n",                hdr->frameType);         assert(FALSE); abort();      }/*switch*/   }   else if (hdr->destAddr == ANY_DEST)   {      switch (hdr->frameType) {      case M802_11_DATA:         Mac802_11ProcessFrame(node, M802, msg);         break;      case M802_11_FRAGMENT:         assert(FALSE); abort();  // Fragmentation Needs to be rewritten. (Jay)         Mac802_11ProcessFrag(node, M802, msg);         GLOMO_MsgFree(node, msg);         break;      default:         printf("MAC_802_11: Unknown frame type %d\n",                hdr->frameType);         assert(FALSE); abort();      }/*switch*/   }   else /* Does not belong to node */   {                  Mac802_11ProcessNotMyFrame(node, M802, hdr->duration,          (hdr->frameType==M802_11_RTS));      if ((M802->myGlomoMac->promiscuousMode == TRUE) &&          ((hdr->frameType == M802_11_FRAGMENT) ||          (hdr->frameType == M802_11_DATA)))      {         Mac802_11HandlePromiscuousMode(node, M802, msg);      }      GLOMO_MsgFree(node,msg);   }//if//      if ((M802->state == M802_11_S_IDLE) &&      (RadioStatus(node, M802) == RADIO_IDLE))   {      RadioStatusIsNowIdleStartSendTimers(node, M802);   }//if//         }//Mac802_11ReceivePacketFromRadio//                         void Mac802_11ReceiveRadioStatusChangeNotification(   GlomoNode* node,   GlomoMac802_11* M802,   RadioStatusType oldRadioStatus,   RadioStatusType newRadioStatus,   clocktype receiveDuration,   const Message* potentialIncomingPacket){         switch (oldRadioStatus) {   case RADIO_IDLE:       switch (newRadioStatus) {      case RADIO_SENSING:         CancelSomeTimersBecauseChannelHasBecomeBusy(node, M802);         break;               case RADIO_RECEIVING:         CancelSomeTimersBecauseChannelHasBecomeBusy(node, M802);         ExaminePotentialIncomingMessage(node, M802, newRadioStatus,             receiveDuration, potentialIncomingPacket);         break;               case RADIO_TRANSMITTING:         break;      default:         assert(FALSE); abort();         break;      }//switch//            break;      case RADIO_SENSING:       switch (newRadioStatus) {      case RADIO_IDLE:         RadioStatusIsNowIdleStartSendTimers(node, M802);         break;      case RADIO_RECEIVING:         ExaminePotentialIncomingMessage(node, M802, newRadioStatus,             receiveDuration, potentialIncomingPacket);         break;      case RADIO_TRANSMITTING:         // 802.11 will transmit ACKs and CTS even when sensing.          break;      default:         assert(FALSE); abort();         break;      }//switch//            break;      case RADIO_RECEIVING: {                  switch (newRadioStatus) {      case RADIO_IDLE:         RadioStatusIsNowIdleStartSendTimers(node, M802);         break;            case RADIO_SENSING:         // Receive was canceled and packet dropped.                                                  break;            case RADIO_RECEIVING:         // "Captured" stronger packet.                  ExaminePotentialIncomingMessage(node, M802, newRadioStatus,             receiveDuration, potentialIncomingPacket);         break;            default:         assert(FALSE); abort();         break;      }//switch//            break;   }   case RADIO_TRANSMITTING:       switch (newRadioStatus) {      case RADIO_IDLE:      case RADIO_SENSING:      case RADIO_RECEIVING:         TransmissionHasFinished(node, M802);         break;      default:         assert(FALSE); abort();         break;      }//switch//         break;      default:      assert(FALSE); abort();      break;   }//switch//         }//Mac802_11ReceiveRadioStatusChangeNotification//   //--------------------------------------------------------------------------   /* * NAME:        Mac802_11HandleTimeout. * * PURPOSE:     Process the different timers in 802.11 that timed out. * * PARAMETERS:  node, node that timer expired at. * * RETURN:      None. * * ASSUMPTION:  None. */static void Mac802_11HandleTimeout(GlomoNode *node, GlomoMac802_11 *M802){         switch (M802->state) {      case M802_11_S_WF_DIFS_OR_EIFS:      if (M802->BO == 0) {         Mac802_11TransmitFrame(node, M802);      } else {         Mac802_11ContinueBackoff(node, M802);         Mac802_11SetState(node, M802, M802_11_S_BO);         Mac802_11StartTimer(node, M802, M802->BO);      }//if//      break;   case M802_11_S_BO:      assert((M802->lastBOTimeStamp + M802->BO) == simclock());      M802->BO = 0;      Mac802_11TransmitFrame(node, M802);      break;   case M802_11_S_WFACK:      M802->retxDueToAck++;      Mac802_11Retransmit(node, M802);      break;   case M802_11_S_NAV_RTS_CHECK_MODE:   case M802_11_S_WFNAV:      M802->NAV = 0;      if (!NetworkIpOutputQueueIsEmpty(             node, M802->myGlomoMac->interfaceIndex))      {         AttemptToGoIntoWaitForDifsOrEifsState(node, M802);      }      else      {         assert(M802->BO == 0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -