NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
HelloMessage.c
1/************************************************************************************
2* Copyright (C) 2023 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14
15#include "main.h"
16#include "AODV.h"
17#include "List.h"
18/**
19This function generate the Hello Message Packets and transmit them.
20*/
21int fn_NetSim_AODV_TransmitHelloMessage(NetSim_EVENTDETAILS* pstruEventDetails)
22{
23 NetSim_EVENTDETAILS pevent;
24 //Add an event to transmit next hello packet
25 memcpy(&pevent,pstruEventDetails,sizeof pevent);
26 pevent.dEventTime += AODV_HELLO_INTERVAL;
27 fnpAddEvent(&pevent);
28 if(AODV_DEV_VAR(pstruEventDetails->nDeviceId)->dLastBroadcastTime+AODV_HELLO_INTERVAL > pstruEventDetails->dEventTime)
29 return 0; //Already broadcast packet sent
30 if(AODV_DEV_VAR(pstruEventDetails->nDeviceId)->routeTable)
31 {
32 NetSim_PACKET* packet = fn_NetSim_AODV_GenerateCtrlPacket(pstruEventDetails->nDeviceId,
33 0,
34 0,
35 pstruEventDetails->dEventTime,
36 AODVctrlPacket_RREP);
37 AODV_RREP* hello = calloc(1,sizeof* hello);
38 packet->pstruNetworkData->Packet_RoutingProtocol = hello;
39 packet->pstruNetworkData->nTTL = 2;
40 strcpy(packet->szPacketType,"AODV_RREP(HELLO)");
41 hello->DestinationIPaddress = aodv_get_curr_ip();
42 hello->DestinationSequenceNumber = AODV_DEV_VAR(pstruEventDetails->nDeviceId)->nSequenceNumber;
43 hello->HopCount = 0;
44 hello->LastAddress = aodv_get_curr_ip();
45 hello->Lifetime = (unsigned int)(pstruEventDetails->dEventTime +
46 (double)AODV_ALLOWED_HELLO_LOSS*AODV_HELLO_INTERVAL);
47 hello->OriginatorIPaddress = aodv_get_curr_ip();
48 //Broadcast hello message
49 //Add network out event
50 pevent.dEventTime = pstruEventDetails->dEventTime;
51 pevent.dPacketSize = fnGetPacketSize(packet);
52 pevent.nApplicationId = 0;
53 pevent.nApplicationId = 0;
54 pevent.nEventType = NETWORK_OUT_EVENT;
55 pevent.nProtocolId = fn_NetSim_Stack_GetNWProtocol(pstruEventDetails->nDeviceId);
56 pevent.nSubEventType = 0;
57 pevent.pPacket = packet;
58 pevent.szOtherDetails = NULL;
59 fnpAddEvent(&pevent);
60 packet->pstruNetworkData->szNextHopIp=NULL;
61 }
62 return 1;
63}
unsigned int HopCount
Definition AODV.h:196
NETSIM_IPAddress OriginatorIPaddress
The IP address of the node which originated the RREQ for which the route is supplied.
Definition AODV.h:204
unsigned int DestinationSequenceNumber
The destination sequence number associated to the route.
Definition AODV.h:203
unsigned int Lifetime
The time in milliseconds for which nodes receiving the RREP consider the route to be valid.
Definition AODV.h:205