/*
* gmac.h
* Copyright (C) 2000 by the University of Southern California
* $Id: gmac.h,v 1.11 2005/08/25 18:58:07 johnh Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*
* The copyright of this module includes the following
* linking-with-specific-other-licenses addition:
*
* In addition, as a special exception, the copyright holders of
* this module give you permission to combine (via static or
* dynamic linking) this module with free software programs or
* libraries that are released under the GNU LGPL and with code
* included in the standard release of ns-2 under the Apache 2.0
* license or under otherwise-compatible licenses with advertising
* requirements (or modified versions of such code, with unchanged
* license). You may copy and distribute such a system following the
* terms of the GNU GPL for this module and the licenses of the
* other code concerned, provided that you include the source code of
* that other code when and as the GNU GPL requires distribution of
* source code.
*
* Note that people who make modified versions of this module
* are not obligated to grant this special exception for their
* modified versions; it is their choice whether to do so. The GNU
* General Public License gives permission to release a modified
* version without this exception; this exception also makes it
* possible to release a modified version which carries forward this
* exception.
*
*/
// gmac is designed and developed by Wei Ye (SCADDS/ISI)
// and is ported into ns by Padma Haldar, June'02.
// Contributors: Yuan Li
// This module implements Sensor-MAC
// See http://www.isi.edu/scadds/papers/gmac_infocom.pdf for details
//
// It has the following functions.
// 1) Both virtual and physical carrier sense
// 2) RTS/CTS for hidden terminal problem
// 3) Backoff and retry
// 4) Broadcast packets are sent directly without using RTS/CTS/ACK.
// 5) A long unicast message is divided into multiple TOS_MSG (by upper
// layer). The RTS/CTS reserves the medium for the entire message.
// ACK is used for each TOS_MSG for immediate error recovery.
// 6) Node goes to sleep when its neighbor is communicating with another
// node.
// 7) Each node follows a periodic listen/sleep schedule
// 8.1) At bootup time each node listens for a fixed SYNCPERIOD and then
// tries to send out a sync packet. It suppresses sending out of sync pkt
// if it happens to receive a sync pkt from a neighbor and follows the
// neighbor's schedule.
// 8.2) Or a node can choose its own schecule instead of following others, the
// schedule start time is user configurable
// 9) Neighbor Discovery: in order to prevent that two neighbors can not
// find each other due to following complete different schedules, each
// node periodically listen for a whole period of the SYNCPERIOD
// 10) Duty cycle is user configurable
// New features including adaptive listen
// See http://www.isi.edu/~weiye/pub/gmac_ton.pdf
#ifndef NS_GMAC
#define NS_GMAC
//test features described in Journal paper, adaptive listen, etc
//#ifndef JOURNAL_PAPER
//#define JOURNAL_PAPER
//#endif
#ifndef dc_aware
#define dc_aware
#endif
#include "mac.h"
#include "mac-802_11.h"
#include "cmu-trace.h"
#include "random.h"
#include "timer-handler.h"
#ifdef dc_aware
#endif
/* User-adjustable MAC parameters
*--------------------------------
* The default values can be overriden in Each application's Makefile
* GMAC_MAX_NUM_NEIGHB: maximum number of neighbors.
* GMAC_MAX_NUM_SCHED: maximum number of different schedules.
* GMAC_DUTY_CYCLE: duty cycle in percentage. It controls the length of sleep
* interval.
* GMAC_RETRY_LIMIT: maximum number of RTS retries for sending a single message.
* GMAC_EXTEND_LIMIT: maximum number of times to extend Tx time when ACK timeout
happens.
*/
#ifndef GMAC_MAX_NUM_NEIGHBORS
#define GMAC_MAX_NUM_NEIGHBORS 20
#endif
#ifndef GMAC_MAX_NUM_SCHEDULES
#define GMAC_MAX_NUM_SCHEDULES 4
#endif
#ifndef GMAC_DUTY_CYCLE
#define GMAC_DUTY_CYCLE 10
#endif
#ifndef GMAC_RETRY_LIMIT
#define GMAC_RETRY_LIMIT 5
#endif
#ifndef GMAC_EXTEND_LIMIT
#define GMAC_EXTEND_LIMIT 5
#endif
#ifdef JOURNAL_PAPER
#ifndef GMAC_UPDATE_NEIGHB_PERIOD
#define GMAC_UPDATE_NEIGHB_PERIOD 50
#endif
#ifndef GUARDTIME
#define GUARDTIME 0.001
#endif
#endif
/* Internal MAC parameters
*--------------------------
* Do NOT change them unless for tuning S-MAC
* SYNC_CW: number of slots in the sync contention window, must be 2^n - 1
* DATA_CW: number of slots in the data contention window, must be 2^n - 1
* SYNC_PERIOD: period to send a sync pkt, in cycles.
* SRCH_CYCLES_LONG: # of SYNC periods during which a node performs a neighbor discovery
* SRCH_CYCLES_SHORT: if there is no known neighbor, a node need to seach neighbor more aggressively
*/
#define SYNC_CW 31
#define DATA_CW 63
#define SYNCPERIOD 10
#define SYNCPKTTIME 3 // an adhoc value used for now later shld converge with durSyncPkt_
#define SRCH_CYCLES_SHORT 3
#define SRCH_CYCLES_LONG 22
/* Physical layer parameters
*---------------------------
* Based on the parameters from PHY_RADIO and RADIO_CONTROL
* CLOCK_RES: clock resolution in ms.
* BANDWIDTH: bandwidth (bit rate) in kbps. Not directly used.
* PRE_PKT_BYTES: number of extra bytes transmitted before each pkt. It equals
* preamble + start symbol + sync bytes.
* ENCODE_RATIO: output/input ratio of the number of bytes of the encoding
* scheme. In Manchester encoding, 1-byte input generates 2-byte output.
* PROC_DELAY: processing delay of each packet in physical and MAC layer, in ms
*/
#define CLOCKRES 1 // clock resolution is 1ms
#define BANDWIDTH 20 // kbps =>CHANGE BYTE_TX_TIME WHENEVER BANDWIDTH CHANGES
//#define BYTE_TX_TIME 4/10 // 0.4 ms to tx one byte => changes when bandwidth does
#define PRE_PKT_BYTES 5
#define ENCODE_RATIO 2 /* Manchester encoding has 2x overhead */
#define PROC_DELAY 1
// Note everything is in clockticks (CLOCKRES in ms) for tinyOS
// so we need to convert that to sec for ns
#define CLKTICK2SEC(x) ((x) * (CLOCKRES / 1.0e3))
#define SEC2CLKTICK(x) ((x) / (CLOCKRES / 1.0e3))
// MAC states
#define SLEEP 0 // radio is turned off, can't Tx or Rx
#define IDLE 1 // radio in Rx mode, and can start Tx
//#define CHOOSE_SCHED 2 // node in boot-up phase, needs to choose a schedule
#define CR_SENSE 2 // medium is free, do it before initiate a Tx
//#define BACKOFF 3 // medium is busy, and cannot Tx
#define WAIT_CTS 3 // sent RTS, waiting for CTS
#define WAIT_DATA 4 // sent CTS, waiting for DATA
#define WAIT_ACK 5 // sent DATA, waiting for ACK
#ifdef JOURNAL_PAPER
#define TX_NEXT_FRAG 6 // send one fragment, waiting for next from upper layer
#else
#define WAIT_NEXTFRAG 6 // send one fragment, waiting for next from upper lay
四散
- 粉丝: 69
- 资源: 1万+
最新资源
- 基于SAR-ADC与OTA运放的PLL锁相环与Bandgap基准电源视频教学进阶,SAR-ADC 运放OTA PLL锁相环基础,pll进阶 bandgap基准电源 LDO 视频教学 ,SAR-ADC
- "两种方法求解MTPA数值解析详解" 或者 "探讨MTPA数值求解的两种策略",MTPA数值求解两种方法 ,MTPA数值求解; 两种方法; 优化算法; 迭代法; 解析法; 计算方法; 精确度比较 ,M
- 医药洁净室空调箱多模式控制程序详解:西门子PLC与昆仑通泰触摸屏联合应用,停止模式、生产模式、值班模式、消毒循环与排风模式控制逻辑解析,医药洁净室空调箱各种模式实现程序介绍 西门子1500 PLC+昆
- 《Abaqus模拟结构调谐质量阻尼器与惯容器制作教程:飞轮转动惯量与丝杠螺距详解》,abaqus生成结构调谐质量阻尼器和惯容器,模拟丝杠螺距,飞轮转动惯量,惯容系数 视频讲解 ,核心关键词:Abaq
- 电-气-热综合能源系统耦合优化调度模型:基于MATLAB YALMIP与CPLEX、Gurobi求解器的细致文档参考,MATLAB代码:电-气-热综合能源系统耦合优化调度 关键词:综合能源系统 优化
- 基于Ansoft Maxwell的电磁场有限元仿真:无线电能传输与电机建模研究,ansoft ansys Maxwell 有限元仿真 电磁场模型 主要为无线电能传输WPT 磁耦合谐振 多相多绕组变压
- 30KW储能双向逆变PCSPS设计方案资料:含双向DCDC与三电平逆变技术、仿真源码、原理图及控制器源码,30KW储能PCS逆变器双向变流器设计方案资料,双向DCDC和三电平逆变PCS 1.此系列为
- MATLAB驱动的ASR防滑转模型:PID与对照控制算法对比,冰雪路面条件下滑移率与车速轮速对照图展示,MATLAB驱动防滑转模型ASR模型 ASR模型驱动防滑转模型 ?牵引力控制系统模型 选择PID
- MATLAB七自由度分布式驱动电动汽车模型的动态仿真与模糊控制策略探究,MATLAB分布式驱动电动汽车模型 MATLAB七自由度整车模型 分布式驱动电动车整车模型 四轮驱动电动车整车模型 轮毂电机电动
- EPS电动助力转向系统:基于MATLAB/Simulink模型搭建与单模型仿真分析,EPS汽车电动助力转向模型 MATLAB电动助力转向模型 Simulink电动助力转向模型 总体模型搭建包括:EPS
- 高频方波电压注入法用于零低速IPMSM无感控制算法仿真研究:转子位置精确估计与动态性能优化,高频方波电压注入零低速IPMSM无感控制算法仿真,在估计的d轴注入高频方波电压来估计转子位置,具有较高的稳态
- Labview Nivision视觉程序:LV2014版源程序,仿视觉助手功能强大,大部分功能可用,Labview Nivision视觉程序,labview源程序,大部分功能可以用,仿视觉助手的 版
- 基于双闭环SVPWM羊角波调制的二极管钳位型NPC控制系统:理论推导与实践应用,高质量电能输出,功率稳定且波形清晰 ,双闭环SVPWM(羊角波)调制的二极管钳位型NPC控制系统,手写理论推导 DC:8
- RSLogix系列软件授权授权详解与版本更新通知:涵盖RSLogix 5000 Studio编程VMware环境支持及固件版本信息,AB罗克韦尔 RSLogix5000 V10-20.5 Studio
- MATLAB滑动窗口函数:高效生成机器学习样本数据,适用于数据分帧与一维原始数据处理,MATLAB加窗滑动窗口程序,MATLAB数据处理,可以直接对一维原始数据生成样本 找了好久的滑动窗口的程序都
- 移相全桥ZVS零电压开通技术:实现滞后桥臂辅助电流源网络,开关频率达20kHz,功率输出500W,输入与输出电压分别为350V与50V ,移相全桥ZVS零电压开通 增加了辅助电流源网络实现滞后桥臂ZV
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