📄 mac-802_11.h
字号:
u_int32_t dot11ATIMWindowSize; //(ms)//end of JUNGMIN u_int32_t TransmittedFragmentCount; u_int32_t MulticastTransmittedFrameCount; u_int32_t FailedCount; u_int32_t RetryCount; u_int32_t MultipleRetryCount; u_int32_t FrameDuplicateCount; u_int32_t RTSSuccessCount; u_int32_t RTSFailureCount; u_int32_t ACKFailureCount; u_int32_t ReceivedFragmentCount; u_int32_t MulticastReceivedFrameCount; u_int32_t FCSErrorCount;};/* ====================================================================== The following destination class is used for duplicate detection. ====================================================================== */class Host {public: LIST_ENTRY(Host) link; u_int32_t index; u_int32_t seqno;};/* ====================================================================== The actual 802.11 MAC class. ====================================================================== */class Mac802_11 : public Mac { friend class DeferTimer; friend class BackoffTimer; friend class IFTimer; friend class NavTimer; friend class RxTimer; friend class RxDATATimer; friend class TxTimer;//JUNGMIN friend class BeaconTimer; friend class BeaconBackoffTimer; friend class ATIMWindowTimer; friend class ChannelUsageTimer; friend class WaitTimer;//end of JUNGMINpublic: Mac802_11(PHY_MIB* p, MAC_MIB *m); void recv(Packet *p, Handler *h); inline int hdr_dst(char* hdr, int dst = -2); inline int hdr_src(char* hdr, int src = -2); inline int hdr_type(char* hdr, u_int16_t type = 0); int CheckDest(Packet* p); void sendATIM(int dst, Handler* h); double NextBeaconTime(); int NearBeacon(Packet* p, int);protected: void backoffHandler(void); void deferHandler(void); void navHandler(void);//JUNGMIN void channelusageHandler(int); void waitHandler(void); void recvHandler(void); void recvDATAHandler(void); void sendHandler(void); void txHandler(void); void beaconHandler(void); void beaconBackoffHandler(void); void atimHandler(void);//end of JUNGMINprivate: int command(int argc, const char*const* argv); /* * Called by the timers. *///JUNGMIN void recv_timer(void); void recvDATA_timer(void); void send_timer(void); int check_pktCTRL(); int check_pktRTS(); int check_pktTx(); int check_pktPCF(); int check_pktATIMRSH(); int check_pktATIMACK(); int check_pktATIM();//end of JUNGMIN /* * Packet Transmission Functions. */ void send(Packet *p, Handler *h); void sendRTS(int dst); void sendCTS(int dst, double duration);//JUNGMIN void sendDRTS(int dst); void sendDCTS(int dst, double duration); void sendDRSH(int dst, double duration);//end of JUNGMIN void sendACK(int dst); void sendDATA(Packet *p); void RetransmitRTS(); void RetransmitDATA();//JUNGMIN void prepare_beacon(); void send_beacon(); void beacon_received(); void pcfSend(int type, int subtype); void sendATIMACK(int dst); void sendATIMRSH(int dst); void RetransmitATIM();//end of JUNGMIN /* * Packet Reception Functions. */ void recvRTS(Packet *p); void recvCTS(Packet *p); void recvDRTS(Packet *p); void recvDCTS(Packet *p); void recvDRSH(Packet *p); void recvACK(Packet *p); void recvDATA(Packet *p);//JUNGMIN void recvATIM(Packet *p); void recvATIMACK(Packet *p); void recvATIMRSH(Packet *p); void recvOtherATIMACK(Packet *p); void recvOtherATIMRSH(Packet *p); void DCAUpdateCUL(int, double); void DCABuildFreeChannelList(int *); void recvOtherDRSH(Packet *p); void recvOtherDCTS(Packet *p);//end of JUNGMIN void capture(Packet *p); void collision(Packet *p); void discard(Packet *p, const char* why); void rx_resume(void); void dx_resume(void); void tx_resume(void); inline int is_idle(void); inline int is_channel_idle(int ch); /* * Debugging Functions. */ void trace_pkt(Packet *p); void dump(char* fname); inline int initialized() { return (phymib_ && macmib_ && cache_ && logtarget_ && Mac::initialized()); } void mac_log(Packet *p) { logtarget_->recv(p, (Handler*) 0); } double txtime(Packet *p); double txtime(double psz, double drt); double txtime(int bytes) { /* clobber inherited txtime() */ abort(); } inline void inc_cw() { cw_ = (cw_ << 1) + 1; if(cw_ > phymib_->CWMax) cw_ = phymib_->CWMax; } inline void rst_cw() { cw_ = phymib_->CWMin; } inline double sec(double t) { return(t *= 1.0e-6); } inline u_int16_t usec(double t) { u_int16_t us = (u_int16_t)floor((t *= 1e6) + 0.5); /* u_int16_t us = (u_int16_t)rint(t *= 1e6); */ return us; } inline void set_nav(u_int16_t us) { double now = Scheduler::instance().clock(); double t = us * 1e-6; if((now + t) > nav_) { nav_ = now + t; if(mhNav_.busy()) mhNav_.stop(); mhNav_.start(t); } }//JUNGMIN void SetATIMWindow(); void SelectChannel(struct atim_frame *); void ConfirmChannel(struct atimack_frame *); int DCASelectChannel(int*); double FindNearestChannelFreeTime(); void ResetChannelInfo(); void ResetDestInfo(); void ResetNeighborChannelStateInfo(); void ResetAtBeacon(); //combination of above 3 int LookupDestState(int dst); void InsertDestState(int dst); void InsertNeighborChannelState(int dst, int channel);//end of JUNGMINprotected: PHY_MIB *phymib_; MAC_MIB *macmib_;private: double basicRate_; double dataRate_; /* * Mac Timers */ IFTimer mhIF_; // interface timer NavTimer mhNav_; // NAV timer RxTimer mhRecv_; // incoming packets RxDATATimer mhRecvDATA_; TxTimer mhSend_; // outgoing packets//JUNGMIN BeaconTimer mhBeacon_; BeaconBackoffTimer mhBeaconBackoff_; ATIMWindowTimer mhATIMWindow_; ChannelUsageTimer *mhChannelUsage_; WaitTimer mhWait_;//end of JUNGMIN DeferTimer mhDefer_; // defer timer BackoffTimer mhBackoff_; // backoff timer /* ============================================================ Internal MAC State ============================================================ *///JUNGMIN int fcl_[NUMBER_OF_CHANNELS]; int dca_recved_fcl_[NUMBER_OF_CHANNELS]; double dca_cul_[NUMBER_OF_CHANNELS]; int selected_channel_; int active_channel_; int dest_state_[MAX_NODES]; //int q_state_[MAX_NODES]; //moved to queue int channel_state_[MAX_NODES]; int ready_for_atim_; double next_beacon_time_; int recved_bytes_; //end of JUNGMIN double nav_; // Network Allocation Vector MacState rx_state_; // incoming state (MAC_RECV or MAC_IDLE) MacState tx_state_; // outgoint state MacState dx_state_; // for dca int tx_active_; // transmitter is ACTIVE Packet *pktRTS_; // outgoing RTS packet Packet *pktCTRL_; // outgoing non-RTS packet Packet *pktRSH_;//JUNGMIN Packet *pktPCF_; // outgoing PCF stuff Packet *pktATIM_; Packet *pktATIMACK_; Packet *pktATIMRSH_; Packet *pktDx_; Packet *pktPending_;//end of JUNGMIN u_int32_t cw_; // Contention Window u_int32_t ssrc_; // STA Short Retry Count//JUNGMIN u_int32_t sarc_; // STA ATIM Retry Count//end of JUNGMIN u_int32_t slrc_; // STA Long Retry Count double sifs_; // Short Interface Space double pifs_; // PCF Interframe Space double difs_; // DCF Interframe Space double eifs_; // Extended Interframe Space double tx_sifs_; double tx_pifs_; double tx_difs_; int min_frame_len_; NsObject* logtarget_;//JUNGMIN int pc_; int btbs_; //beacon int atim_window_; //whether atim window is on or off int dca_; double total_delay_; int packet_count_;//end of JUNGMIN /* ============================================================ Duplicate Detection state ============================================================ */ u_int16_t sta_seqno_; // next seqno that I'll use int cache_node_count_; Host *cache_;};#endif /* __mac_80211_h__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -