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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? antnet.cc

?? 基于 NS2 的 AntNet 源代碼
?? CC
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/* * antnet.cc * * 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. * * If you are using this program for any publication, we kindly request that you cite: * "Ant Colony Optimisation Based Routing on NS-2",  * V. Laxmi, Lavina Jain and M. S. Gaur,  * International Conference on Wireless Communication and Sensor Networks (WCSN),  * India, December 2006. *  * 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. * * Author: Lavina Jain * *//////////////////////////////////////////////////// \file antnet.cc/// \brief Implementation file for Agent Antnet////////////////////////////////////////////////#include "antnet.h"#include "address.h" // to fascilitate inlines#include <stdio.h>#include <stdlib.h>#include <math.h> int hdr_ant_pkt::offset_;	///< to access ant packet header  偏移量extern double r;		///< reinforcement factorextern int N;			///< number of neighbors of a nodeextern int NUM_NODES;		///< total number of nodes in the topology////////////////////////////////////////////////////////////////////////////// \brief tcl binding for new packet: Ant///////////////////////////////////////////////////////////////////////////static class AntHeaderClass : public PacketHeaderClass { 	public: 	AntHeaderClass() : PacketHeaderClass("PacketHeader/Ant",sizeof(hdr_ant_pkt)) { 		bind_offset(&hdr_ant_pkt::offset_); 	} } class_rtProtoAnt_hdr;////////////////////////////////////////////////////////////////////////////// \brief tcl binding for new Agent: Antnet///////////////////////////////////////////////////////////////////////////static class AntnetClass : public TclClass {	public:	AntnetClass() : TclClass("Agent/Antnet") {}	TclObject* create(int argc, const char*const* argv) {		assert(argc == 5);		return (new Antnet((nsaddr_t)Address::instance().str2addr(argv[4])));	}} class_rtProtoAntnet; ////////////////////////////////////////////////////////////////////////////// tcl binding for agent parameters/// default values defined in ns-default.tcl/////////////////////////////////////////////////////////////////////////// Antnet::Antnet(nsaddr_t id) : Agent(PT_ANT), ant_timer_(this), dmux_(0) {		bind("num_nodes_", &num_nodes_);	// number of nodes in topology	bind("num_nodes_x_", &num_nodes_x_);	// number of nodes in row (for regular mesh topology)	bind("num_nodes_y_", &num_nodes_y_);	// number of nodes in column (for regular mesh topology)	bind("r_factor_", &r_factor_);		// reinforcement factor    r = r_factor_	bind("timer_ant_", &timer_ant_);	// timer for generation of forward ants		ra_addr_ = id;		// agent address 	ant_seq_num_ = 0;	// initialize sequence number of ant packets to zero}//////////////////////////////////////////////////////////////////// commands that the agent can handle/////////////////////////////////////////////////////////////////int Antnet::command(int argc, const char*const* argv) {	if (argc == 2) {		if(strcasecmp(argv[1], "start") == 0) {	// begin AntNet algorithm			initialize_rtable();	// initialize routing tables			ant_timer_.resched(0.);	// schedule timer to begin ant generation now			return TCL_OK;		}		else if(strcasecmp(argv[1], "stop") == 0) {	// stop AntNet algorithm			ant_timer_.cancel();	// cancel any scheduled timers			return TCL_OK;		}		else if (strcasecmp(argv[1], "print_rtable") == 0) {	// print routing tables to a file			FILE *fp = fopen(file_rtable,"a");	// file name defined in antnet_common.h			fprintf(fp,"\nRouting table at node %d\n",addr());			fclose(fp);			rtable_.print();	// call method to print routing table			return TCL_OK;		} 	}	else if (argc == 3) {		// obtain corresponding dmux to carry packets		if (strcmp(argv[1], "port-dmux") == 0) {			dmux_ = (PortClassifier*)TclObject::lookup(argv[2]);			if (dmux_ == 0) {				fprintf(stderr, "%s: %s lookup of %s failed\n",__FILE__,argv[1],argv[2]);				return TCL_ERROR; 			}			return TCL_OK; 		}		// obtain corresponding tracer		else if (strcmp(argv[1], "log-target") == 0 || strcmp(argv[1], "tracetarget") == 0) {			logtarget_ = (Trace*)TclObject::lookup(argv[2]);			if (logtarget_ == 0)				return TCL_ERROR;			return TCL_OK;		}	}	// add node1 to neighbor list of node2 and vice-versa (we assume duplex link)	else if (argc == 4) {		if(strcmp(argv[1], "add-neighbor") == 0) {			Node *node1 = (Node*)TclObject::lookup(argv[2]);			Node *node2 = (Node*)TclObject::lookup(argv[3]);			add_Neighbor(node1, node2);			return TCL_OK;		}	} 	// Pass the command to the base class	return Agent::command(argc, argv);}//////////////////////////////////////////////////////////////////// Agent recieves ant packets/////////////////////////////////////////////////////////////////void Antnet::recv(Packet *p, Handler *h) {	struct hdr_cmn *ch = HDR_CMN(p);	// common header	struct hdr_ip *ih = HDR_IP(p);		// ip header	struct hdr_ant_pkt *ah = HDR_ANT_PKT(p);// ant header			if((int)ih->saddr() == ra_addr()) {		// If loop, drop the packet		if (ch->num_forwards() > 0) {			drop(p, DROP_RTR_ROUTE_LOOP);		}		// else if reciever is the source		else if (ch->num_forwards() == 0){				}	}	else {		// recieved packet is an Ant packet		if(ch->ptype() == PT_ANT) {			// call method to handle ant packet			recv_ant_pkt(p);		}		// if not Ant packet, drop		else {			drop(p, DROP_RTR_ROUTE_LOOP);		}	}}//////////////////////////////////////////////////////////////////// Method to send a forward ant/// Called when ant timer expires/////////////////////////////////////////////////////////////////void Antnet::send_ant_pkt() {	nsaddr_t next, dest;	Packet* p = allocpkt();			// allocate new packet	struct hdr_cmn* ch = HDR_CMN(p);	// common header	struct hdr_ip* ih = HDR_IP(p);		// ip header	struct hdr_ant_pkt* ah = HDR_ANT_PKT(p);// ant header		ah->pkt_type() = FORWARD_ANT;		// set ant type as FORWARD ant	ah->pkt_src() = addr();			// source address	ah->pkt_len() = ANT_SIZE;		// length of ant header	ah->pkt_seq_num() = ant_seq_num_++;	// sequence number	ah->pkt_start_time() = CURRENT_TIME;	// packet generation time	dest = rtable_.calc_destination(addr());// generate random destination	ah->pkt_dst() = dest;			// set packet destination	ah->pkt_mem_size() = 0;			// initialize size of memory	ah->pkt_memory_[0].node_addr = addr();	// add source node to memory	ah->pkt_memory_[0].trip_time = 0.0;	// add trip time to this node to memory	ah->pkt_mem_size()++;			// increment size of memory			ch->ptype() = PT_ANT;			// set packet type as Ant	ch->direction() = hdr_cmn::DOWN;	// forward ant	ch->size() = IP_HDR_LEN + ah->pkt_len();// packet header size	ch->error() = 0;	ch->addr_type() = NS_AF_INET;	// generate next hop as per AntNet algorithm	next = rtable_.calc_next(addr(), ah->pkt_dst(), addr());	// if next hop same as this node, release packet	if(next == addr()) {		Packet::free(p);		return;	}	ch->next_hop() = next;		// set next hop address in common header		ih->saddr() = addr();		// set source address in ip header	ih->daddr() = next;		// set destination address in ip header	ih->ttl() = 2 * (NUM_NODES);	// set time-to-live	if(DEBUG)		fprintf(stdout,"sending antnet packet from %d to %d next hop %d\n", ah->pkt_src(), ah->pkt_dst(), ih->daddr());		target_->recv(p);	// send forward ant packet}////////////////////////////////////////////////////////////////////// Method to recieve Ant packet at the Agent/// Calls appropriate methods to process forward and backward ants///////////////////////////////////////////////////////////////////void Antnet::recv_ant_pkt(Packet* p) {	struct hdr_ip* ih = HDR_IP(p);		// ip header	struct hdr_cmn* ch = HDR_CMN(p);	// common header	struct hdr_ant_pkt* ah = HDR_ANT_PKT(p);// ant header		assert(ih->sport() == RT_PORT);	assert(ih->dport() == RT_PORT);		if(DEBUG)		printf("In recv_antnet_pkt() %d at node %d %d source %d dest %d\n", ch->direction(), addr(), ih->daddr(), ah->pkt_src(), ah->pkt_dst());		if(ch->direction() == hdr_cmn::DOWN) {	// forward ant		if(addr() == ah->pkt_dst()) {	// destination node			// add this node to memory			memorize(p);			// create backward ant			create_backward_ant_pkt(p);		}		else {		// not destination node			// add this node to memory			memorize(p);			// send forward ant to next hop node as determined by AntNet algorithm			forward_ant_pkt(p);		}	}	else 	if(ch->direction() == hdr_cmn::UP) {	// backward ant		if(addr() == ah->pkt_dst()) {	// destination node, travel complete		    //00000000000000		     update_traffic(p);			// update routing table			update_table(p);			// release packet			Packet::free(p);			return;		}		else {		// not destination node		     //00000000000000000000		    update_traffic(p);			// update routing table			update_table(p);			// send backward ant to next hop node as determined by memory			backward_ant_pkt(p);		}	}}////////////////////////////////////////////////////////////////////// Method to build meory of forward ant///////////////////////////////////////////////////////////////////void Antnet::memorize(Packet* p) {	struct hdr_ant_pkt* tmp = HDR_ANT_PKT(p);	// ant header		double time = CURRENT_TIME - tmp->pkt_start_time();	// trip time to this node		// If node revisited, there is a loop, remove loop and corresponding memory	for(int i=0; i<tmp->pkt_mem_size(); i++) {		if(tmp->pkt_memory_[i].node_addr == addr()) {			double t = time - tmp->pkt_memory_[i].trip_time;			tmp->pkt_mem_size() = i+1;			for(int j=0; j <= i; j++) {				tmp->pkt_memory_[j].trip_time += t;			}			return;		}	}		// add current node to memory	tmp->pkt_memory_[tmp->pkt_mem_size()].node_addr = addr();	tmp->pkt_memory_[tmp->pkt_mem_size()].trip_time = time;	tmp->pkt_mem_size() = tmp->pkt_mem_size()+1;	if(DEBUG) {		fprintf(stdout,"adding %d to memory of pkt %d\n", addr(), tmp->pkt_seq_num());	}}//////////////////////////////////////////////////////////////////////////////////////////// Method to send forward ant packet to next hop node as determined by AntNet algorithm////////////////////////////////////////////////////////////////////////////////////////void Antnet::forward_ant_pkt(Packet* p) {	struct hdr_ip* ih = HDR_IP(p);		// ip header	struct hdr_cmn* ch = HDR_CMN(p);	// common header	struct hdr_ant_pkt* ah = HDR_ANT_PKT(p);// ant header	nsaddr_t parent = ih->saddr();	// parent node	// find next hop node as per AntNet algorithm

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品视频资源站| 国产在线播精品第三| 欧美探花视频资源| 日日摸夜夜添夜夜添精品视频| 在线免费视频一区二区| 五月激情综合婷婷| 日韩欧美国产系列| 国产69精品一区二区亚洲孕妇| 欧美激情在线观看视频免费| 91在线视频免费91| 午夜欧美2019年伦理| 精品欧美乱码久久久久久1区2区 | 亚洲二区在线观看| 91精品国产福利在线观看 | 五月激情综合色| 精品免费国产二区三区 | 日韩毛片视频在线看| 欧美亚洲丝袜传媒另类| 蜜桃视频一区二区三区 | 成人影视亚洲图片在线| 亚洲男人的天堂网| 日韩欧美你懂的| proumb性欧美在线观看| 亚洲国产欧美在线| 久久综合九色综合欧美就去吻| 国产成人精品免费在线| 亚洲一区二区黄色| 日本一区二区免费在线观看视频| 91视频你懂的| 激情欧美一区二区| 一区二区三区高清| 国产视频视频一区| 在线播放91灌醉迷j高跟美女 | 99re8在线精品视频免费播放| 伊人开心综合网| 久久这里只精品最新地址| 一本到不卡精品视频在线观看| 日韩高清一区二区| 亚洲视频在线观看一区| 精品久久久久久久人人人人传媒 | 欧美日本在线播放| 成人aa视频在线观看| 日韩主播视频在线| 国产精品的网站| 精品日韩在线观看| 欧美群妇大交群中文字幕| 成人黄色在线网站| 韩国三级中文字幕hd久久精品| 亚洲精品免费在线| 久久精品一区二区三区四区| 欧美日韩高清影院| 99re8在线精品视频免费播放| 麻豆精品视频在线观看| 亚洲激情自拍偷拍| 日本一区免费视频| 久久先锋影音av鲁色资源网| 欧美日韩免费一区二区三区视频| 成人性视频网站| 久久99精品视频| 调教+趴+乳夹+国产+精品| 亚洲乱码国产乱码精品精的特点| 久久久久久亚洲综合影院红桃| 91精品视频网| 欧美人牲a欧美精品| 日本精品裸体写真集在线观看| 国产麻豆精品久久一二三| 蜜臀久久久99精品久久久久久| 亚洲成在线观看| 亚洲精品一二三四区| 国产精品久久一卡二卡| 国产欧美一区二区三区在线看蜜臀 | 日韩成人免费看| 亚洲国产精品精华液网站| 亚洲男人天堂av网| 亚洲日本在线观看| 亚洲免费av网站| 伊人夜夜躁av伊人久久| 伊人夜夜躁av伊人久久| 亚洲精品国产a| 一个色在线综合| 亚洲精品写真福利| 亚洲最新视频在线观看| 一区二区三区在线看| 亚洲久草在线视频| 一区二区三区中文在线| 一二三区精品视频| 亚洲成人av中文| 丝袜亚洲另类欧美综合| 日本强好片久久久久久aaa| 天天亚洲美女在线视频| 日韩精品乱码av一区二区| 全部av―极品视觉盛宴亚洲| 美女性感视频久久| 国产乱码一区二区三区| 国产成人精品免费网站| 99精品黄色片免费大全| 色狠狠一区二区| 6080午夜不卡| 精品免费视频.| 中文字幕国产一区二区| 亚洲欧美日韩国产另类专区| 亚洲五月六月丁香激情| 日本视频中文字幕一区二区三区 | 国产在线一区二区综合免费视频| 国产高清成人在线| 色综合网站在线| 4438成人网| 欧美国产日韩精品免费观看| 亚洲精品综合在线| 免费在线观看日韩欧美| 国产精品伊人色| 在线亚洲欧美专区二区| 日韩三级在线免费观看| 国产婷婷色一区二区三区在线| 亚洲欧洲精品一区二区精品久久久 | 黑人精品欧美一区二区蜜桃| 成人免费高清在线| 欧美区视频在线观看| 国产亚洲自拍一区| 亚洲精品国产第一综合99久久 | 在线观看av不卡| 日韩欧美三级在线| 成人欧美一区二区三区| 视频一区免费在线观看| 国产成人综合自拍| 欧美日韩精品欧美日韩精品| 久久精品视频一区二区| 一区二区三区美女| 国产精品一色哟哟哟| 欧美日韩精品专区| 国产精品高潮久久久久无| 日韩av午夜在线观看| 97se亚洲国产综合自在线不卡| 欧美精品日日鲁夜夜添| 国产精品久久久久久久久免费樱桃 | 亚洲欧洲av色图| 久久精品久久久精品美女| 91视频你懂的| 国产欧美日韩视频在线观看| 日本视频免费一区| 一本色道久久综合狠狠躁的推荐| 欧美v国产在线一区二区三区| 亚洲精品精品亚洲| 成人手机电影网| 精品国产乱码久久久久久夜甘婷婷| 亚洲久本草在线中文字幕| 国产91丝袜在线18| 亚洲欧美日韩在线不卡| 激情国产一区二区| 91精品欧美一区二区三区综合在| 亚洲欧美日韩国产中文在线| 国产成人8x视频一区二区| 欧美成人a∨高清免费观看| 香蕉乱码成人久久天堂爱免费| 99久久精品免费看| 中文字幕高清不卡| 国产精品1区二区.| 精品国产亚洲一区二区三区在线观看 | 亚洲午夜一区二区三区| 成人国产亚洲欧美成人综合网| 精品对白一区国产伦| 久久精品国产亚洲一区二区三区| 欧美视频在线观看一区二区| 亚洲乱码国产乱码精品精小说 | 色噜噜狠狠色综合欧洲selulu| 国产视频在线观看一区二区三区 | 69p69国产精品| 五月天精品一区二区三区| 欧洲av在线精品| 亚洲一区二区欧美| 欧美日韩精品二区第二页| 亚洲国产精品久久久久秋霞影院 | 亚洲欧洲精品一区二区三区| 成人免费视频国产在线观看| 欧美国产精品专区| 成人深夜在线观看| 亚洲欧美在线aaa| 99久久精品费精品国产一区二区| 中文字幕免费不卡| 91亚洲男人天堂| 亚洲曰韩产成在线| 欧美日韩一二三区| 日本成人在线网站| 精品毛片乱码1区2区3区 | 不卡av在线网| 亚洲精品成人悠悠色影视| 欧美性欧美巨大黑白大战| 亚洲国产日韩精品| 日韩欧美视频一区| 国产美女av一区二区三区| 国产精品萝li| 欧美在线影院一区二区| 日本不卡在线视频| 久久久久久一二三区| 99久免费精品视频在线观看 | 欧美日韩精品一区二区三区 | 久久九九99视频| 色综合久久中文综合久久牛| 亚洲va韩国va欧美va| 日韩欧美激情在线|