📄 mac-802_11.h
字号:
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- * * Copyright (c) 1997 Regents of the University of California. * All rights reserved. * * 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 following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Computer Systems * Engineering Group at Lawrence Berkeley Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Header: /u23/ns-user/cvsroot/ns-2/mac-802_11.h,v 1.1.1.1.6.3 2001/08/20 12:04:14 dugdale Exp $ * * 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);}/* ====================================================================== Frame Formats ====================================================================== */#define MAC_ProtocolVersion 0x00#define MAC_Type_Management 0x00#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// wqos - changes by almquist endsstruct frame_control { u_char fc_subtype : 4; u_char fc_type : 2; u_char fc_protocol_version : 2; u_char fc_order : 1; u_char fc_wep : 1; u_char fc_more_data : 1; u_char fc_pwr_mgt : 1; u_char fc_retry : 1; u_char fc_more_frag : 1; u_char fc_from_ds : 1; u_char fc_to_ds : 1;};struct rts_frame { struct frame_control rf_fc; u_int16_t rf_duration; u_char rf_ra[ETHER_ADDR_LEN]; u_char rf_ta[ETHER_ADDR_LEN]; u_char rf_fcs[ETHER_FCS_LEN];};struct cts_frame { struct frame_control cf_fc; u_int16_t cf_duration; u_char cf_ra[ETHER_ADDR_LEN]; u_char cf_fcs[ETHER_FCS_LEN];};struct ack_frame { struct frame_control af_fc; u_int16_t af_duration; u_char af_ra[ETHER_ADDR_LEN]; u_char af_fcs[ETHER_FCS_LEN];};// XXX This header does not have its header access function because it shares// the same header space with hdr_mac.struct hdr_mac802_11 { struct frame_control dh_fc; u_int16_t dh_duration; u_char dh_da[ETHER_ADDR_LEN]; u_char dh_sa[ETHER_ADDR_LEN]; u_char dh_bssid[ETHER_ADDR_LEN]; u_int16_t dh_scontrol; 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 6struct mmff_SSID { // Not used in this implementation u_char elemID;//=MMFF_SSID; u_char length;//=0; // char SSID[0];};// Supported ratesstruct mmff_rates { // Not used in this implementation u_char elemID;//=MMFF_SUPPORTED_RATES; u_char length;//=1; char rates[1];};// FH Parameter Setstruct 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 Setstruct mmff_DSParamSet { u_char elemID;//=MMFF_DS_PARAM_SET; u_char length; u_char dot11CCN; // dot11CurrentChannelNumber};// CF Parameter Setstruct 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;};// IBSS Parameter Setstruct mmff_IBSSParamSet { u_char elemID;//=MMFF_IBSS_PARAM_SET; u_char length; };struct mmff_TIM { u_char elemID;//=MMFF_TIM; u_char length; u_char DTIMcount; u_char DTIMperiod; u_char bitmapcontrol;//=0; // These are ignored in this u_char PVB[1]; // implementation... (PVB could be // up to 251 octets long IRL)};struct beacon_frame { struct frame_control bf_fc; u_int16_t bf_duration; u_char bf_da[ETHER_ADDR_LEN]; u_char bf_sa[ETHER_ADDR_LEN]; u_char bf_bssid[ETHER_ADDR_LEN]; u_int16_t bf_scontrol; unsigned long long bf_timestamp; u_int16_t bf_binterval; u_int16_t bf_capability; struct mmff_SSID bf_ssid; struct mmff_rates bf_supported_rates; struct mmff_FHParamSet bf_fhparamset; struct mmff_DSParamSet bf_dsparamset; struct mmff_CFParamSet bf_cfparamset; struct mmff_IBSSParamSet bf_ibssparamset; struct mmff_TIM bf_tim; u_char bf_fcs[ETHER_FCS_LEN];};// wqos - changes by dugdale ends/* ====================================================================== Definitions ====================================================================== */#define ETHER_HDR_LEN \ ((phymib_->PreambleLength >> 3) + \ (phymib_->PLCPHeaderLength >> 3) + \ sizeof(struct hdr_mac802_11) + \ ETHER_FCS_LEN)#define ETHER_RTS_LEN \ ((phymib_->PreambleLength >> 3) + \ (phymib_->PLCPHeaderLength >> 3) + \ sizeof(struct rts_frame))#define ETHER_CTS_LEN \ ((phymib_->PreambleLength >> 3) + \ (phymib_->PLCPHeaderLength >> 3) + \ sizeof(struct cts_frame))#define ETHER_ACK_LEN \ ((phymib_->PreambleLength >> 3) + \ (phymib_->PLCPHeaderLength >> 3) + \ sizeof(struct ack_frame))#define RTS_Time (8 * ETHER_RTS_LEN / bandwidth_)#define CTS_Time (8 * ETHER_CTS_LEN / bandwidth_)#define ACK_Time (8 * ETHER_ACK_LEN / bandwidth_)#define DATA_Time(len) (8 * (len) / bandwidth_)/* * IEEE 802.11 Spec, section 9.2.5.7 * - After transmitting an RTS, a node waits CTSTimeout * seconds for a CTS. * * IEEE 802.11 Spec, section 9.2.8 * - After transmitting DATA, a node waits ACKTimeout * seconds for an ACK. * * IEEE 802.11 Spec, section 9.2.5.4 * - After hearing an RTS, a node waits NAVTimeout seconds * before resetting its NAV. I've coined the variable * NAVTimeout. * */#define CTSTimeout ((RTS_Time + CTS_Time) + 2 * sifs_)#define ACKTimeout(len) (DATA_Time(len) + ACK_Time + sifs_ + difs_)#define NAVTimeout (2 * phymib_->SIFSTime + CTS_Time + 2 * phymib->SlotTime)#define RTS_DURATION(pkt) \ usec(sifs_ + CTS_Time + sifs_ + TX_Time(pkt) + sifs_ + ACK_Time)#define CTS_DURATION(d) \ usec((d * 1e-6) - (CTS_Time + sifs_))#define DATA_DURATION() \ usec(ACK_Time + sifs_)#define ACK_DURATION() 0x00 // we're not doing fragments now/* * IEEE 802.11 Spec, section 15.3.2 * - default values for the DSSS PHY MIB */#define DSSS_CWMin 31
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -