NetSim Source Code Help
Loading...
Searching...
No Matches
AODV.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#include "main.h"
15#include "AODV.h"
16#include "List.h"
17
27
28
29
30
31
32/**
33AODV Init function initializes the AODV parameters.
34*/
36{
37 return fn_NetSim_AODV_Init_F();
38}
39/**
40~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41This is the AODV Run function which gets called by the IP layer for routing the data
42by the DSR Network Routing Protocol. It includes the events NETWORK_OUT_EVENT,
43NETWORK_IN_EVENT and TIMER_EVENT.
44
45NETWORK_OUT_EVENT -
46It process the Data Packets which arrive at the NetworkOut layer to route the packet.
47NETWORK_IN_EVENT -
48It processes Data Packets, Route Request Packets, Route Reply Packets, Route Error
49Packets, Ack Packet
50TIMER_EVENT -
51It Process the AODV Route Request timeout and the AODV Maintenance Buffer timeout.
52~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53*/
55{
59 return -1;
60
62 {
64 {
67 {
68 NETSIM_IPAddress n1,n2;
71 if(ip->type != dest->type)
72 return 0;
76 n2=IP_NETWORK_ADDRESS(dest,
79
80 if(!IP_COMPARE(n1,n2))
82 else
83 return 0; //Other network packet
84 }
85 else
86 {
87 //No processing required
89 }
91 {
93 {
97 }
98 else
99 {
103 }
104 }
105 else
107 }
108 break;
109 case NETWORK_IN_EVENT:
111 {
115 break;
119 break;
123 break;
124 default:
125 {
128 {
129 //Update the life time
132 }
133 else
134 {
135 packet->pstruNetworkData->szNextHopIp = NULL;
136 packet->DropNotification = NULL;
137 //Update the life time of dest
140 //Update the life time of source
143 }
144 }
145 break;
146 }
147 break;
148 case TIMER_EVENT:
150 {
153 break;
156 break;
159 break;
160 default:
161 fnNetSimError("Unknown subevent for AODV");
162 break;
163 }
164 break;
165 default:
166 fnNetSimError("Unknown event type for AODV");
167 break;
168 }
169 return 1;
170}
171/**
172This function is called by NetworkStack.dll, while writing the evnt trace
173to get the sub event as a string.
174*/
176{
177 return fn_NetSim_AODV_Trace_F(id);
178}
179/**
180This function is called by NetworkStack.dll, to free the AODV protocol parameters.
181*/
183{
184 return fn_NetSim_AODV_FreePacket_F(packet);
185}
186/**
187This function is called by NetworkStack.dll, to copy the AODV protocol parameters
188from source packet to destination.
189*/
190_declspec(dllexport) int fn_NetSim_AODV_CopyPacket(const NetSim_PACKET* destPacket,const NetSim_PACKET* srcPacket)
191{
192 return fn_NetSim_AODV_CopyPacket_F(destPacket,srcPacket);
193}
194/**
195This function call WLAN Metrics function in lib file to write the Metrics in Metrics.txt
196*/
198{
199 return fn_NetSim_AODV_Metrics_F(metricsWriter);
200}
201/**
202This function is called by NetworkStack.dll, while configuring the device
203NETWORK layer for AODV protocol.
204*/
205_declspec(dllexport) int fn_NetSim_AODV_Configure(void** var)
206{
207 return fn_NetSim_AODV_Configure_F(var);
208}
209/**
210This function will return the string to write packet trace heading.
211*/
213{
215}
216/**
217This function is called by NetworkStack.dll, once simulation end to free the
218allocated memory for the network.
219*/
221{
223}
224/**
225This function will return the string to write packet trace.
226*/
228{
230}
int fn_NetSim_AODV_CopyPacket_F()
int fn_NetSim_AODV_Finish_F()
int fn_NetSim_AODV_CopyPacket(const NetSim_PACKET *destPacket, const NetSim_PACKET *srcPacket)
Definition: AODV.c:190
int fn_NetSim_AODV_Run()
Definition: AODV.c:54
int fn_NetSim_AODV_Init_F()
int fn_NetSim_AODV_Init()
Definition: AODV.c:35
char * fn_NetSim_AODV_WritePacketTrace_F()
int fn_NetSim_AODV_Metrics_F(PMETRICSWRITER metricsWriter)
int fn_NetSim_AODV_Configure(void **var)
Definition: AODV.c:205
int fn_NetSim_AODV_Configure_F()
char * fn_NetSim_AODV_WritePacketTrace()
Definition: AODV.c:227
int fn_NetSim_AODV_Finish()
Definition: AODV.c:220
int fn_NetSim_AODV_Metrics(PMETRICSWRITER metricsWriter)
Definition: AODV.c:197
int fn_NetSim_AODV_FreePacket_F()
char * fn_NetSim_AODV_Trace_F(NETSIM_ID)
char * fn_NetSim_AODV_ConfigPacketTrace_F()
char * fn_NetSim_AODV_Trace(NETSIM_ID id)
Definition: AODV.c:175
char * fn_NetSim_AODV_ConfigPacketTrace()
Definition: AODV.c:212
int fn_NetSim_AODV_FreePacket(NetSim_PACKET *packet)
Definition: AODV.c:182
#define AODV_ACTIVE_ROUTE_TIMEOUT
Definition: AODV.h:26
NETSIM_ID aodv_get_curr_if()
#define AODV_PACKET_PROCESSING()
Definition: AODV.h:391
void set_aodv_curr()
@ AODVctrlPacket_RERR
Definition: AODV.h:80
@ AODVctrlPacket_RREP
Definition: AODV.h:79
@ AODVctrlPacket_RREQ
Definition: AODV.h:78
@ AODVsubevent_RREQ_TIMEOUT
Definition: AODV.h:85
@ AODVsubevent_TRANSMIT_HELLO
Definition: AODV.h:86
@ AODVsubevent_ACTIVE_ROUTE_TIMEOUT
Definition: AODV.h:87
#define AODV_TRANSMIT_HELLO()
Definition: AODV.h:406
#define AODV_PROCESS_RREQ()
Definition: AODV.h:396
#define AODV_RETRY_RREQ()
Definition: AODV.h:395
#define AODV_UPDATE_ROUTE_TABLE(ip, lifetime)
Definition: AODV.h:407
bool isAodvConfigured(NETSIM_ID d, NETSIM_ID in)
NETSIM_IPAddress aodv_get_curr_ip()
#define AODV_PROCESS_RREP()
Definition: AODV.h:402
NETSIM_IPAddress aodv_get_dev_ip(NETSIM_ID d)
#define AODV_PROCESS_RERR()
Definition: AODV.h:410
#define AODV_DEV_VAR(devId)
Definition: AODV.h:413
#define AODV_ACTIVE_ROUTE_TIMEOUT_EVENT()
Definition: AODV.h:408
unsigned int NETSIM_ID
Definition: Animation.h:45
NETSIM_IPAddress IP_NETWORK_ADDRESS(NETSIM_IPAddress ip, NETSIM_IPAddress subnet, unsigned int prefix_len)
#define IP_COMPARE(ip1, ip2)
Definition: IP_Addressing.h:67
#define _declspec(dllexport)
This function is used to trigger the update.
Definition: Linux.h:41
#define fnNetSimError(x,...)
Definition: Linux.h:56
void * PMETRICSWRITER
Definition: MetricsWriter.h:27
@ PacketType_Control
Definition: Packet.h:66
bool isDestFoundinPacket(NetSim_PACKET *packet, NETSIM_ID dest)
@ NW_PROTOCOL_AODV
Definition: Stack.h:197
@ NETWORK_OUT_EVENT
Definition: Stack.h:108
@ TIMER_EVENT
Definition: Stack.h:114
@ NETWORK_IN_EVENT
Definition: Stack.h:109
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define DEVICE_INTERFACE(DeviceId, InterfaceId)
Definition: Stack.h:780
#define fn_NetSim_Packet_FreePacket(pstruPacket)
Definition: main.h:177
EVENT_TYPE nEventType
Definition: Stack.h:747
struct stru_NetSim_Packet * pPacket
Definition: Stack.h:754
NETSIM_ID nSubEventType
Definition: Stack.h:757
NETSIM_ID nDeviceId
Definition: Stack.h:750
NETSIM_ID nInterfaceId
Definition: Stack.h:751
NETSIM_IPAddress szDestIP
Definition: Packet.h:199
NETSIM_IPAddress szNextHopIp
Definition: Packet.h:201
NETSIM_IPAddress szSourceIP
Definition: Packet.h:198
struct stru_NetSim_Packet_NetworkLayer * pstruNetworkData
Definition: Packet.h:275
NETSIM_ID nReceiverId
Definition: Packet.h:266
unsigned int nControlDataType
Definition: Packet.h:258
PACKET_TYPE nPacketType
Definition: Packet.h:257
int(* DropNotification)(struct stru_NetSim_Packet *packet)
Definition: Packet.h:281