亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? smac.cc

?? 在ns2中仿真無線傳感器網絡mac層協議的代碼smac
?? CC
?? 第 1 頁 / 共 5 頁
字號:

/*
 * smac.cc
 * Copyright (C) 2000 by the University of Southern California
 * $Id: smac.cc,v 1.18 2005/12/10 17:57:13 liyuan 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.
 *
 */

// smac is designed and developed by Wei Ye (SCADDS/ISI)
// and is re-written for ns by Padma Haldar (CONSER/ISI).
// Contributors: Yuan Li

// This module implements Sensor-MAC
//  http://www.isi.edu/scadds/papers/smac_report.pdf
//
// 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/smac_ton.pdf
                                                                                                                                                           
#include "wireless-phy.h"
#include "smac.h"

static class MacSmacClass : public TclClass {
public:
       MacSmacClass() : TclClass("Mac/SMAC") {}
    TclObject* create(int, const char*const*) {
        return (new SMAC());
    }
} class_macSMAC;


// Timers call on expiration

int SmacTimer::busy()
{
    if (status_ != TIMER_PENDING)
        return 0;
    else
        return 1;
}

#ifdef JOURNAL_PAPER
void SmacUpdateNeighbTimer::expire(Event *e) {
        a_->handleUpdateNeighbTimer();
}
                                                                                                                                                            
void SmacAdaptiveListenTimer::expire(Event *e) {
        a_->handleAdaptiveListenTimer();
}
#endif

void SmacGeneTimer::expire(Event *e) {
    a_->handleGeneTimer();
}

void SmacRecvTimer::expire(Event *e) {
    stime_ = rtime_ = 0;
    a_->handleRecvTimer();
}

void SmacRecvTimer::sched(double time) {
    TimerHandler::sched(time);
    stime_ = Scheduler::instance().clock();
    rtime_ = time;
}

void SmacRecvTimer::resched(double time) {
    TimerHandler::resched(time);
    stime_ = Scheduler::instance().clock();
    rtime_ = time;
}

double SmacRecvTimer::timeToExpire() {
    return ((stime_ + rtime_) - Scheduler::instance().clock());
}

void SmacSendTimer::expire(Event *e) {
    a_->handleSendTimer();
}

void SmacNavTimer::expire(Event *e) {
    a_->handleNavTimer();
}

void SmacNeighNavTimer::sched(double time) {
    TimerHandler::sched(time);
    stime_ = Scheduler::instance().clock();
    rtime_ = time;
}

void SmacNeighNavTimer::expire(Event *e) {
    stime_ = rtime_ = 0;
    a_->handleNeighNavTimer();
}

double SmacNeighNavTimer::timeToExpire() {
    return ((stime_ + rtime_) - Scheduler::instance().clock());
}

void SmacCsTimer::expire(Event *e) {
    a_->handleCsTimer();
}

// if pending, cancel timer
void SmacCsTimer::checkToCancel() {
    if (status_ == TIMER_PENDING)
        cancel();
}

// void SmacChkSendTimer::expire(Event *e) {
//   a_->handleChkSendTimer();
// }

void SmacCounterTimer::sched(double time) {
    // the cycle timer assumes that all time shall be scheduled with time "left to sleep" 
    // and not the absolute time for a given state (sleep, sync or data). Thus in order 
    // to schedule for a sleep state, need to schedule with aggregate time CYCLETIME 
    // (sleeptime+synctime+dadatime).
    // Similarly for sync state, schedule with listenTime_ (synctime+datattime)
    // This is implemented to be in step with the counter used in actual smac.

    tts_ = time; // time before it goes to sleep again
    stime_ = Scheduler::instance().clock();
  
    if (time <= CLKTICK2SEC(cycleTime_) && time > CLKTICK2SEC(listenTime_)) { // in sleep state
        value_ = sleepTime_;
        if (status_ == TIMER_IDLE)
            TimerHandler::sched(time - CLKTICK2SEC(listenTime_)); 
        else
            TimerHandler::resched(time - CLKTICK2SEC(listenTime_)); 
    
    } else if ( time <= CLKTICK2SEC(listenTime_) && time > CLKTICK2SEC(dataTime_)) { // in sync state
        value_ = syncTime_;
        if (status_ == TIMER_IDLE)
            TimerHandler::sched(time - CLKTICK2SEC(dataTime_)); 
        else
            TimerHandler::resched(time - CLKTICK2SEC(dataTime_)); 
    
    } else { // in data state
        assert(time <= CLKTICK2SEC(dataTime_));
        value_ = dataTime_;
        if (status_ == TIMER_IDLE)
            TimerHandler::sched(time); 
        else
            TimerHandler::resched(time); 
    
    }

}

double SmacCounterTimer::timeToSleep() {
    return ((stime_ + tts_) - Scheduler::instance().clock()) ;
}

void SmacCounterTimer::expire(Event *e) {
    tts_ = stime_ = 0;
    a_->handleCounterTimer(index_);
}


#ifdef JOURNAL_PAPER
SMAC::SMAC() : Mac(), mhUpdateNeighb_(this),mhNav_(this), mhNeighNav_(this), mhSend_(this), mhRecv_(this), mhGene_(this), mhCS_(this), mhAdap_(this), syncFlag_(0) {
        int i;
#else
SMAC::SMAC() : Mac(), mhNav_(this), mhNeighNav_(this), mhSend_(this), mhRecv_(this), mhGene_(this), mhCS_(this), syncFlag_(0) {
#endif
    state_ = IDLE;
    radioState_ = RADIO_IDLE;
    tx_active_ = 0;
    mac_collision_ = 0;
  
    sendAddr_ = -1;
    recvAddr_ = -1;

    nav_ = 0;
    neighNav_ = 0;
  
    numRetry_ = 0;
    numExtend_ = 0;
    lastRxFrag_ = -3; // since -1, -2 and 0 could be valid pkt uid's
    //numFrags_ = 0;
    //succFrags_ = 0;

#ifdef JOURNAL_PAPER
        numFrags_ = 0;
        succFrags_ = 0;
        dataSched_ = 0;
        syncSched_ = 0;
                                                                                                                                                            
        globalSchedule_ = 0; // Do not test global schedule
        //globalSchedule_ = 1; // Test global schedule
                                                                                                                                                            
        updateNeighbList_ = 0;
                                                                                                                                                            
        sendSYNCFlag_ = 0;
                                                                                                                                                            
        sendAddr = -1;
        adapSend_ = 0;
        txRequest_ = 0;
                                                                                                                                                            
        adaptiveListen_ = 0;
#endif

    dataPkt_ = 0;
    pktRx_ = 0;
    pktTx_ = 0;

    /* setup internal mac and physical parameters
       ----------------------------------------------
       byte_tx_time_: time to transmit a byte, in ms. Derived from bandwidth
  
       slotTime_: time of each slot in contention window. It should be large
       enough to receive the whole start symbol but cannot be smaller than clock 
       resolution. in msec
  
       slotTime_sec_: slottime in sec
  
       difs_: DCF interframe space (from 802.11), in ms. It is used at the beginning
       of each contention window. It's the minmum time to wait to start a new 
       transmission.
  
       sifs_: short interframe space (f

       /rom 802.11), in ms. It is used before sending
       an CTS or ACK packet. It takes care of the processing delay of each pkt.
  
       eifs_: Entended interfrane space (from 802.11) in ms. Used for backing off 
       incase of a collision.

       guardTime_: guard time at the end of each listen interval, in ms.

    */

    byte_tx_time_ = 8.0 / BANDWIDTH;
    double start_symbol = byte_tx_time_ * 2.5;  // time to tx 20 bits
    slotTime_ = CLOCKRES >= start_symbol ? CLOCKRES : start_symbol;  // in msec
    slotTime_sec_ = slotTime_ / 1.0e3;   // in sec
    difs_ = 10.0 * slotTime_;
    sifs_ = 5.0 * slotTime_;
    eifs_ = 50.0 * slotTime_;
    guardTime_ = 4.0 * slotTime_;
  
    // calculate packet duration. Following equations assume 4b/6b coding.
    // All calculations yield in usec

    //durSyncPkt_ = ((SIZEOF_SMAC_SYNCPKT) * 12 + 18) / 1.0e4 ;

    durSyncPkt_ =  (PRE_PKT_BYTES + (SIZEOF_SMAC_SYNCPKT * ENCODE_RATIO)) * byte_tx_time_ + 1;
    durSyncPkt_ = CLKTICK2SEC(durSyncPkt_);

    //durDataPkt_ = ((SIZEOF_SMAC_DATAPKT) * 12 + 18) / 1.0e4 ;
    durDataPkt_ = (PRE_PKT_BYTES + (SIZEOF_SMAC_DATAPKT * ENCODE_RATIO)) * byte_tx_time_ + 1;
    durDataPkt_ = CLKTICK2SEC(durDataPkt_);

    //durCtrlPkt_ = ((SIZEOF_SMAC_CTRLPKT) * 12 + 18) / 1.0e4;
    durCtrlPkt_ = (PRE_PKT_BYTES + (SIZEOF_SMAC_CTRLPKT * ENCODE_RATIO)) * byte_tx_time_ + 1;
    durCtrlPkt_ = CLKTICK2SEC(durCtrlPkt_);
  
    // time to wait for CTS or ACK
    //timeWaitCtrl_ = durCtrlPkt_ + CLKTICK2SEC(4) ;    // timeout time
    double delay = 2 * PROC_DELAY + sifs_;
    timeWaitCtrl_ = CLKTICK2SEC(delay) + durCtrlPkt_;    // timeout time

  
    numSched_ = 0;
    numNeighb_ = 0;
    numSync_ = 1;  // perform neighbor discovery, do not go to sleep for the first SYNC period
    schedListen_ = 1;
    searchNeighb_ = 1;

#ifdef JOURNAL_PAPER
        schedState_ = 1;  // this is my first schedule
    
    // initialize neighbour table
        for (i = 0; i < SMAC_MAX_NUM_NEIGHBORS; i++) {
        neighbList_[i].nodeId = 0;
        neighbList_[i].schedId = 0;
        neighbList_[i].active = 0;
                neighbList_[i].state = 0;
        }
                                                                                                                                                            
        // initialize schedule table
        for (i = 0; i < SMAC_MAX_NUM_SCHEDULES; i++) {
                schedTab_[i].numNodes = 0;
                schedTab_[i].syncNode = 0;
        }
                                                                                                                                                            
                                                                                                                                                            
        schedTab_[0].numNodes = 1;  // I'm the only one on this schedule
        schedTab_[0].syncNode = index_;  // I'm the schedule initializer
        schedTab_[0].txData = 0;
        schedTab_[0].txSync = 0;
        schedTab_[0].chkSched = 0;
#endif
    	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久看| 精品国产污污免费网站入口| 麻豆久久久久久| 午夜精品爽啪视频| 亚洲女与黑人做爰| 国产精品不卡在线| 一区二区三区四区亚洲| 一区二区三区四区五区视频在线观看 | av在线综合网| 成人少妇影院yyyy| 99re这里都是精品| 日本道色综合久久| 欧美视频一二三区| 日韩西西人体444www| 日韩欧美自拍偷拍| 国产亚洲综合在线| 国产精品夫妻自拍| 亚洲电影中文字幕在线观看| 午夜精品视频在线观看| 久久精品国产一区二区| 国产精品一区二区久久精品爱涩| 国内精品国产成人国产三级粉色 | 欧美高清精品3d| 欧美一级一级性生活免费录像| 欧美一区二区三区精品| 国产日韩av一区| 一区二区三区在线视频观看58| 三级亚洲高清视频| 成人午夜精品在线| 精品视频一区三区九区| 久久久另类综合| 亚洲一区二区三区中文字幕在线| 老司机精品视频线观看86| 高清国产一区二区三区| 欧美日韩一级片网站| 久久久久久久综合色一本| 亚洲免费观看在线视频| 精品一区二区在线免费观看| 99久久久久久| 日韩片之四级片| 亚洲乱码国产乱码精品精98午夜| 亚洲成人动漫av| 成人av网站大全| 日韩一区二区免费高清| 亚洲欧洲国产日本综合| 免费精品视频最新在线| 在线观看视频91| 中文字幕国产一区| 开心九九激情九九欧美日韩精美视频电影 | 丝袜美腿成人在线| 成人av一区二区三区| 制服视频三区第一页精品| 日韩毛片一二三区| 国产精品乡下勾搭老头1| 制服丝袜日韩国产| 午夜私人影院久久久久| 成人app软件下载大全免费| 日韩欧美国产高清| 亚洲成av人片在www色猫咪| 99视频超级精品| 久久久精品综合| 国内精品久久久久影院一蜜桃| 欧美日韩免费一区二区三区视频| 国产精品久久久久久久久快鸭| 日韩**一区毛片| 欧美一二三在线| 青青草原综合久久大伊人精品优势| 91国内精品野花午夜精品| 中文字幕不卡的av| 国产999精品久久| 久久九九99视频| 国产一区二区不卡老阿姨| 欧美一区二区三区婷婷月色| 一区二区三区四区五区视频在线观看| 成人免费毛片高清视频| 中文幕一区二区三区久久蜜桃| 久久99国产精品久久99| 日韩一区二区三区免费看| 日本不卡视频在线| 3d成人h动漫网站入口| 日韩福利电影在线| 欧美成人a在线| 国产一区二区三区四| 亚洲国产精品激情在线观看| 成人黄页在线观看| 国产精品每日更新| 91网上在线视频| 亚洲午夜久久久久中文字幕久| 色菇凉天天综合网| 亚洲国产日韩在线一区模特| 欧美色涩在线第一页| 老司机午夜精品| 国产视频亚洲色图| 91污片在线观看| 日本不卡在线视频| 国产三级久久久| 色猫猫国产区一区二在线视频| 亚洲成人av中文| 精品国产伦一区二区三区观看体验| 国产成人精品综合在线观看| 中文子幕无线码一区tr| 91色.com| 蜜臀99久久精品久久久久久软件| 国产日韩影视精品| 日本精品视频一区二区| 免费成人av在线| 国产精品私房写真福利视频| 91久久精品网| 国产一区二区在线观看视频| 综合久久综合久久| 日韩精品一区国产麻豆| av一区二区久久| 美国毛片一区二区三区| 国产精品国产三级国产| 日韩一二三区视频| 99久久综合狠狠综合久久| 日韩中文字幕不卡| 亚洲国产精品黑人久久久| 欧美日韩国产在线观看| 成人黄色综合网站| 久久精品理论片| 亚洲高清在线精品| 中文字幕亚洲不卡| 精品国产露脸精彩对白 | 久久国产人妖系列| 亚洲特黄一级片| 久久久久成人黄色影片| 91精品午夜视频| 在线视频一区二区免费| 成人午夜看片网址| 国产一区二区三区精品视频| 亚洲国产精品久久人人爱| 国产精品传媒入口麻豆| 精品成a人在线观看| 欧美丝袜第三区| 色哦色哦哦色天天综合| 成人免费视频caoporn| 国产综合久久久久久久久久久久| 亚洲成av人片观看| 亚洲成人综合视频| 有码一区二区三区| 成人欧美一区二区三区| 国产精品蜜臀在线观看| 国产蜜臀av在线一区二区三区| 精品少妇一区二区| 精品国产乱码久久久久久1区2区| 欧美人xxxx| 91精品国模一区二区三区| 欧美日韩黄色影视| 91精品国产免费| 欧美一级日韩免费不卡| 在线不卡一区二区| 在线播放一区二区三区| 欧美精品粉嫩高潮一区二区| 欧美女孩性生活视频| 在线成人av网站| 欧美videos中文字幕| 久久日韩精品一区二区五区| 久久免费电影网| 国产精品福利一区二区| 一区二区三区在线视频免费观看| 亚洲精品日韩综合观看成人91| 亚洲最新视频在线观看| 亚洲v日本v欧美v久久精品| 日韩激情在线观看| 韩国毛片一区二区三区| 国产激情91久久精品导航| 麻豆精品久久久| 国产精品一区二区在线观看网站 | 91亚洲资源网| 欧美网站大全在线观看| 日韩欧美一区二区三区在线| 久久精品欧美日韩精品| 亚洲丝袜另类动漫二区| 午夜成人免费视频| 久久er99热精品一区二区| 岛国精品一区二区| 在线视频国产一区| 欧美变态口味重另类| 国产精品嫩草99a| 亚洲成a人片综合在线| 精品一区二区三区久久| 99久久久免费精品国产一区二区| 欧美三级午夜理伦三级中视频| 欧美电影精品一区二区| 国产精品久久午夜夜伦鲁鲁| 亚洲午夜三级在线| 丁香婷婷综合激情五月色| 欧美在线免费视屏| 欧美—级在线免费片| 五月婷婷综合在线| 粉嫩一区二区三区性色av| 欧美日韩专区在线| 国产精品午夜春色av| 日韩成人午夜电影| 91免费观看国产| 久久精品视频免费| 日本女人一区二区三区| 波多野结衣一区二区三区| 欧美一区二区免费视频|