NetSim Source Code Help
Loading...
Searching...
No Matches
PacketProcessing.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 "DSR.h"
16#include "List.h"
17/**
18This function is called in the Network Out Event for routing of the packet.<br/>
19
20Whenever a packet is to be routed to a destination and the device route cache doesnt have
21a route to the target, the Packet is added to the Send buffer and a Route Discovery is
22iitiated.<br/>
23
24If the Device route cache has a route to the target, then the packet is added to the Maintanence
25Buffer and the count of packets originated is incremented.
26
27*/
29{
30 NETSIM_IPAddress nextHop;
31 NETSIM_ID nInterface;
32 DSR_ROUTE_CACHE* cache=NULL;
36 pstruDevVar,&nextHop,pstruEventDetails->dEventTime,&cache))
37 {
38 //Route found
47 DSR_DEV_VAR(pstruEventDetails->nDeviceId)->dsrMetrics.packetTransmitted++;
49 DSR_DEV_VAR(pstruEventDetails->nDeviceId)->dsrMetrics.packetOrginated++;
50 if(DSR_DEV_VAR(pstruEventDetails->nDeviceId)->AckType == LINK_LAYER_ACK)
52 }
53 else
54 {
55 //Add packet to send buffer
59 {
60 //Initiate Route discovery process
62 &pstruDevVar->pstruRREQTable,
65 pstruEventDetails->pPacket = packet;
69 }
70 else
71 {
72 //RREQ already sent
73 pstruEventDetails->pPacket = NULL;//Don't transmit the packet
74 }
75 }
76 return 1;
77}
unsigned int NETSIM_ID
Definition: Animation.h:45
#define DSR_ADD_TO_MAINT_BUFFER(nDeviceId, pstruPacket, dTime)
Definition: DSR.h:720
#define DSR_INIT_RREQ(target, pprreqTable, nDeviceId, dTime)
Definition: DSR.h:737
#define DSR_CHECK_ROUTE_FOUND(destAddress, devVar, nextHop, dTime, ppcache)
Definition: DSR.h:718
#define DSR_ADD_TO_SEND_BUFFER(ppsendBuffer, packet, dTime)
Definition: DSR.h:742
#define DSR_ADD_SRC_ROUTE(packet, cache)
Definition: DSR.h:747
#define DSR_DEV_VAR(dev)
Definition: DSR.h:772
#define DSR_ADD_ACK_REQUEST(packet)
Definition: DSR.h:750
NETSIM_IPAddress dsr_get_curr_ip()
int fn_NetSim_DSR_LinkLayerAck(NetSim_PACKET *)
NETSIM_IPAddress IP_COPY(NETSIM_IPAddress ip)
void IP_FREE(NETSIM_IPAddress ip)
int fn_NetSim_DSR_GeneralPacketProcessing(NetSim_EVENTDETAILS *pstruEventDetails)
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asIP(NETSIM_IPAddress ip, NETSIM_ID *nInterfaceId)
struct stru_DSR_SendBuffer * pstruSendBuffer
Buffer in which packets are added if route to target is not known.
Definition: DSR.h:658
struct stru_DSR_RouteRequestTable * pstruRREQTable
A table in which entry of RREQ initiated is made.
Definition: DSR.h:659
NETSIM_ID nApplicationId
Definition: Stack.h:752
struct stru_NetSim_Packet * pPacket
Definition: Stack.h:754
NETSIM_ID nDeviceId
Definition: Stack.h:750
long long int nPacketId
Definition: Stack.h:755
NETSIM_IPAddress szGatewayIP
Definition: Packet.h:200
NETSIM_IPAddress szDestIP
Definition: Packet.h:199
NETSIM_IPAddress szNextHopIp
Definition: Packet.h:201
struct stru_NetSim_Packet_NetworkLayer * pstruNetworkData
Definition: Packet.h:275
int(* ReceiveAckNotification)(struct stru_NetSim_Packet *ack)
Definition: Packet.h:282
NETSIM_ID nReceiverId
Definition: Packet.h:266
NETSIM_ID nTransmitterId
Definition: Packet.h:265
NETSIM_ID nSourceId
Definition: Packet.h:263