NetSim Source Code Help
Loading...
Searching...
No Matches
HelloMessage.c
Go to the documentation of this file.
1
/************************************************************************************
2
* Copyright (C) 2020 *
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
/**
19
This function generate the Hello Message Packets and transmit them.
20
*/
21
int
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
hello->
DestinationIPaddress
=
aodv_get_curr_ip
();
41
hello->
DestinationSequenceNumber
=
AODV_DEV_VAR
(
pstruEventDetails
->
nDeviceId
)->nSequenceNumber;
42
hello->
HopCount
= 0;
43
hello->
LastAddress
=
aodv_get_curr_ip
();
44
hello->
Lifetime
= (
unsigned
int)(
pstruEventDetails
->
dEventTime
+
45
(
double
)
AODV_ALLOWED_HELLO_LOSS
*
AODV_HELLO_INTERVAL
);
46
hello->
OriginatorIPaddress
=
aodv_get_curr_ip
();
47
//Broadcast hello message
48
//Add network out event
49
pevent.
dEventTime
=
pstruEventDetails
->
dEventTime
;
50
pevent.
dPacketSize
=
fnGetPacketSize
(packet);
51
pevent.
nApplicationId
= 0;
52
pevent.
nApplicationId
= 0;
53
pevent.
nEventType
=
NETWORK_OUT_EVENT
;
54
pevent.
nProtocolId
=
fn_NetSim_Stack_GetNWProtocol
(
pstruEventDetails
->
nDeviceId
);
55
pevent.
nSubEventType
= 0;
56
pevent.
pPacket
= packet;
57
pevent.
szOtherDetails
= NULL;
58
fnpAddEvent
(&pevent);
59
packet->
pstruNetworkData
->
szNextHopIp
=NULL;
60
}
61
return
1;
62
}
AODV.h
fn_NetSim_AODV_GenerateCtrlPacket
NetSim_PACKET * fn_NetSim_AODV_GenerateCtrlPacket(NETSIM_ID src, NETSIM_ID dest, NETSIM_ID recv, double dTime, AODV_CONTROL_PACKET type)
AODV_HELLO_INTERVAL
#define AODV_HELLO_INTERVAL
Definition:
AODV.h:31
AODVctrlPacket_RREP
@ AODVctrlPacket_RREP
Definition:
AODV.h:79
aodv_get_curr_ip
NETSIM_IPAddress aodv_get_curr_ip()
AODV_ALLOWED_HELLO_LOSS
#define AODV_ALLOWED_HELLO_LOSS
Definition:
AODV.h:27
AODV_DEV_VAR
#define AODV_DEV_VAR(devId)
Definition:
AODV.h:413
fn_NetSim_AODV_TransmitHelloMessage
int fn_NetSim_AODV_TransmitHelloMessage(NetSim_EVENTDETAILS *pstruEventDetails)
Definition:
HelloMessage.c:21
List.h
calloc
#define calloc(c, s)
Definition:
Memory.h:29
fnGetPacketSize
double fnGetPacketSize(NetSim_PACKET *pstruData)
fn_NetSim_Stack_GetNWProtocol
NETWORK_LAYER_PROTOCOL fn_NetSim_Stack_GetNWProtocol(NETSIM_ID nDeviceId)
NETWORK_OUT_EVENT
@ NETWORK_OUT_EVENT
Definition:
Stack.h:108
pstruEventDetails
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition:
Stack.h:837
main.h
fnpAddEvent
#define fnpAddEvent(pstruEvent)
Definition:
main.h:191
stru_NetSim_AODV_RREP
Definition:
AODV.h:179
stru_NetSim_AODV_RREP::HopCount
unsigned int HopCount
Definition:
AODV.h:195
stru_NetSim_AODV_RREP::OriginatorIPaddress
NETSIM_IPAddress OriginatorIPaddress
The IP address of the node which originated the RREQ for which the route is supplied.
Definition:
AODV.h:203
stru_NetSim_AODV_RREP::DestinationSequenceNumber
unsigned int DestinationSequenceNumber
The destination sequence number associated to the route.
Definition:
AODV.h:202
stru_NetSim_AODV_RREP::Lifetime
unsigned int Lifetime
The time in milliseconds for which nodes receiving the RREP consider the route to be valid.
Definition:
AODV.h:204
stru_NetSim_AODV_RREP::LastAddress
NETSIM_IPAddress LastAddress
Definition:
AODV.h:205
stru_NetSim_AODV_RREP::DestinationIPaddress
NETSIM_IPAddress DestinationIPaddress
Definition:
AODV.h:201
stru_NetSim_EventDetails
Definition:
Stack.h:744
stru_NetSim_EventDetails::nApplicationId
NETSIM_ID nApplicationId
Definition:
Stack.h:752
stru_NetSim_EventDetails::nEventType
EVENT_TYPE nEventType
Definition:
Stack.h:747
stru_NetSim_EventDetails::nProtocolId
NETSIM_ID nProtocolId
Definition:
Stack.h:748
stru_NetSim_EventDetails::pPacket
struct stru_NetSim_Packet * pPacket
Definition:
Stack.h:754
stru_NetSim_EventDetails::nSubEventType
NETSIM_ID nSubEventType
Definition:
Stack.h:757
stru_NetSim_EventDetails::nDeviceId
NETSIM_ID nDeviceId
Definition:
Stack.h:750
stru_NetSim_EventDetails::szOtherDetails
void * szOtherDetails
Definition:
Stack.h:758
stru_NetSim_EventDetails::dEventTime
double dEventTime
Definition:
Stack.h:746
stru_NetSim_EventDetails::dPacketSize
double dPacketSize
Definition:
Stack.h:753
stru_NetSim_Packet_NetworkLayer::nTTL
unsigned int nTTL
Definition:
Packet.h:202
stru_NetSim_Packet_NetworkLayer::Packet_RoutingProtocol
void * Packet_RoutingProtocol
Definition:
Packet.h:207
stru_NetSim_Packet_NetworkLayer::szNextHopIp
NETSIM_IPAddress szNextHopIp
Definition:
Packet.h:201
stru_NetSim_Packet
Definition:
Packet.h:255
stru_NetSim_Packet::pstruNetworkData
struct stru_NetSim_Packet_NetworkLayer * pstruNetworkData
Definition:
Packet.h:275
ALL
Component 4
AODV
HelloMessage.c
Generated on Fri Dec 9 2022 10:22:46 for NetSim Source Code Help by
1.9.5