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

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

?? 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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
宅男在线国产精品| 99国产精品久久久| 日韩三级在线免费观看| 免费高清不卡av| 久久美女高清视频 | 亚洲一二三四区不卡| 欧美在线免费视屏| 日韩激情av在线| 精品捆绑美女sm三区| 岛国精品在线播放| 亚洲免费观看高清完整版在线观看 | 91在线观看免费视频| 亚洲精品日产精品乱码不卡| 欧美日韩久久一区| 狠狠色丁香婷婷综合| 国产精品丝袜久久久久久app| 91麻豆高清视频| 天天av天天翘天天综合网| 日韩欧美色电影| 成人免费毛片高清视频| 亚洲国产一区二区三区青草影视| 日韩亚洲欧美一区| 白白色亚洲国产精品| 亚洲成人在线免费| 国产欧美精品一区二区色综合| 91在线观看下载| 美洲天堂一区二卡三卡四卡视频| 国产亚洲精品中文字幕| 欧美性xxxxxx少妇| 国产一区二区三区香蕉 | 精品免费国产一区二区三区四区| 粉嫩在线一区二区三区视频| 亚洲图片有声小说| 久久久91精品国产一区二区精品| 91搞黄在线观看| 韩国一区二区三区| 亚洲午夜电影在线观看| 久久九九国产精品| 欧美人牲a欧美精品| 成人免费视频国产在线观看| 香蕉久久夜色精品国产使用方法| 亚洲国产精品黑人久久久| 欧美另类一区二区三区| 99视频有精品| 激情六月婷婷久久| 天堂在线亚洲视频| 一区二区三区在线观看动漫| 久久美女艺术照精彩视频福利播放| 欧美性大战久久久| 成人福利电影精品一区二区在线观看| 天堂久久久久va久久久久| 中文字幕一区二区三区色视频| 日韩欧美中文一区| 欧美日韩一区二区三区高清| av在线这里只有精品| 精品一区二区国语对白| 日韩影院在线观看| 亚洲线精品一区二区三区八戒| 国产精品毛片大码女人| 国产性做久久久久久| 精品蜜桃在线看| 欧美一区二区三区四区在线观看 | 欧美亚洲国产一卡| av一本久道久久综合久久鬼色| 国产一区二区精品久久| 久久激情五月婷婷| 日韩高清一区在线| 视频在线观看91| 香港成人在线视频| 五月天亚洲婷婷| 午夜精品视频在线观看| 亚洲一区二区精品视频| 亚洲国产成人av好男人在线观看| 亚洲精品欧美激情| 亚洲综合色成人| 亚洲bt欧美bt精品| 视频在线在亚洲| 老汉av免费一区二区三区| 青青青伊人色综合久久| 蜜桃久久av一区| 国产在线乱码一区二区三区| 国产一区二区三区在线观看免费视频 | 色综合久久天天| 一本久道久久综合中文字幕| 91香蕉视频在线| 欧美亚洲愉拍一区二区| 欧美视频在线不卡| 日韩免费高清av| 久久先锋影音av鲁色资源| 久久久久久97三级| 国产精品成人一区二区艾草| 亚洲色图欧美在线| 三级欧美韩日大片在线看| 欧美a级理论片| 国产69精品久久777的优势| 99精品视频免费在线观看| av毛片久久久久**hd| 欧美视频一二三区| 日韩精品中文字幕在线不卡尤物| 精品不卡在线视频| 亚洲国产成人自拍| 一区二区三区精品在线观看| 日日夜夜精品免费视频| 国产制服丝袜一区| 一本大道综合伊人精品热热| 欧美日韩国产一区| 久久综合色综合88| 亚洲精品伦理在线| 精品亚洲porn| 色综合中文字幕国产 | 国产成人免费在线视频| 91啪九色porn原创视频在线观看| 欧美性色综合网| 2024国产精品| 亚洲男人天堂av网| 开心九九激情九九欧美日韩精美视频电影 | 精品国产乱码久久久久久牛牛| 国产精品污www在线观看| 亚洲国产视频在线| 国产成人午夜精品5599| 欧美美女直播网站| 久久精品视频在线看| 亚洲成人av中文| 成人综合婷婷国产精品久久免费| 欧美吻胸吃奶大尺度电影| 久久久777精品电影网影网 | 午夜电影一区二区三区| 国产一区二三区| 欧美日韩黄色影视| 中文幕一区二区三区久久蜜桃| 天天色综合天天| 91免费在线视频观看| 久久一区二区视频| 日韩精品午夜视频| 日本丶国产丶欧美色综合| 久久久久久久免费视频了| 亚洲成人免费电影| 99精品热视频| 国产片一区二区三区| 久久91精品国产91久久小草| 欧洲一区二区三区在线| 国产精品久久久久毛片软件| 国产在线播放一区二区三区 | 日韩午夜在线观看视频| 亚洲精品中文字幕乱码三区| 丁香激情综合五月| 2024国产精品| 久久电影国产免费久久电影| 欧美色图天堂网| 亚洲欧美另类图片小说| 成人午夜电影网站| 久久久久99精品一区| 精品一区二区免费看| 日韩欧美一级二级| 美女性感视频久久| 日韩一区二区三区在线| 亚洲成人自拍偷拍| 欧美日韩在线电影| 亚洲妇熟xx妇色黄| 欧美日韩一区二区三区四区| 洋洋成人永久网站入口| 色老综合老女人久久久| 亚洲视频一区在线观看| 91在线高清观看| 国产精品国产三级国产aⅴ中文| 成人少妇影院yyyy| 国产精品美女久久久久久久| proumb性欧美在线观看| 国产精品国产三级国产| 99这里只有久久精品视频| 亚洲天堂网中文字| 97久久精品人人做人人爽50路| 日韩久久一区二区| 欧美午夜不卡在线观看免费| 亚洲成人激情自拍| 欧美一区二区精品在线| 精品写真视频在线观看| 久久综合给合久久狠狠狠97色69| 国产精品77777| 中文字幕免费不卡在线| 亚洲精品一线二线三线无人区| 国产一区二区日韩精品| 国产精品视频观看| 一本色道久久综合亚洲91| 亚洲午夜久久久久久久久电影网 | 欧美aa在线视频| 精品1区2区在线观看| 国产不卡高清在线观看视频| 国产精品福利一区| 欧洲色大大久久| 毛片av中文字幕一区二区| 亚洲国产精品黑人久久久| 色吊一区二区三区| 日本vs亚洲vs韩国一区三区二区| 精品日韩欧美一区二区| 成人黄色在线视频| 亚洲综合色丁香婷婷六月图片| 日韩午夜在线影院| 99热99精品| 日本免费新一区视频|