博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Watchdog源码
阅读量:6871 次
发布时间:2019-06-26

本文共 1694 字,大约阅读时间需要 5 分钟。

/* Constructor */ WATCHDOG::WATCHDOG(int32_t own_IP) {
port = PORTW; //Port of the GW. devalue = 0; //Devalue old packets. readed_packets = 0; ip_packets = 0; arp_packets = 0; interesting_readed_packets = 0; heartbeat_malicious = HEARTBEAT_MALICIOUS_NODE; immediate_reaction_duration = IMMEDIATE_REATION_DURATION; percentile_of_loss = PERCENTAGE_LOSS; neighbour_timeout = NEIGHBOUR_TIMEOUT; //timeout for neighbours stored. storing_packet_timeout = STORE_PACKET_TIME; storing_route_timeout = STORE_ROUTE_TIME; reduction = WEIGHT_OF_OLD_PACKETS; //Weight of the olds packets when are devaluated. //IniciateNeighbours(&neigs); neigs = new NEIGHBOURS(); ownIP = own_IP; ownMAC=666; debug=0; }
/* New Packet detected! */ void WATCHDOG::newPacket(int32_t source_ip, int32_t destination_ip, int source_mac, int destination_mac, int sourcePort, int destinationPort,  packet_t packet_type, char* tmp_data, double tmp_time) {
if(debug>0) printf("Node IP: %d MAC: %d says:\n",ownIP, ownMAC); readPacket(source_ip, destination_ip, source_mac, destination_mac, sourcePort, destinationPort, packet_type, tmp_data, tmp_time); neigs->SearchForBlackHole(percentile_of_loss, ownIP, heartbeat_malicious, immediate_reaction_duration, tmp_time); /* Clean old information */ neigs->DeleteOldNeighbours(neighbour_timeout, debug, tmp_time); neigs->RemoveOldPackets(storing_packet_timeout, tmp_time); neigs->RemoveOldFlows(storing_route_timeout, tmp_time); /* Apply devaluation technique */ if (devalue){
neigs->CompressPacketsAllNeighbours(reduction); } }

转载于:https://www.cnblogs.com/zhangrui/archive/2012/03/08/2385040.html

你可能感兴趣的文章
HttpClient使用详解
查看>>
增强现实?先不要指望那些眼镜了
查看>>
《iOS 6核心开发手册(第4版)》——1.10节秘诀:使用多触摸交互
查看>>
《云数据管理:挑战与机遇》一第1章
查看>>
《嵌入式C编程实战》——1.5 软件开发工具
查看>>
分析3000份技术面试数据:这几大指标比你毕业于哪所学校更要紧
查看>>
Linux有问必答:如何检查PDF中使用了哪种字体
查看>>
《Lua游戏AI开发指南》一2.1 新建一个沙箱项目
查看>>
对jquery val 获取input 文本框值进行扩展
查看>>
MySQL (select_paren) union_order_or_limit 行为
查看>>
并发不是并行,它更好!
查看>>
nltk 自己训练模型例子
查看>>
间谍卫星的基础?YOLT——利用卷积神经网络对卫星影像进行多尺度目标检测(Part I)...
查看>>
jstl_开发第一个标签
查看>>
程序员哇,你想在下个情人节或者520脱单么?这个秘籍不能错过
查看>>
去不去O,谁说了算?
查看>>
PHP防SQL注入和XSS攻击
查看>>
在SHAREPOINT共享文档库中启用版本控制功能。
查看>>
Http 代理工具 实战 支持网页与QQ代理
查看>>
又见尾递归
查看>>