Watchdog源码

/*
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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值