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

📄 pcf_support-2.1b8.patch

📁 用c++实现的802.11中的pcf功能的源代码
💻 PATCH
📖 第 1 页 / 共 4 页
字号:
Index: ll.ccdiff -u ll.cc:1.1 ll.cc:1.1.1.1.6.3--- ll.cc:1.1	Tue Aug 14 11:37:45 2001+++ ll.cc	Tue Aug 21 01:14:36 2001@@ -33,6 +33,32 @@  *  * Contributed by the Daedalus Research Group, http://daedalus.cs.berkeley.edu  */+/*+ * Code contained within lines such as the below+ *+  // wqos - <date> - dugdale+  // wqos - changes by dugdale ends+ *+ * or+ *+  // wqos - <date> - almquist+  // wqos - changes by almquist ends+ *+ * have been changed or added to implement the PCF mode of IEEE 802.11 and is+ * Copyright (c) 2001 Anders Lindgren and Andreas Almquist.+ *+ * Redistribution and use in source and binary forms, with or without+ * modification, are permitted provided that the following conditions+ * are met:+ * 1. Redistributions of source code must retain the above copyright+ *    notice, this list of conditions and the above disclaimer.+ * 2. Redistributions in binary form must reproduce the above copyright+ *    notice, this list of conditions and the above disclaimer in the+ *    documentation and/or other materials provided with the distribution.+ *+ *    The disclaimer above apply to the modifications made to the source code+ *    by Anders Lindgren and Andreas Almquist as well as to the rest of the code.+ */  #ifndef lint static const char rcsid[] =@@ -93,6 +119,9 @@ 		if (strcmp(argv[1], "mac") == 0) { 			mac_ = (Mac*) TclObject::lookup(argv[2]);                         assert(mac_);+			// wqos - Fri 13 Oct 00, 12:50 - dugdale+                        mac_->setll(this);+			// wqos - changes by dugdale ends 			return (TCL_OK); 		} 		if (strcmp(argv[1], "down-target") == 0) {Index: mac-802_11.ccdiff -u mac-802_11.cc:1.1 mac-802_11.cc:1.1.1.1.6.4--- mac-802_11.cc:1.1	Tue Aug 14 11:37:45 2001+++ mac-802_11.cc	Tue Aug 21 01:14:36 2001@@ -35,6 +35,32 @@  *  * Ported from CMU/Monarch's code, nov'98 -Padma.  */+/*+ * Code contained within lines such as the below+ *+  // wqos - <date> - dugdale+  // wqos - changes by dugdale ends+ *+ * or+ *+  // wqos - <date> - almquist+  // wqos - changes by almquist ends+ *+ * have been changed or added to implement the PCF mode of IEEE 802.11 and is+ * Copyright (c) 2001 Anders Lindgren and Andreas Almquist.+ *+ * Redistribution and use in source and binary forms, with or without+ * modification, are permitted provided that the following conditions+ * are met:+ * 1. Redistributions of source code must retain the above copyright+ *    notice, this list of conditions and the above disclaimer.+ * 2. Redistributions in binary form must reproduce the above copyright+ *    notice, this list of conditions and the above disclaimer in the+ *    documentation and/or other materials provided with the distribution.+ *+ *    The disclaimer above apply to the modifications made to the source code+ *    by Anders Lindgren and Andreas Almquist as well as to the rest of the code.+ */  #include "delay.h" #include "connector.h"@@ -127,6 +153,10 @@ 	0 /* MAC_RTSThreshold */, MAC_ShortRetryLimit, 	MAC_LongRetryLimit, MAC_FragmentationThreshold, 	MAC_MaxTransmitMSDULifetime, MAC_MaxReceiveLifetime,+  // wqos - Wed 04 Oct 00, 11:10 - dugdale+  0 /* CF Pollable */, 1 /* CFP Period */, 15 /* CFP Max Duration*/,+  20 /* BeaconPeriod */, 0 /* DTIM Period */,+  // wqos - changes by dugdale ends 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -147,7 +177,10 @@    ====================================================================== */ Mac802_11::Mac802_11(PHY_MIB *p, MAC_MIB *m) : Mac(), 	mhIF_(this), mhNav_(this), mhRecv_(this), mhSend_(this),-	mhDefer_(this, p->SlotTime), mhBackoff_(this, p->SlotTime)+	mhDefer_(this, p->SlotTime), mhBackoff_(this, p->SlotTime),+// wqos - Sat 18 Aug 01, 16:49 - dugdale +       mhBeacon_(this)				       +// wqos - changes by dugdale ends { 	macmib_ = m; 	phymib_ = p;@@ -175,13 +208,20 @@ 	sta_seqno_ = 1; 	cache_ = 0; 	cache_node_count_ = 0;++  // wqos - Fri 06 Oct 00, 10:29 - dugdale+  pc_=0; dtimcount_=0; cfp_=0; +  cfpcount_ = macmib_->dot11CFPPeriod;+  pktPCF_ = 0; pollList_=0;+  pollsToSend_=0; btbs_=0;+  // wqos - changes by dugdale ends } 	  int Mac802_11::command(int argc, const char*const* argv) {-	if (argc == 3) {+	if (argc >= 3) { 		if (strcmp(argv[1], "log-target") == 0) { 			logtarget_ = (NsObject*) TclObject::lookup(argv[2]); 			if(logtarget_ == 0)@@ -195,7 +235,52 @@ 			bzero(cache_, sizeof(Host) * (cache_node_count_+1 )); 			return TCL_OK; 		}+// wqos - Sat 18 Aug 01, 12:39 - dugdale+		// If this node is a base station, add a station to its polling list+		else if(strcmp(argv[1], "addSTA") == 0){+			if(pc_) {+				int macId = atoi(argv[2]);+				int cfPollable = atoi(argv[3]);+				int cfPollReq = atoi(argv[4]);+				+				pollList_->insertNode(macId, cfPollable, cfPollReq);+				// TODO: Some debug printouts and errorchecking.+				//      free(tmpstr);+				return TCL_OK;+			} else+				return TCL_ERROR;+		}+		// If this node is a base station, remove a station from its polling list+		else if(strcmp(argv[1], "remSTA") == 0){+			if(pc_) {+				int macId = atoi(argv[2]);+				if(pollList_->deleteNode(macId)==0)+					return TCL_OK;+				else+					return TCL_ERROR;+			} else+				return TCL_ERROR;+		}+		// Sets the beacon period+		else if(strcmp(argv[1], "beaconperiod") == 0){+			macmib_->dot11BeaconPeriod = atoi(argv[2]);+			// Calculate the maximum length of a CFP (the CFP interval - the time+			// to send a maximum length frame)+			// (Each beacon starts a CFP)+			macmib_->dot11CFPMaxDuration = macmib_->dot11CFPPeriod*(macmib_->dot11DTIMPeriod+1)*macmib_->dot11BeaconPeriod - tu(2346/bandwidth_);+			return TCL_OK;+		}+	} else if(argc==2) {+		// Let this node be the Point Coordinator+		if(strcmp(argv[1], "make-pc") == 0) {+			pc_=1;+			if(!pollList_)+				pollList_ = new PCFPollList();+			mhBeacon_.start(macmib_->dot11BeaconPeriod*0.001024);+			return TCL_OK;+		} 	}+	// wqos - changes by dugdale ends 	return Mac::command(argc, argv); } @@ -336,6 +421,11 @@ 				return; 			} 			break;+// wqos - Sat 18 Aug 01, 17:17 - dugdale 			+		case MAC_Subtype_CFEnd:+		case MAC_Subtype_CFEnd_CFACK:+			break;			+// wqos - changes by dugdale ends 		default: 			fprintf(stderr, "invalid MAC Control subtype\n"); 			exit(1);@@ -353,6 +443,15 @@ 				return; 			} 			break;+// wqos - Sat 18 Aug 01, 17:17 - dugdale 			+		case MAC_Subtype_Data_CFACK:+		case MAC_Subtype_Data_CFACK_CFPoll:+		case MAC_Subtype_NullFunction:+		case MAC_Subtype_CFACK:+		case MAC_Subtype_CFPoll:+		case MAC_Subtype_CFACK_CFPoll:			+			break;+// wqos - changes by dugdale ends 		default: 			fprintf(stderr, "invalid MAC Data subtype\n"); 			exit(1);@@ -414,12 +513,30 @@ 	assert(mhSend_.busy() == 0); 	assert(mhDefer_.busy() == 0); +	// wqos - Thu 09 Nov 00, 09:55 - dugdale+	if(btbs_) { // Make sure beacons are sent...+		btbs_=0;+		send_beacon();+	}+	// wqos - changes by dugdale ends+ 	if(pktCTRL_) { 		/* 		 *  Need to send a CTS or ACK. 		 */ 		mhDefer_.start(sifs_);-	} else if(pktRTS_) {+	}+	// wqos - Tue 10 Oct 00, 14:17 - dugdale +	else if(pktPCF_) { // We have been polled, and should send a packet+		//		if(mhBackoff_.busy() && !mhBackoff_.paused()) // Should we really do this?? +		if(mhBackoff_.busy()) // Should we really do this?? +			mhBackoff_.stop(); // Pausing+		//			mhBackoff_.pause(); // Pausing+		mhDefer_.start(sifs_);+		// We should only wait a SIFS to send this...+	}+	// wqos - changes by dugdale ends+	else if(pktRTS_) { 		if(mhBackoff_.busy() == 0) 			mhDefer_.start(difs_); 	} else if(pktTx_) {@@ -453,6 +570,11 @@ 		return; 	} +	// wqos - Fri 13 Oct 00, 09:03 - dugdale+	if(check_pktPCF() == 0)+		return;+	// wqos - changes by dugdale ends+	 	if(check_pktRTS() == 0) 		return; @@ -463,11 +585,25 @@ void Mac802_11::deferHandler() {-	assert(pktCTRL_ || pktRTS_ || pktTx_);+// wqos - Sat 18 Aug 01, 13:14 - dugdale+	assert(pktCTRL_ || pktRTS_ || pktTx_ || pktPCF_);+// wqos - changes by dugdale ends  	if(check_pktCTRL() == 0) 		return; +	// wqos - Sat 18 Aug 01, 13:15 - dugdale +	if(check_pktPCF() == 0)+		return;+	// wqos - changes by dugdale ends+	+	// wqos - Sat 06 Jan 01, 15:22 - dugdale+	// REMOVE THIS LATER!!!!!+	//if(mhBackoff_.busy())+	//	mhBackoff_.stop();++	// Let's see if it works with the above commented out.+	// wqos - changes by dugdale ends 	assert(mhBackoff_.busy() == 0); 	//if (mhBackoff_.busy() != 0) 	//{@@ -484,6 +620,12 @@ void Mac802_11::navHandler() {+	// wqos - Fri 06 Oct 00, 11:38 - dugdale+	// If this is the PC, and we have had a CFP, end it now+	if(!pc_&&cfp_) +		cfp_=0;+	// wqos - changes by dugdale ends+ 	if(is_idle() && mhBackoff_.paused()) 		mhBackoff_.resume(difs_); }@@ -507,7 +649,28 @@ 	tx_active_ = 0; } +// wqos - Tue 26 Sep 00, 16:49 - dugdale+void+Mac802_11::beaconHandler()+{+	// Schedule the next beacon+	mhBeacon_.start(macmib_->dot11BeaconPeriod*0.001024);+	// Send the beacon+	send_beacon();+} +void+Mac802_11::pcfHandler()+{+	if(pc_) {+		// Send CFEnd frame+		cfp_=0;+	} else {+		set_nav(macmib_->dot11CFPMaxDuration);+	}+}+// wqos - changes by dugdale ends+ /* ======================================================================    The "real" Timer Handler Routines    ====================================================================== */@@ -540,7 +703,45 @@ 	case MAC_ACK: 		assert(pktCTRL_); 		Packet::free(pktCTRL_); pktCTRL_ = 0;+		// wqos - Wed 08 Nov 00, 14:43 - dugdale+		// If we are a base station and this is during a CFP we want to send a+		// CFPoll or CFEnd frame+		if(cfp_&&pc_) {+			// Check if there is time left on the CFP and if there are polls left to send+			if((Scheduler::instance().clock()<lastPoll_)&&pollsToSend_) {+				pollsToSend_--;+				sendPoll();+			} else {+				sendCFEnd();+			}+		}+		// wqos - changes by dugdale ends+		break;+		// wqos - Thu 26 Oct 00, 16:14 - dugdale+	case MAC_BEACONING:+		if(pktPCF_) {+			Packet::free(pktPCF_); pktPCF_ = 0;+		}	+		if(cfp_) { // Now we have sent the beacon and should start the CFP+			do_cfp();+		} 		break;+		// wqos - changes by dugdale ends+		+		// wqos - Tue 10 Oct 00, 14:52 - dugdale +	case MAC_POLLING:+		fprintf(stderr, "Poll timed out!!!\n");+		Packet::free(pktPCF_); pktPCF_ = 0;+		// Check if there is time left on the CFP and if there are polls left to send+		if((Scheduler::instance().clock()<lastPoll_)&&pollsToSend_) {+			pollsToSend_--;+			sendPoll();+		} else {+			sendCFEnd();+		}++		break;+		// wqos - changes by dugdale ends 	case MAC_IDLE: 		break; 	default:@@ -642,7 +843,9 @@  	switch(mh->dh_fc.fc_subtype) { 	case MAC_Subtype_Data:-		if(! is_idle()) {+		// wqos - Thu 30 Nov 00, 15:06 - dugdale +		if(! is_idle()&&!cfp_) {+			// wqos - changes by dugdale ends 			sendRTS(ETHER_ADDR(mh->dh_da)); 			inc_cw(); 			mhBackoff_.start(cw_, is_idle());@@ -666,6 +869,75 @@ 	return 0; } +// wqos - Tue 10 Oct 00, 14:11 - dugdale +int+Mac802_11::check_pktPCF()+{+	struct hdr_mac802_11 *mh;+	double timeout;+	+	//  assert(mhBackoff_.busy() == 0);+	+	if(pktPCF_ == 0)+		return -1;+	+	mh = HDR_MAC802_11(pktPCF_);+	int len = HDR_CMN(pktPCF_)->size();+	+	switch(mh->dh_fc.fc_type) {+	case MAC_Type_Data:+		switch(mh->dh_fc.fc_subtype) {+		case MAC_Subtype_CFPoll:+			fprintf(stderr,"Sent poll to %d at time %f\n",ETHER_ADDR(mh->dh_da), (Scheduler::instance()).clock());+			// The polled station should respond within a PIFS+			timeout = TX_Time(pktPCF_)+pifs_;+			SET_TX_STATE(MAC_POLLING);+			break;+		}+		break;+	case MAC_Type_Control:

⌨️ 快捷键说明

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