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

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

?? initializer.cc

?? clustering for ns-2 simulation
?? CC
字號:
/** * Copyright (c) 2006 Michele Mastrogiovanni. * *   Licensed under the Apache License, Version 2.0 (the "License"); *   you may not use this file except in compliance with the License. *   You may obtain a copy of the License at * *       http://www.apache.org/licenses/LICENSE-2.0 * *   Unless required by applicable law or agreed to in writing, software *   distributed under the License is distributed on an "AS IS" BASIS, *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *   See the License for the specific language governing permissions and *   limitations under the License. * */ ////////////////// NS Headers //////////////////#include "BackboneUtility.h"#include "Separator.h"#include "initializer.h"#include "random.h"#include "gridkeeper.h"#include <algorithm>#include <typeinfo>///////////////////////////////////// Parte di dichiarazione comune /////////////////////////////////////int hdr_initializer::offset_;int INITIALIZER_Agent::degree;int INITIALIZER_Agent::stojmenovic;int INITIALIZER_Agent::_DEBUG_;int INITIALIZER_Agent::limit;double INITIALIZER_Agent::max_delay;int INITIALIZER_Agent::max_timeout_hello;double INITIALIZER_Agent::jitter_timeout_hello;double INITIALIZER_Agent::timeout_hello;int INITIALIZER_Agent::max_timeout_first_decision;double INITIALIZER_Agent::jitter_timeout_first_decision;double INITIALIZER_Agent::timeout_first_decision;int INITIALIZER_Agent::max_timeout_last_decision;double INITIALIZER_Agent::jitter_timeout_last_decision;double INITIALIZER_Agent::timeout_last_decision;static class InitializerClass : public TclClass {public:    InitializerClass() : TclClass("Agent/INITIALIZER") {}    TclObject* create(int argc, const char*const* argv) {        return(new INITIALIZER_Agent());    }} class_initializer;static class InitializerHeaderClass : public PacketHeaderClass {public:	InitializerHeaderClass() : PacketHeaderClass("PacketHeader/INITIALIZER",					      sizeof(hdr_initializer)) {		bind_offset(&hdr_initializer::offset_);                   	}} class_initializerhdr;//// Verifica che il timeout sia di tipo HELLO.//boolInitializerTimer::isHelloTimeout(Event * e){    for (TimeoutMap::iterator i = hello_timeouts.begin(); i != hello_timeouts.end(); i++) {        if (i->second.timeout == e) {            i->second.num--;            if (i->second.num <= 0) {                agent->lastTimeout(INITIALIZER_STATUS_HELLO, i->first);            }            else {                Scheduler::instance().schedule(this, e,                     INITIALIZER_Agent::timeout_hello + Random::uniform(INITIALIZER_Agent::jitter_timeout_hello));                agent->timeout(INITIALIZER_STATUS_HELLO, i->first);            }            return true;        }    }    return false;}//// Verifica che il timeout sia di tipo FIRST DECISION.//boolInitializerTimer::isFirstDecisionTimeout(Event * e){    for (TimeoutMap::iterator i = first_decision_timeouts.begin(); i != first_decision_timeouts.end(); i++) {        if (i->second.timeout == e) {            i->second.num--;            if (i->second.num <= 0) {                agent->lastTimeout(INITIALIZER_STATUS_FIRST_DECISION, i->first);            }            else {                Scheduler::instance().schedule(this, e,                     INITIALIZER_Agent::timeout_first_decision + Random::uniform(INITIALIZER_Agent::jitter_timeout_first_decision));                agent->timeout(INITIALIZER_STATUS_FIRST_DECISION, i->first);            }            return true;        }    }        return false;}//// Verifica che il timeout sia di tipo LAST DECISION.//boolInitializerTimer::isLastDecisionTimeout(Event * e){    for (TimeoutMap::iterator i = last_decision_timeouts.begin(); i != last_decision_timeouts.end(); i++) {        if (i->second.timeout == e) {            i->second.num--;            if (i->second.num <= 0) {                agent->lastTimeout(INITIALIZER_STATUS_LAST_DECISION, i->first);            }            else {                Scheduler::instance().schedule(this, e,                     INITIALIZER_Agent::timeout_last_decision + Random::uniform(INITIALIZER_Agent::jitter_timeout_last_decision));                agent->timeout(INITIALIZER_STATUS_LAST_DECISION, i->first);            }            return true;        }    }        return false;}//// Gestisce l'arrivo di un timeout segnalandolo// opportunamente all'Agente.//voidInitializerTimer::handle(Event *e){    if (isHelloTimeout(e))        return;            if (isFirstDecisionTimeout(e))        return;    if (isLastDecisionTimeout(e))        return;}//// Inizializza i timeout che si possono lanciare in base ai vicini del nodo.// voidInitializerTimer::initTimeouts(NodeList & neighbors) {    for (NodeList::iterator i = neighbors.begin(); i != neighbors.end(); i++) {        // Definisce i Timeout di tipo HELLO        struct Timeout h;        h.timeout = new Event();        h.num = INITIALIZER_Agent::max_timeout_hello;        hello_timeouts[*i] = h;        // Definisce i Timeout di tipo FIRST DECISION        struct Timeout f;        f.timeout = new Event();        f.num = INITIALIZER_Agent::max_timeout_first_decision;        first_decision_timeouts[*i] = f;        // Definisce i Timeout di tipo LAST DECISION        struct Timeout s;        s.timeout = new Event();        s.num = INITIALIZER_Agent::max_timeout_last_decision;        last_decision_timeouts[*i] = s;            }}//// Fa partire i timeout per i nodi che non hanno ancora risposto al// messaggio di HELLO inviando la propria lista di vicini.//        voidInitializerTimer::launchHelloTimeouts(){    for (TimeoutMap::iterator i = hello_timeouts.begin(); i != hello_timeouts.end(); i++) {        Scheduler::instance().schedule(this, i->second.timeout,             INITIALIZER_Agent::timeout_hello + Random::uniform(INITIALIZER_Agent::jitter_timeout_hello));    }    }//// Fa partire i timeout per i nodi che non hanno ancora inviato// il proprio colore (iniziale).//        void InitializerTimer::launchFirstDecisionTimeouts(){    for (TimeoutMap::iterator i = first_decision_timeouts.begin(); i != first_decision_timeouts.end(); i++) {        Scheduler::instance().schedule(this, i->second.timeout,             INITIALIZER_Agent::timeout_first_decision + Random::uniform(INITIALIZER_Agent::jitter_timeout_first_decision));    }}//// Fa partire i timeout per i nodi che non hanno ancora inviato// il proprio colore (finale).//        void InitializerTimer::launchLastDecisionTimeouts(){    for (TimeoutMap::iterator i = last_decision_timeouts.begin(); i != last_decision_timeouts.end(); i++) {        Scheduler::instance().schedule(this, i->second.timeout,             INITIALIZER_Agent::timeout_last_decision + Random::uniform(INITIALIZER_Agent::jitter_timeout_last_decision));    }}     //// L'agente segnala la ricezione di un messaggio di tipo HELLO:// il timeout viene eliminato.//void InitializerTimer::receivedHello(NodeAddress from){    TimeoutMap::iterator i;    for (i = hello_timeouts.begin(); i != hello_timeouts.end(); i++) {        if (i->first == from) {            Scheduler::instance().cancel(i->second.timeout);            break;        }    }    if (i != hello_timeouts.end())        hello_timeouts.erase(i);}//// L'agente segnala la ricezione di un messaggio di tipo FIRST DECISION:// il timeout viene eliminato.//void InitializerTimer::receivedFirstDecision(NodeAddress from){    TimeoutMap::iterator i;    for (i = first_decision_timeouts.begin(); i != first_decision_timeouts.end(); i++) {        if (i->first == from) {            Scheduler::instance().cancel(i->second.timeout);            break;        }    }    if (i != first_decision_timeouts.end())        first_decision_timeouts.erase(i);}    //// L'agente segnala la ricezione di un messaggio di tipo LAST DECISION:// il timeout viene eliminato.//void InitializerTimer::receivedLastDecision(NodeAddress from){    TimeoutMap::iterator i;    for (i = last_decision_timeouts.begin(); i != last_decision_timeouts.end(); i++) {        if (i->first == from) {            Scheduler::instance().cancel(i->second.timeout);            break;        }    }    if (i != last_decision_timeouts.end())        last_decision_timeouts.erase(i);}//// Costruttore//INITIALIZER_Agent::INITIALIZER_Agent() : ClusteringModule(PT_INITIALIZER){    timer = new InitializerTimer(this);		bind_bool("debug", &_DEBUG_);	bind_bool("degree", &degree);	bind_bool("stojmenovic", &stojmenovic);	bind("limit", &limit);	bind("max-delay", &max_delay);	bind("max-timeout-hello", &max_timeout_hello);	bind("jitter-timeout-hello", &jitter_timeout_hello);	bind("timeout-hello", &timeout_hello);	bind("max-timeout-first-decision", &max_timeout_first_decision);	bind("jitter-timeout-first-decision", &jitter_timeout_first_decision);	bind("timeout-first-decision", &timeout_first_decision);	bind("max-timeout-last-decision", &max_timeout_last_decision);	bind("jitter-timeout-last-decision", &jitter_timeout_last_decision);	bind("timeout-last-decision", &timeout_last_decision);	}void INITIALIZER_Agent::receive(Packet *p, Handler *h) {    struct hdr_initializer *initializerh = HDR_INITIALIZER(p);        struct hdr_ip *iph = HDR_IP(p);        // Mittente.    NodeAddress sender_address = iph->saddr(); //dcah->my_status.node_ID;    // Destinazione.    NodeAddress destination_address = iph->daddr(); // dcah->destination_address;    switch (initializerh->msg_type) {        case INITIALIZER_NEIGHBORS :            receive_NEIGHBORS(sender_address, *(initializerh->node_list));            break;                    case INITIALIZER_COLOR :            receive_COLOR(sender_address, initializerh->status, initializerh->color);            break;                                case INITIALIZER_REQUEST :            receive_REQUEST(sender_address, initializerh->status);            break;        default:            break;    }	}//// Richiede un messaggio che forse e'stato perduto.//voidINITIALIZER_Agent::send_REQUEST(InitializerStatus _status_, NodeAddress to) {	if (_DEBUG_)		printf("%d send REQUEST\n", myAddress);    Packet* p = allocpkt();	    struct hdr_initializer * initializerh = HDR_INITIALIZER(p);	    initializerh->msg_type = INITIALIZER_REQUEST;    initializerh->status = _status_;	sendDown(p, sizeof(InitializerMessageType) + sizeof(InitializerStatus), to, INITIALIZER_Agent::max_delay);}//// Messaggio usato per cumunicare la propria lista dei vicini ad un nodo vicino//voidINITIALIZER_Agent::send_NEIGHBORS(NodeAddress to) {	if (_DEBUG_)		printf("%d send NEIGHBORS\n", myAddress);    Packet* p = allocpkt();        struct hdr_initializer * initializerh = HDR_INITIALIZER(p);        initializerh->msg_type = INITIALIZER_NEIGHBORS;    initializerh->node_list = & neighbors;	sendDown(p, sizeof(InitializerMessageType) + sizeof(nsaddr_t) * neighbors.size(), to, INITIALIZER_Agent::max_delay);}//// Messaggio usato per comunicare il colore del nodo in una certa fase dell'algoritmo.//voidINITIALIZER_Agent::send_COLOR(InitializerStatus _status_, NodeAddress to, Color color) {	if (_DEBUG_)		printf("%d send COLOR\n", myAddress);		    // Attention: set status of Agent BEFORE send GATEWAY message    Packet* p = allocpkt();	    struct hdr_initializer * initializerh = HDR_INITIALIZER(p);        initializerh->msg_type = INITIALIZER_COLOR;    initializerh->status = _status_;    initializerh->color = color;	sendDown(p, sizeof(InitializerMessageType) + sizeof(InitializerStatus) + sizeof(Color), to, INITIALIZER_Agent::max_delay);}////////////////////// Interrogazioni ////////////////////////// Procedura per verificare se esistono due vicini del nodo // non collegati fra loro.//boolINITIALIZER_Agent::twoNeighborsAreUnlinked(){        NodeList tmp;    // Il nodo A punta ad un vicino.    for (NodeList::iterator A = neighbors.begin(); A != neighbors.end(); A++) {        NodeList & nlA = nodeNeighbors[*A];        // Il nodo B punta all'altro vicino.        for (NodeList::iterator B = A; B != neighbors.end(); B++)            // Se i vicini sono diversi            if (A != B) {                tmp.clear();                tmp.insert(*B);                // Se fra i vicini di A non c'e' B allora i due vicini sono scollegati.                if (!includes(nlA.begin(), nlA.end(), tmp.begin(), tmp.end()))                    return true;            }    }    // Tutti i vicini sono collegati fra loro    return false;}//// Verifica se l'insieme dei vicini passato come parametro// costituisce un insieme connesso.// Viene effettuata una visita in profondit

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品视频观看| 欧美性感一类影片在线播放| xfplay精品久久| 狠狠色综合日日| 国产偷国产偷亚洲高清人白洁| 国产精品综合在线视频| 国产精品国产三级国产aⅴ原创| 91在线视频在线| 午夜视频在线观看一区| 91精品国产综合久久精品性色 | 中文字幕中文乱码欧美一区二区| av在线综合网| aaa欧美色吧激情视频| 成人欧美一区二区三区在线播放| 色综合中文字幕国产 | 国产精品情趣视频| 91日韩在线专区| 婷婷综合五月天| 精品国产乱码久久久久久蜜臀| 国产成人自拍在线| 性做久久久久久久免费看| 91精品国产91热久久久做人人| 国产在线乱码一区二区三区| 中文字幕一区二区在线播放| 欧美日韩一本到| 久久er精品视频| 综合激情成人伊人| 欧美成人一区二区三区在线观看| 成人动漫一区二区| 奇米色777欧美一区二区| 欧美激情一区二区在线| 欧美精品在线观看播放| 不卡视频一二三四| 免费在线观看精品| 国产精品日韩成人| 婷婷激情综合网| 中文字幕欧美三区| 欧美一区二区成人| 一本色道久久综合狠狠躁的推荐 | 夜夜亚洲天天久久| 精品国产一区二区精华| 欧美日韩一区二区欧美激情| 懂色av一区二区三区免费看| 亚洲午夜电影在线观看| 国产精品久久久久久福利一牛影视 | 亚洲乱码国产乱码精品精可以看| 日韩一区二区电影| 色综合 综合色| 国产精品一二三在| 麻豆免费看一区二区三区| 亚洲欧美韩国综合色| 欧美激情一区在线| 26uuu亚洲综合色| 欧美一区中文字幕| 欧美系列在线观看| 一本色道综合亚洲| 成人动漫在线一区| 成人丝袜高跟foot| 国产在线麻豆精品观看| 日本欧美在线看| 在线精品国精品国产尤物884a| 国产黄色成人av| 国产一区视频网站| 久久不见久久见中文字幕免费| 亚洲成人免费看| 亚洲一区二区三区四区中文字幕| 中文字幕视频一区| 亚洲婷婷综合久久一本伊一区| 欧美高清在线精品一区| 久久九九国产精品| 欧美国产视频在线| 一区在线观看视频| 日韩理论在线观看| 樱桃视频在线观看一区| 一区二区三区免费看视频| 亚洲人成亚洲人成在线观看图片| 中文字幕亚洲区| 亚洲精品国产精华液| 艳妇臀荡乳欲伦亚洲一区| 一区二区三区高清| 午夜激情久久久| 免费成人av在线播放| 国产一区二区三区免费看| 国产一区二区三区久久悠悠色av| 国内成人免费视频| 国产.欧美.日韩| 97精品电影院| 欧美撒尿777hd撒尿| 欧美日韩国产区一| 91精品国产乱| 国产片一区二区| 国产一区二区三区久久悠悠色av| 国产乱人伦偷精品视频免下载| 成人免费毛片app| 94-欧美-setu| 欧美三级午夜理伦三级中视频| 51精品秘密在线观看| 日韩三级在线观看| www国产成人免费观看视频 深夜成人网| 欧美精品一区二区不卡| 国产精品天干天干在线综合| 亚洲视频一区在线| 免费黄网站欧美| 国内精品国产成人国产三级粉色 | 久久久久久综合| 中文字幕永久在线不卡| 亚洲午夜日本在线观看| 免费人成在线不卡| 国产真实乱对白精彩久久| 99精品偷自拍| 91精品欧美福利在线观看| 亚洲国产激情av| 日韩中文字幕一区二区三区| 国产资源精品在线观看| 一本久道久久综合中文字幕| 日韩欧美一级在线播放| 国产精品久久久久久久久免费丝袜| 又紧又大又爽精品一区二区| 激情都市一区二区| 色狠狠一区二区| 久久久五月婷婷| 午夜精品福利一区二区三区蜜桃| 高清在线成人网| 91精品久久久久久久99蜜桃| 综合色中文字幕| 国产精品一区二区在线看| 欧美色图12p| 亚洲国产精品成人综合| 7777精品伊人久久久大香线蕉超级流畅 | 国产一区在线精品| 欧美日韩一区二区不卡| 亚洲国产高清在线观看视频| 美女视频黄 久久| 色美美综合视频| 中文字幕av一区二区三区高| 日韩高清欧美激情| 91麻豆成人久久精品二区三区| 日韩欧美国产一区二区在线播放 | 制服丝袜av成人在线看| 国产精品福利影院| 黄网站免费久久| 欧美精品粉嫩高潮一区二区| 亚洲人123区| 波多野结衣一区二区三区| 欧美va日韩va| 免费看日韩a级影片| 欧美精品久久久久久久久老牛影院| 亚洲视频在线一区观看| 成人av小说网| 国产日产欧美精品一区二区三区| 日韩av不卡在线观看| 日韩理论片中文av| 成人福利视频网站| 国产欧美精品在线观看| 国产高清在线精品| 欧美精品一区二| 国内国产精品久久| 精品第一国产综合精品aⅴ| 日韩av不卡在线观看| 555夜色666亚洲国产免| 午夜精品一区二区三区电影天堂 | eeuss影院一区二区三区| 国产欧美视频一区二区三区| 狠狠久久亚洲欧美| 久久奇米777| 国产凹凸在线观看一区二区| 国产视频一区在线播放| 国产成人欧美日韩在线电影| 欧美高清在线精品一区| 不卡欧美aaaaa| 亚洲人成网站影音先锋播放| 色婷婷久久久综合中文字幕| 一区二区三区日韩精品视频| 欧美日韩精品欧美日韩精品| 亚洲r级在线视频| 这里只有精品免费| 久久国产夜色精品鲁鲁99| 久久久国产一区二区三区四区小说| 国产精品亚洲人在线观看| 国产亚洲精品久| 精品欧美久久久| 成人精品免费视频| 亚洲免费观看高清| 欧美日韩国产a| 狠狠狠色丁香婷婷综合久久五月| 欧美激情一区在线观看| 色哟哟在线观看一区二区三区| 亚洲一区二区成人在线观看| 欧美日本乱大交xxxxx| 久久er精品视频| 国产精品蜜臀av| 欧美日韩成人一区| 国产精品456| 伊人婷婷欧美激情| 日韩欧美一级二级三级久久久| 国产精品456| 亚洲一区二区精品视频| 久久影院午夜片一区| 91小视频在线观看| 青青青伊人色综合久久|