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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mac-tdma.c

?? $Header: /cvsroot/nsnam/ns-2/mac/mac-tdma.cc,v 1.16 2006/02/22 13:25:43 mahrenho Exp $ // // mac-t
?? C
?? 第 1 頁 / 共 2 頁
字號:
// -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-

/*
 * mac-tdma.cc
 * Copyright (C) 1999 by the University of Southern California
 * $Id: mac-tdma.cc,v 1.16 2006/02/22 13:25:43 mahrenho 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.
 *
 */

//
// $Header: /cvsroot/nsnam/ns-2/mac/mac-tdma.cc,v 1.16 2006/02/22 13:25:43 mahrenho Exp $
//
// mac-tdma.cc
// by Xuan Chen (xuanc@isi.edu), ISI/USC
//
// Preamble TDMA MAC layer for single hop.
// Centralized slot assignment computing.


#include "delay.h"
#include "connector.h"
#include "packet.h"
#include "random.h"

// #define DEBUG

//#include 

#include "arp.h"
#include "ll.h"
#include "mac.h"
#include "mac-tdma.h"
#include "wireless-phy.h"
#include "cmu-trace.h"

#include 

#define SET_RX_STATE(x)			\
{					\
	rx_state_ = (x);			\
}

#define SET_TX_STATE(x)				\
{						\
	tx_state_ = (x);				\
}

/* Phy specs from 802.11 */
static PHY_MIB PMIB = {
	DSSS_CWMin, DSSS_CWMax, DSSS_SlotTime, DSSS_CCATime,
	DSSS_RxTxTurnaroundTime, DSSS_SIFSTime, DSSS_PreambleLength,
	DSSS_PLCPHeaderLength
};	

/* Timers */
void MacTdmaTimer::start(Packet *p, double time)
{
	Scheduler &s = Scheduler::instance();
	assert(busy_ == 0);
  
	busy_ = 1;
	paused_ = 0;
	stime = s.clock();
	rtime = time;
	assert(rtime >= 0.0);
  
	s.schedule(this, p, rtime);
}

void MacTdmaTimer::stop(Packet *p) 
{
	Scheduler &s = Scheduler::instance();
	assert(busy_);
  
	if(paused_ == 0)
		s.cancel((Event *)p);

	// Should free the packet p.
	Packet::free(p);
  
	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;
}

/* Slot timer for TDMA scheduling. */
void SlotTdmaTimer::handle(Event *e)
{       
	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;
  
	mac->slotHandler(e);
}

/* Receive Timer */
void RxPktTdmaTimer::handle(Event *e) 
{       
	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;
  
	mac->recvHandler(e);
}

/* Send Timer */
void TxPktTdmaTimer::handle(Event *e) 
{       
	busy_ = 0;
	paused_ = 0;
	stime = 0.0;
	rtime = 0.0;
	
	mac->sendHandler(e);
}

/* ======================================================================
   TCL Hooks for the simulator
   ====================================================================== */
static class MacTdmaClass : public TclClass {
public:
	MacTdmaClass() : TclClass("Mac/Tdma") {}
	TclObject* create(int, const char*const*) {
		return (new MacTdma(&PMIB));
	}
} class_mac_tdma;


// Mac Tdma definitions
// Frame format:
// Pamble Slot1 Slot2 Slot3...
MacTdma::MacTdma(PHY_MIB* p) : 
	Mac(), mhSlot_(this), mhTxPkt_(this), mhRxPkt_(this){
	/* Global variables setting. */
	// Setup the phy specs.
	phymib_ = p;
	
	/* Get the parameters of the link (which in bound in mac.cc, 2M by default),
	   the packet length within one TDMA slot (1500 byte by default), 
	   and the max number of nodes (64) in the simulations.*/
	bind("slot_packet_len_", &slot_packet_len_);
	bind("max_node_num_", &max_node_num_);
	
	//  slot_packet_len_ = 1500;
	//  max_node_num_ = 64;
	// Calculate the slot time based on the MAX allowed data length.
	slot_time_ = DATA_Time(slot_packet_len_);
	
	/* Calsulate the max slot num within on frame from max node num.
	   In the simple case now, they are just equal. 
	*/
	max_slot_num_ = max_node_num_;
	
	/* Much simplified centralized scheduling algorithm for single hop
	   topology, like WLAN etc. 
	*/
	// Initualize the tdma schedule and preamble data structure.
	tdma_schedule_ = new int[max_slot_num_];
	tdma_preamble_ = new int[max_slot_num_];

	/* Do each node's initialization. */
	// Record the initial active node number.
	active_node_++;

	if (active_node_ > max_node_num_) {
		printf("Too many nodes taking part in the simulations, aborting...\n");
		exit(-1);
	}
    
	// Initial channel / transceiver states. 
	tx_state_ = rx_state_ = MAC_IDLE;
	tx_active_ = 0;

	// Initialy, the radio is off. NOTE: can't use radioSwitch(OFF) here.
	radio_active_ = 0;

	// Do slot scheduling.
	re_schedule();

	/* Deal with preamble. */
	// Can't send anything in the first frame.
	slot_count_ = FIRST_ROUND;
	tdma_preamble_[slot_num_] = NOTHING_TO_SEND;

	//Start the Slot timer..
	mhSlot_.start((Packet *) (& intr_), 0);  
}

/* similar to 802.11, no cached node lookup. */
int MacTdma::command(int argc, const char*const* argv)
{
	if (argc == 3) {
		if (strcmp(argv[1], "log-target") == 0) {
			logtarget_ = (NsObject*) TclObject::lookup(argv[2]);
			if(logtarget_ == 0)
				return TCL_ERROR;
			return TCL_OK;
		}
	}
	return Mac::command(argc, argv);
}


/* ======================================================================
   Debugging Routines
   ====================================================================== */
void MacTdma::trace_pkt(Packet *p) 
{
	struct hdr_cmn *ch = HDR_CMN(p);
	struct hdr_mac_tdma* dh = HDR_MAC_TDMA(p);
	u_int16_t *t = (u_int16_t*) &dh->dh_fc;

	fprintf(stderr, "\t[ %2x %2x %2x %2x ] %x %s %d\n",
		*t, dh->dh_duration,
		ETHER_ADDR(dh->dh_da), ETHER_ADDR(dh->dh_sa),
		index_, packet_info.name(ch->ptype()), ch->size());
}

void MacTdma::dump(char *fname)
{
	fprintf(stderr, "\n%s --- (INDEX: %d, time: %2.9f)\n", fname, 
		index_, Scheduler::instance().clock());
	
	fprintf(stderr, "\ttx_state_: %x, rx_state_: %x, idle: %d\n", 
		tx_state_, rx_state_, is_idle());
	fprintf(stderr, "\tpktTx_: %lx, pktRx_: %lx, callback: %lx\n", 
		(long) pktTx_, (long) pktRx_, (long) callback_);
}


/* ======================================================================
   Packet Headers Routines
   ====================================================================== */
int MacTdma::hdr_dst(char* hdr, int dst )
{
	struct hdr_mac_tdma *dh = (struct hdr_mac_tdma*) hdr;
	if(dst > -2)
		STORE4BYTE(&dst, (dh->dh_da));
	return ETHER_ADDR(dh->dh_da);
}

int MacTdma::hdr_src(char* hdr, int src )
{
	struct hdr_mac_tdma *dh = (struct hdr_mac_tdma*) hdr;
	if(src > -2)
		STORE4BYTE(&src, (dh->dh_sa));
  
	return ETHER_ADDR(dh->dh_sa);
}

int MacTdma::hdr_type(char* hdr, u_int16_t type) 
{
	struct hdr_mac_tdma *dh = (struct hdr_mac_tdma*) hdr;
	if(type)
		STORE2BYTE(&type,(dh->dh_body));
	return GET2BYTE(dh->dh_body);
}

/* Test if the channel is idle. */
int MacTdma::is_idle() {
	if(rx_state_ != MAC_IDLE)
		return 0;
	if(tx_state_ != MAC_IDLE)
		return 0;
	return 1;
}

