📄 pcf_support-2.1b8.patch
字号:
+ break;+ case MAC_Type_Control:+ switch(subtype) {+ case MAC_Subtype_CFEnd:+ fprintf(stderr,"CFEnd: %f\n",s.clock());+ // assert(pktPCF_ == 0);+ + + mh->dh_duration = 32768;+ // mh->dh_scontrol = sta_seqno_++;+ + cfp_ = 0;+ + break;+ }+ break;+ case MAC_Type_Data:+ switch(subtype) {+ case MAC_Subtype_CFPoll:+ dst=pollList_->getNextPollable();+ defertime=sifs_;+ if(dst==-1) { // No stations to poll...+ sendCFEnd(); + return;+ }+ fprintf(stderr,"Poll: %d %f\n",dst,s.clock());+ // assert(pktPCF_ == 0);+ + mh->dh_duration = 32768; // This is sent during a CFP+ + mh->dh_scontrol = sta_seqno_++;++ break;+ }+ break;+ }++ pktPCF_ = p;++ STORE4BYTE(&dst,(mh->dh_da));+ STORE4BYTE(&index_, (mh->dh_sa));++ /* CAN THIS BE REMOVED?????? /dugdale+ * drop the packet if the node is in sleep mode+ XXX sleep mode can't stop node from sending packets+ */+ EnergyModel *em = netif_->node()->energy_model();+ if (em && em->sleep()) {+ em->set_node_sleep(0);+ em->set_node_state(EnergyModel::INROUTE);+ }++ if(mhBackoff_.busy() == 0) {+ if(is_idle()) {+ /*+ * If we are already deferring, there is no+ * need to reset the Defer timer.+ */+ if(mhDefer_.busy() == 0)+ mhDefer_.start(defertime);+ }+ + /*+ * If the medium is NOT IDLE, then we start+ * the backoff timer.+ */++ // Should we really do this here????????? /dugdale+ else {+ mhBackoff_.start(cw_, is_idle());+ }+ }+}+// wqos - changes by dugdale ends++++// wqos - Fri 06 Oct 00, 11:20 - almquist+/* ======================================================================+ Implementation of the PCFPollList + ======================================================================++ This polling list is used by the Point Coordinator (PC) in the PCF scheme+ to maintain a list of stations to poll (and of those not to poll as well). +*/++/**+ Constructor++ This will initialize the list and set nextToBePolled to the first element in the list.+ */+PCFPollList::PCFPollList(){+ lastPollable = lastPolled = firstElement = lastElement = NULL;+ // nrOfNodes = 0;+ fprintf(stderr, "DEBUG: PCFPollList created\n");+}++/**+ Destructor++ This removes all elements in the poll list.+*/+PCFPollList::~PCFPollList(){+ PCFPollElement *elem = firstElement;+ PCFPollElement *tmpElem;+ firstElement = lastElement = NULL;+ fprintf(stderr, "DEBUG: PCFPollList: Deleting elements with macId_ : ");+ while(elem != NULL){ + tmpElem = elem;+ elem = elem->next_;+ fprintf(stderr, "%d, ", elem->macId_);+ delete tmpElem; + }+ fprintf(stderr, "\nDEBUG: PCFPollList destroyed\n");+}++/**+ This will return the macId of the node to be polled.+ + @return The macId of the node to be polled or -1 if no nodes in list+ */+int+PCFPollList::getNextPollable(){+ PCFPollElement *toBePolled;+ if(firstElement == NULL){+ return -1;+ }++ if(lastPolled == NULL || lastPolled == lastElement){+ toBePolled = firstElement;+ } else {+ toBePolled = lastPolled->next_;+ }+ + switch(toBePolled->cfPollField_){+ case 0: // STA is not pollable+ case 1: // STA pollable but not req. to be put on pollinglist+ case 3: // STA pollable but req. never to be polled (PowerSave)+ if(toBePolled == lastElement){+ return -1;+ } else {+ return(this->getNextPollable());+ }+ break;+ case 2: // STA pollable and in pollinglist+ if(toBePolled->dontPoll_){+ return(this->getNextPollable());+ }+ lastPollable = toBePolled;+ break;+ default:+ fprintf(stderr, "Error: PCFPollList getNextPollable(): node %d has invalid CFPollable+CFPollReq fields, %x !\n", toBePolled->macId_, toBePolled->cfPollField_);+ break;+ }+ lastPolled = toBePolled;+ return toBePolled->macId_;+}++/**+ This inserts an element last in the poll list.++ @param macId The mac id of the node to insert.+ @param cfPollable Indicates if this node is pollable (1 or 0)+ @param cfPollReq Indicates if this node should be polled (1 or 0)+ */+void+PCFPollList::insertNode(int macId, int cfPollable, int cfPollReq){+ int cfPollField = (cfPollable<<1) | cfPollReq;+ fprintf(stderr, "DEBUG: PCFPollList insertNode(%d, %d, %d): cfPollField = %d\n",+ macId, cfPollable, cfPollReq, cfPollField);+ PCFPollElement *elem = new PCFPollElement(macId, cfPollField);+ if(firstElement == NULL){+ firstElement = lastElement = elem;+ } else {+ lastElement->next_ = elem;+ lastElement = elem;+ }+ // nrOfNodes++;+}++/**+ Deletes a node from the list+ Returns zero if successful, otherwise -1+*/+int+PCFPollList::deleteNode(int macId) {+ PCFPollElement *prev=NULL, *elem = firstElement;+ while(elem != NULL){+ if(elem->macId_==macId) { // Remove this node from the list+ if(prev)+ prev->next_ = elem->next_;+ else+ firstElement = elem->next_;+ if(!elem->next_) {+ lastElement = prev;+ prev->next_=NULL;+ }+ if(elem==lastPolled)+ lastPolled=NULL;+ delete(elem);+ return 0;+ }+ prev=elem;+ elem = elem->next_;+ }+ return -1;+}++/**+ Initializes the list.+*/+void+PCFPollList::initPoll(){+ lastPolled = NULL;+ clearDontPoll();+}++/**+ Used to perform some sort of polling policy.+ + @param macId if this is -1 disable last polled STA+*/+void+PCFPollList::markDontPoll(int macId){+ if(macId != -1){+ PCFPollElement *elem = firstElement;+ while(elem != NULL && elem->macId_ != macId){+ elem = elem->next_;+ }+ elem->dontPoll_ = 1;+ } else {+ lastPolled->dontPoll_ = 1;+ }+}++/**+ Clears the dontPoll_ flag in all pollable nodes.+ */+void+PCFPollList::clearDontPoll(){+ PCFPollElement *elem = firstElement;+ while(elem != NULL){+ elem->dontPoll_ = 0;+ elem = elem->next_;+ }+}++/**+ Returns the number of pollable stations+ */+int+PCFPollList::numPollable() {+ PCFPollElement *elem = firstElement;+ int num=0;+ while(elem) {+ if(elem->cfPollField_ == 2)+ num++;+ elem = elem->next_;+ }+ return num;+}++// wqos - changes by almquist endsIndex: mac-802_11.hdiff -u mac-802_11.h:1.1 mac-802_11.h:1.1.1.1.6.4--- mac-802_11.h:1.1 Tue Aug 14 11:37:45 2001+++ mac-802_11.h Tue Aug 21 01:14:36 2001@@ -36,12 +36,42 @@ * Ported from CMU/Monarch's code, nov'98 -Padma. * wireless-mac-802_11.h */+/*+ * 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 ns_mac_80211_h #define ns_mac_80211_h #include "mac-timers.h" #include "marshall.h"+// wqos - Mon 09 Oct 00, 09:53 - almquist+#include "list.h"+extern int errno;+// wqos - changes by almquist ends #define GET_ETHER_TYPE(x) GET2BYTE((x)) #define SET_ETHER_TYPE(x,y) {u_int16_t t = (y); STORE2BYTE(x,&t);}@@ -56,11 +86,40 @@ #define MAC_Type_Control 0x01 #define MAC_Type_Data 0x02 #define MAC_Type_Reserved 0x03++// wqos - Tue 26 Sep 00, 16:19 - almquist+// Control subtypes+#define MAC_Subtype_PSPoll 0x0A+#define MAC_Subtype_RTS 0x0B+#define MAC_Subtype_CTS 0x0C+#define MAC_Subtype_ACK 0x0D+#define MAC_Subtype_CFEnd 0x0E+#define MAC_Subtype_CFEnd_CFACK 0x0F++// Data subtypes+#define MAC_Subtype_Data 0x00+#define MAC_Subtype_Data_CFACK 0x01+#define MAC_Subtype_Data_CFPoll 0x02+#define MAC_Subtype_Data_CFACK_CFPoll 0x03+#define MAC_Subtype_NullFunction 0x04+#define MAC_Subtype_CFACK 0x05+#define MAC_Subtype_CFPoll 0x06+#define MAC_Subtype_CFACK_CFPoll 0x07++// Management subtypes+#define MAC_Subtype_Association_REQ 0x00+#define MAC_Subtype_Association_RESP 0x01+#define MAC_Subtype_ReAssociation_REQ 0x02+#define MAC_Subtype_ReAssociation_RESP 0x03+#define MAC_Subtype_Probe_REQ 0x04+#define MAC_Subtype_Probe_RESP 0x05+#define MAC_Subtype_Beacon 0x08+#define MAC_Subtype_ATIM 0x09+#define MAC_Subtype_DisAssociation 0x0A+#define MAC_Subtype_Auth 0x0B+#define MAC_Subtype_DeAuth 0x0C -#define MAC_Subtype_RTS 0x0B-#define MAC_Subtype_CTS 0x0C-#define MAC_Subtype_ACK 0x0D-#define MAC_Subtype_Data 0x00+// wqos - changes by almquist ends struct frame_control { u_char fc_subtype : 4;@@ -111,7 +170,96 @@ u_char dh_body[0]; // XXX Non-ANSI }; +// wqos - 2000-09-26 dugdale+// MAC Management frame fields+#define MMFF_SSID 0+#define MMFF_SUPPORTED_RATES 1+#define MMFF_FH_PARAM_SET 2+#define MMFF_DS_PARAM_SET 3+#define MMFF_CF_PARAM_SET 4+#define MMFF_TIM 5+#define MMFF_IBSS_PARAM_SET 6++struct mmff_SSID {+ // Not used in this implementation+ u_char elemID;//=MMFF_SSID;+ u_char length;//=0;+ // char SSID[0];+}; +// Supported rates+struct mmff_rates {+ // Not used in this implementation+ u_char elemID;//=MMFF_SUPPORTED_RATES;+ u_char length;//=1;+ char rates[1];+};++// FH Parameter Set+struct mmff_FHParamSet {+ u_char elemID;//=MMFF_FH_PARAM_SET;+ u_char length;+ u_int16_t dwelltime;+ u_char hopset;+ u_char hoppattern;+ u_char hopindex;+};++// DS Parameter Set+struct mmff_DSParamSet {+ u_char elemID;//=MMFF_DS_PARAM_SET;+ u_char length;+ u_char dot11CCN; // dot11CurrentChannelNumber+};++// CF Parameter Set+struct mmff_CFParamSet {+ u_char elemID;//=MMFF_CF_PARAM_SET;+ u_char length;+ u_char CFPCount;+ u_char CFPPeriod;+ u_int16_t CFPMaxDuration;+ u_int16_t CFPDurRemaining;+};+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -