GF - #include #include #include #include #include #include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> #include <math.h> #include "api.h" #include "structmsg.h" #include "fileio.h" #include "message.h" #include "network.h" #include "GF.h" #include "ip.h" #include "udp.h" #include "nwip.h" #include "nwcommon.h" #include "application.h" #include "transport.h" #include "java_gui.h" # #define ABSOLUTE_VALUE(x) (x)>=0 ? (x):(0-(x)) #define GF_DELAYBEFOREBEACON (20*SECOND) #define MAX_BEACON_LIMIT 3 GF_LOCATION_SERVICE_TABLE GF_global_ls_table; G //*************************************************************************** //*************************************************************************** //*************************************************************************** void RoutingGFInit(GlomoNode *node, GlomoRoutingGF **GFPtr, const GlomoNodeInput *nodeInput){ GlomoNetworkIp *ipLayer = (GlomoNetworkIp *)node->networkData.networkVar; char buf[GLOMO_MAX_STRING_LENGTH]; char beaconIntervalStr[GLOMO_MAX_STRING_LENGTH]; BOOL retVal; clocktype beacon_interval; GlomoRoutingGF *GF = checked_pc_malloc(sizeof(GlomoRoutingGF)); NetworkIpSetRouterFunction(node, &RoutingGFRouterFunction); //schedule beacon retVal = GLOMO_ReadString(node->nodeAddr, nodeInput, "GF_BEACON_INTERVAL", buf); if(retVal == FALSE){ fprintf(stderr, "No GF_BEACON_INTERVAL in GF.in\n"); assert(FALSE); abort(); } beacon_interval = GLOMO_ConvertToClock(buf); GLOMO_PrintClockInSecond(beacon_interval, beaconIntervalStr); GF->numBeacons = 0; GF->beacon_interval = beacon_interval; *GFPtr = GF; if(node->nodeAddr == 0) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
GF_LocServ_Init(); } GF_LocServ_AddEntry(node); GF_InitStats(node); GF_InitNT(&GF->nt); GF_Enable_ScheduleABeacon(node); } //*************************************************************************** //*************************************************************************** //*************************************************************************** // delay the time to start the first beacon schedule void GF_Enable_ScheduleABeacon(GlomoNode *node){ Message *enableScheduleABeaconTimer; clocktype delay; //enableScheduleABeaconTimer is used to start the first beacon schedule enableScheduleABeaconTimer = GLOMO_MsgAlloc(node,GLOMO_NETWORK_LAYER, ROUTING_PROTOCOL_GF, MSG_NETWORK_EVENT_GFEnableScheduleABeacon); delay= GF_DELAYBEFOREBEACON; GLOMO_MsgSend(node, enableScheduleABeaconTimer, delay); } //*************************************************************************** //*************************************************************************** //*************************************************************************** void GF_InitStats(GlomoNode * node){ GlomoNetworkIp * ipLayer = (GlomoNetworkIp *)node->networkData.networkVar; GlomoRoutingGF * GF = (GlomoRoutingGF *)ipLayer->routingProtocol; GF->stats.numOfBeaconPkts = 0; } //*************************************************************************** //*************************************************************************** //***************************************************************************
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

GF - #include #include #include #include #include #include...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online