/* Do the slot re-scheduling:
   The idea of postphone the slot scheduling for one slot time may be useful.
*/
void MacTdma::re_schedule() {
	static int slot_pointer = 0;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
九九**精品视频免费播放| 国产白丝精品91爽爽久久| 久久综合久久99| 色伊人久久综合中文字幕| 美女视频第一区二区三区免费观看网站| 日本一区二区成人在线| 欧美猛男gaygay网站| 成人国产一区二区三区精品| 日韩制服丝袜先锋影音| 日本一区二区视频在线| 欧美一区二区三区日韩| 色一情一乱一乱一91av| 国产高清视频一区| 热久久免费视频| 亚洲精品欧美在线| 中文字幕巨乱亚洲| 欧美一区二区三区色| 欧美日韩在线亚洲一区蜜芽| 国产成人午夜电影网| 日本不卡的三区四区五区| 亚洲色图.com| 国产精品看片你懂得| 久久麻豆一区二区| 日韩一级片网址| 欧美日韩电影在线| 欧美中文字幕不卡| 色香蕉成人二区免费| 成人免费毛片片v| 国产激情一区二区三区四区| 日韩高清一级片| 天天色综合天天| 亚洲国产视频直播| 亚洲一区二区欧美日韩| 一区二区三区四区在线播放| 久久精品一区二区| 亚洲欧洲成人自拍| 中文字幕乱码一区二区免费| 精品区一区二区| 欧美成人a在线| 精品国产乱码久久久久久1区2区| 在线播放中文一区| 欧美一区二区三区性视频| 欧美精选在线播放| 欧美一区二区视频在线观看2020| 欧美色倩网站大全免费| 欧美日韩国产一级| 91精品欧美福利在线观看| 欧美欧美欧美欧美首页| 欧美精品九九99久久| 欧美高清dvd| 日韩欧美国产一区在线观看| 日韩美女在线视频| 久久久久久久一区| 国产精品国产成人国产三级| 国产精品久久久久久久裸模 | 欧美午夜电影在线播放| 色综合欧美在线| 欧美三级韩国三级日本三斤| 欧美精品三级在线观看| 日韩亚洲欧美成人一区| 精品欧美乱码久久久久久1区2区| 欧美精品一区二区三区蜜桃视频| 久久久久高清精品| 中文字幕一区二区三中文字幕| 亚洲另类春色国产| 五月天婷婷综合| 国产综合一区二区| 成人sese在线| 欧美日韩精品系列| 精品国产sm最大网站免费看| 欧美极品另类videosde| 国产精品一二一区| 成人免费不卡视频| 欧洲精品一区二区| 精品日韩在线一区| 一区二区中文字幕在线| 亚洲妇女屁股眼交7| 国内精品不卡在线| 色综合色狠狠天天综合色| 7777精品伊人久久久大香线蕉| 久久免费视频色| 亚洲激情图片一区| 精品一区二区在线看| 不卡的av网站| 91精品欧美福利在线观看| 国产精品无遮挡| 午夜伦理一区二区| 国产成人免费视频一区| 欧美日韩一区二区三区视频| 久久久综合网站| 亚洲成人综合视频| 成人app下载| 日韩欧美一级二级三级久久久| 中文字幕一区av| 麻豆久久一区二区| 在线观看成人免费视频| 国产午夜精品一区二区三区四区| 亚洲一区二区三区精品在线| 国产成人8x视频一区二区| 精品视频在线视频| 亚洲欧洲日韩女同| 国内久久精品视频| 884aa四虎影成人精品一区| 中文字幕一区二区三区在线播放| 美女视频网站黄色亚洲| 欧美性xxxxxx少妇| 国产精品二三区| 国产老女人精品毛片久久| 7777精品久久久大香线蕉| 亚洲黄色小说网站| 成人久久视频在线观看| 26uuu欧美| 日本欧美一区二区在线观看| 99re热这里只有精品视频| 精品sm在线观看| 免费观看日韩电影| 欧美精品精品一区| 亚洲高清视频的网址| 91社区在线播放| 国产精品二三区| 成人免费电影视频| 国产欧美日韩卡一| 国产激情一区二区三区四区| 精品久久五月天| 美国欧美日韩国产在线播放| 91黄色在线观看| 亚洲精品中文在线影院| av一二三不卡影片| 国产精品久久久久久亚洲伦 | 欧美日韩综合色| 亚洲精品国产a| 一本一道久久a久久精品| 国产精品色哟哟| 国产大陆a不卡| 欧美极品少妇xxxxⅹ高跟鞋| 国产精品一线二线三线精华| 久久综合色8888| 国产一区免费电影| 久久一日本道色综合| 欧美亚洲综合另类| 一区二区三区不卡视频 | 成人av网站大全| 国产精品天干天干在观线| 成人综合在线观看| 成人欧美一区二区三区1314| av在线一区二区| 一区av在线播放| 精品视频免费看| 麻豆精品在线视频| 26uuu国产日韩综合| 国产激情一区二区三区| 国产精品第五页| 欧美在线不卡视频| 日本不卡一区二区三区高清视频| 日韩视频一区二区三区| 国产一区二区三区香蕉| 中文无字幕一区二区三区 | 亚洲va欧美va国产va天堂影院| 欧美日韩在线精品一区二区三区激情| 亚洲国产另类精品专区| 欧美日韩大陆在线| 九九九精品视频| 中文字幕亚洲视频| 欧美日韩国产a| 国产最新精品免费| 亚洲色图欧洲色图| 欧美精品 国产精品| 国产精品自拍三区| 亚洲欧美自拍偷拍色图| 欧美日韩在线不卡| 国产成人综合在线| 亚洲国产精品久久人人爱| 日韩欧美的一区二区| 成人动漫在线一区| 午夜精品一区二区三区免费视频| 日韩精品专区在线影院重磅| 波多野结衣在线aⅴ中文字幕不卡| 亚洲午夜精品久久久久久久久| 精品卡一卡二卡三卡四在线| 91免费版在线| 精品一区二区三区蜜桃| 亚洲另类色综合网站| 日韩精品一区在线观看| 色综合天天综合网国产成人综合天| 午夜电影一区二区三区| 中文字幕不卡一区| 在线综合视频播放| 99国产精品久久久久久久久久久| 日韩福利视频导航| 成人欧美一区二区三区黑人麻豆| 欧美一区二区三区不卡| 99久久国产综合色|国产精品| 蜜臀a∨国产成人精品| 亚洲丝袜另类动漫二区| 亚洲精品在线一区二区| 欧美主播一区二区三区| 成人开心网精品视频| 激情五月婷婷综合网| 亚洲自拍偷拍欧美| 国产精品入口麻豆原神|