⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hellomsg.c

📁 ucsb大学开发的aodv路由协议代码。
💻 C
字号:
/* * Copyright (C) 2001, University of California, Santa Barbara *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. *  * 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. *  * Other copyrights might apply to parts of this software and are so * noted when applicable. *//* * Parts of this program has been derived from PIM sparse-mode pimd. * The pimd program is covered by the license in the accompanying file * named "LICENSE.pimd". *   * The pimd program is COPYRIGHT 1998 by University of Southern California. * */#include <arpa/inet.h>#include <netinet/in.h>#include <sys/socket.h>#include "aodvConst.h"#include "aodvPktInfo.h"#include "callout.h"#include "const.h"#include "debug.h"#include "inet.h"#include "rrep.h"#include "sendDatagram.h"int helloMsgSend = TRUE;int helloMsgRecv = TRUE;int broadcastSent = FALSE;static void sendHelloMsg __P(());void startHelloMsg(){  int j;  j=-250+(int) (500.0*random()/(RAND_MAX+1.0));  trace(TRACE_HELLO,"start random delay %i",j);  trace(TRACE_HELLO|TRACE_INIT|TRACE_TIMER	,"startHelloMsg %i",HELLO_INTERVAL+j);  timer_setTimer(HELLO_INTERVAL+j,sendHelloMsg,NULL);}static void sendHelloMsg(){  struct RREP rrep;  struct AodvPktInfo info;  int j;  if (broadcastSent == FALSE){    rrep.src=getip();    rrep.dest=getip();    fill_my_rrep(&rrep);    rrep.lifetime=htonl(ALLOWED_HELLO_LOSS * HELLO_INTERVAL);    fill_pktInfo(&info,BROADCAST);    info.ttl=1;    trace(TRACE_METRIC,"s h RREP");    sendDatagram(&info,&rrep,sizeof(struct RREP));  }  broadcastSent=FALSE;    j=-250+(int) (500.0*random()/(RAND_MAX+1.0));  trace(TRACE_HELLO,"random delay %i",j);  trace(TRACE_HELLO|TRACE_TIMER,"sendHelloMsg %i",HELLO_INTERVAL+j);  timer_setTimer(HELLO_INTERVAL+j,sendHelloMsg,NULL);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -