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

📄 wimedia.h

📁 ns2.31下的UWB(Ultra WideBand)实现
💻 H
字号:
/*This module is to simulate 802.15.3, MBOA-UWB. */#ifndef WiMedia_H#define WiMedia_H#include "address.h"#include "ip.h"#include "mac-timers2.h"#include "marshall.h"#include <math.h>#include <stddef.h>#include "WiMedia_defs.h"#include <list>class Mac_WiMedia : public Mac {friend class PNC;friend class BackoffTimer2;// Functionspublic:	Mac_WiMedia(MacMib *mib);	~Mac_WiMedia();		int nTotalReceivedFrags_;        int nCorruptedReceivedFrags_;		void OnBeaconTimer();	void OnIFTimer();	void OnSendTimer();	void OnDeferTimer();	void OnRxTimer();	void OnTDMATimer();	void OnBackoffTimer();		void tx_resume(double defer_duration);	void rx_resume();	void Transmit(Packet *p, double t);	int SendBeacon(Packet *p);protected:	void AddNewPacket(Packet *p, Handler *h);	int SendPacket(Packet *p, double defer_duration);	int SendNullPacket(int flowid, double remaining, double defer_duration, bool bRequestDelayedAck);	int command(int argc, const char*const* argv);	void CreateAckPacket(int dst, MacACKType ack_type);		void CreateDataPacket(Packet *p);	void QAddPacket(Packet *p);		int QPacketCount(int flowid);	int QUnAckedPacketCount(int flowid);	bool QRemovePacket(Packet *p);	bool QRemoveUnAckedPacket(Packet *p);	void QAddUnAckedPacket(Packet *p);	int CheckAckPacket();	void AdjustQueueSize(Packet *p);	void collision(Packet *p);	void discard(Packet *p, const char* why);	inline int is_idle();	int CheckQueues(double defer_duration, MacState state);	int CheckNRTQueue(bool bIdle);	int CheckRetransmission(double defer_duration, MacState state);	// Gets the next packet from the queue	Packet* QGetNextPacket(int flowid);	Packet* QGetNextUnAckedPacket(int flowid, bool bCheckDeadline);	bool IsStillValid(Packet *p);		// Packet Reception Functions	void recv(Packet *p, Handler *h);	void recvBeacon(Packet *p);	void recvMSBeacon(Packet *p);	void recvACK(Packet *p);	void recvDATA(Packet *p);	// Ack Information Related	void ParseAckInfoInBeacon(Packet *p);	void ACKPacketsInArray(int flowid, int *nAckArray, int nAckCount);	void WriteACKIDs(int flowid, bool bBeacon, int nOffset, Packet * pTempACK);	void CheckReceiveDataBuffer(int flowid);	void SendDataToUp(Packet *p);public:	u_int16_t usec(double t) {		u_int16_t us = (u_int16_t)ceil(t *= 1e6);		return us;	}	double TxTime_HdrPHY() {	// size of the PHY headerin terms of bytes		return macmib_->PHYHeaderTxTime;	}	int Len_HdrPHY() { 	// size of the PHY header in terms of bytes		return (int)(bandwidth_*TxTime_HdrPHY()/8);	}		int Len_HdrMAC() {		return macmib_->MACHeaderLength;	}		int TotalLen_Header() {	// Length of the header with PHY preamble (in terms of bytes)		return Len_HdrMAC() + Len_HdrPHY();	}	int TotalLen_ACK() {	// Length of an ACK pkt with PHY preamble (in terms of bytes)		return Len_HdrMAC() + Len_HdrPHY();	}	double TxTime_ACK() {		return((TxTime_HdrPHY() + ((8 * TotalLen_ACK()) / bandwidth_)));	}	double Timeout_ACK() {		return TxTime_ACK() + macmib_->sifs + macmib_->sifs;	}	double TxTime_Bytes(int len) {		return (TxTime_HdrPHY () + ((8 * len) / bandwidth_));	}		double TxTime(Packet *p) {		double t = TxTime_Bytes(HDR_CMN(p)->size());		if(t < 0.0){			drop(p, "XXX");			printf ("Mac802_15_3::TXTime () -> time is less than 0. Size of the packet is %d. Exitting!\n", HDR_CMN (p)->size ());			exit(1);		}		return t;	}		void increment_cw() {		cw_ = (cw_ << 1) + 1;		if(cw_ > CW_MAX)			cw_ = CW_MAX;	}// Parametersprotected:	MacMib *macmib_;	// MAC Timers	BeaconTimer2	mhBeacon_;	//beacon timer	IFTimer2	mhIF_;	TxTimer2	mhSend_;	DeferTimer2	mhDefer_;	RxTimer2	mhRecv_;	TDMATimer2	mhTDMA_;	BackoffTimer2	mhBackoff_;	// Internal MAC State	MacState tx_state_;	MacState rx_state_;		int tx_active_;	Packet *pktNULL_;	Packet *pktACK_;	int 	slrc_;	// STA long retransmission Count	NsObject*	logtarget_;	int cw_;			bool	isPNC_;		// Slot Schedules	ScheduleInfo	schedule_info_;	double beacon_offset_;	int next_gts_;	double current_slot_end_time_;	int current_flowid_;	TrafficType current_traffic_type_;	// Traffic type of current flow	MacACKType current_ack_type_;		double last_ack_received_;	// Queuing Related	list<Packet*> packet_queue_[MAX_FLOWS];	// packet queue	list<Packet*> unacked_queue_[MAX_FLOWS];	// Unacked packet queue	// outgoing flows	FlowInfo flow_list_[MAX_FLOWS];	// Fragement Support	bool	bDoFragmentation_;	int 	max_frag_size_;	Packet* fraq_cache_[MAX_FLOWS];		// Incoming fragmented packet cache.	// Duplicate Detection	u_int32_t sta_seqno_[MAX_FLOWS];	// next seqno that will be used.	int 	cache_node_count_;	Host2	*cache_;			bool bResetPToBeAckedOnRx_[MAX_FLOWS];	int nNextPacketToUpper_[MAX_FLOWS];	int nNextFragToUpper_[MAX_FLOWS];	list <Packet*> PacketsToBeAcked_[MAX_FLOWS];};#endif

⌨️ 快捷键说明

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