📄 phy_802_15_4.h
字号:
// Copyright (c) 2001-2008, Scalable Network Technologies, Inc. All Rights Reserved.// 6701 Center Drive West// Suite 520// Los Angeles, CA 90045// sales@scalable-networks.com//// This source code is licensed, not sold, and is subject to a written// license agreement. Among other things, no portion of this source// code may be copied, transmitted, disclosed, displayed, distributed,// translated, used as the basis for a derivative work, or used, in// whole or in part, for any program or purpose other than its intended// use in compliance with the license agreement as part of the QualNet// software. This source code and certain of the algorithms contained// within it are confidential trade secrets of Scalable Network// Technologies, Inc. and may not be used as the basis for any other// software, hardware, product or service./* */#ifndef PHY_802_15_4_H#define PHY_802_15_4_H//#include "battery_model.h"#define PHY802_15_4_DEFAULT_TX_POWER_dBm 0.0#define PHY802_15_4_DEFAULT_MODULATION O_QPSK#define PHY802_15_4_800MHZ_DEFAULT_CHANNEL_BANDWIDTH 600000 // 800 MHz#define PHY802_15_4_DEFAULT_CHANNEL_BANDWIDTH 2000000 // 2400 //and 900 MHz frequency bands#define PHY802_15_4_BPSK_PREAMBLE_LENGTH 32#define PHY802_15_4_800MHZ_ASK_PREAMBLE_LENGTH 2#define PHY802_15_4_900MHZ_ASK_PREAMBLE_LENGTH 6#define PHY802_15_4_O_QPSK_PREAMBLE_LENGTH 8#define PHY802_15_4_SFD_LENGTH 8 // in symbols#define PHY802_15_4_PHR_LENGTH 8 // in bits#define PHY802_15_4_BPSK_BITS_PER_SYMBOL 1 // 800 and 900 MHz#define PHY802_15_4_800MHZ_ASK_BITS_PER_SYMBOL 20#define PHY802_15_4_900MHZ_ASK_BITS_PER_SYMBOL 5#define PHY802_15_4_O_QPSK_BITS_PER_SYMBOL 4//threshold in linear value#define PHY802_15_4_BPSK_THRESHOLD 1.2 // 800 and 900 MHz //frequency bands#define PHY802_15_4_800MHZ_ASK_THRESHOLD 2.2#define PHY802_15_4_900MHZ_ASK_THRESHOLD 0.7#define PHY802_15_4_O_QPSK_THRESHOLD 3.1 // 800 and 900 MHz //frequency bands#define PHY802_15_4_2400MHZ_O_QPSK_THRESHOLD 1.6#define PHY802_15_4_BPSK_THRESHOLD 1.2 // 800 and 900 MHz // frequency bands#define PHY802_15_4_800MHZ_ASK_THRESHOLD 2.2#define PHY802_15_4_900MHZ_ASK_THRESHOLD 0.7#define PHY802_15_4_O_QPSK_THRESHOLD 3.1 // 800 and 900 MHz // frequency bands#define PHY802_15_4_2400MHZ_O_QPSK_THRESHOLD 1.6#define PHY802_15_4_DEFAULT_CCA_MODE CARRIER_SENSE//10dB above the speicifed receiver sensitivity#define PHY802_15_4_BPSK_ED_THRESHOLD -82 // 800 and 900 MHz // frequency bands#define PHY802_15_4_ED_THRESHOLD -75 //#define PHY802_15_4_DEFAULT_BER_CONSTANT 0.5#define PHY802_15_4_800MHZ_O_QPSK_SYMBOL_RATE 25000 //per symbol 4 bits#define PHY802_15_4_O_QPSK_SYMBOL_RATE 62500 // 900 and 2400 MHz // per symbol 4 bits#define PHY802_15_4_O_QPSK_SPREAD_FACTOR 16 // 800 and 900 // frequency band#define PHY802_15_4_2400MHZ_O_QPSK_SPREAD_FACTOR 32#define PHY802_15_4_900MHZ_ASK_SYMBOL_RATE 50000 // per symbol 5 // bits#define PHY802_15_4_800MHZ_ASK_SYMBOL_RATE 12500 // per symbol // 20 bits#define PHY802_15_4_ASK_SPREAD_FACTOR 32 // 800 and 900 // frequency bands#define PHY802_15_4_800MHZ_BPSK_SYMBOL_RATE 20000#define PHY802_15_4_900MHZ_BPSK_SYMBOL_RATE 40000#define PHY802_15_4_BPSK_SPREAD_FACTOR 15 // 800 and 900 // frequency bands#define PHY802_15_4_BER_CONSTANT 8.0/240.0#define PHY802_15_4_BER_UPPER_BOUND_SUMMATION 17#define PHY802_15_4_DEFAULT_EXPONENT_FACTOR 10.0 // 800 AND // 900 MHz#define PHY802_15_4_2400MHZ_DEFAULT_EXPONENT_FACTOR 20.0 // 2400 MHz#define PHY802_15_4_RX_TX_TURNAROUND_TIME_IN_SYMBOL_PERIODS 12 // 12 symbol // duration//// PHY power consumption rate in mW.// Note:// The values below are set based on the reference "Performance Analysis// of IEEE 802.15.4 and ZigBee for Large-Scale Wireless Sensor Network// Applications"//// *** There is no guarantee that these values are correct! ***//#define BATTERY_SLEEP__POWER (1.5 / SECOND)#define BATTERY_RX__POWER (56.5 / SECOND)#define BATTERY_TX_POWER__OFFSET (48.0 / SECOND)#define BATTERY_TX_POWER__COEFFICIENT (12.6 / SECOND)enum Modulation { ASK, // amplitude shift keying BPSK, // binary phase shift keying O_QPSK // offset quadrature phase shift keying};enum PLMEsetTrxState { RX_ON, TX_ON, TRX_OFF, FORCE_TRX_OFF};enum phyCCAmode { ENERGY_ABOVE_THRESHOLD, CARRIER_SENSE, CARRIER_SENSE_WITH_ENERGY_ABOVE_THRESHOLD};//PHY PIB attributes (Table 19)typedef enum{ phyCurrentChannel = 0x00, phyChannelsSupported, phyTransmitPower, phyCCAMode}PPIBAenum;struct PHY_PIB{ int phyCurrentChannel; int phyChannelsSupported; double phyTransmitPower; phyCCAmode phyCCAMode;};/* * Structure for phy statistics variables */typedef struct phy802_15_4_stats_str { int totalTxSignals; int totalSignalsDetected; int totalSignalsLocked; int totalSignalsWithErrors; int totalRxSignalsToMac; double energyConsumed; clocktype turnOnTime; clocktype turnOnPeriod; int totalTxSignalsId; int totalSignalsDetectedId; int totalSignalsLockedId; int totalSignalsWithErrorsId; int totalRxSignalsToMacId; int currentSINRId; // for debugging. int energyConsumedId;} Phy802_15_4Stats;/* * Structure for Phy. */typedef struct struct_phy802_15_4_str { PhyData* thisPhy; float txPower_dBm; double linkQuality; double rxSensitivity_mW; double EDthreshold_mW; int dataRate; double channelBandwidth; //PowerCosts* powerConsmpTable;//added for energy modeling Message* rxMsg; double rxMsgPower_mW; clocktype rxTimeEvaluated; BOOL rxMsgError; clocktype rxEndTime; clocktype txOnPeriod; clocktype rxOnPeriod; clocktype turnOffPeriod; clocktype activationTime; clocktype deactivationTime; double noisePower_mW; double interferencePower_mW; PhyStatusType mode; PhyStatusType previousMode; Phy802_15_4Stats stats; phyCCAmode CCAmode; Modulation modulation; clocktype symbolPeriod; clocktype preambleHeaderPeriod; clocktype RxTxTurnAroundTime; int spreadFactor;} PhyData802_15_4;//**// FUNCTION :: Phy802_15_4GetStatus// LAYER :: PHY// PURPOSE :: Obtain the PHY status// PARAMETERS ::// + node : Node* : Pointer to node.// + phyNum : int : Index of the PHY// RETURN :: PhyStatusType : PHY status// **/static /*inline*/PhyStatusType Phy802_15_4GetStatus(Node *node, int phyNum) { PhyData802_15_4* phy802_15_4 = (PhyData802_15_4*)node->phyData[phyNum]->phyVar; return (phy802_15_4->mode);}//**// FUNCTION :: Phy802_15_4Init// LAYER :: PHY// PURPOSE :: Initialize configurable parameters// PARAMETERS ::// + node : Node* : Pointer to node.// + phyIndex : const int : Index of the PHY// + nodeInput : const NodeInput* : Pointer to node input// RETURN :: void : NULL// **/void Phy802_15_4Init( Node* node, const int phyIndex, const NodeInput *nodeInput);// /**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -