NetSim Source Code Help
Loading...
Searching...
No Matches
IP.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2022 *
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* This source code is licensed per the NetSim license agreement. *
12* *
13* No portion of this source code may be used as the basis for a derivative work, *
14* or used, for any purpose other than its intended use per the NetSim license *
15* agreement. *
16* *
17* This source code and the algorithms contained within it are confidential trade *
18* secrets of TETCOS and may not be used as the basis for any other software, *
19* hardware, product or service. *
20* *
21* Author: Shashi Kant Suman *
22* *
23* ----------------------------------------------------------------------------------*/
24#include "main.h"
25#include "List.h"
26#include "IP.h"
27#include "Protocol.h"
28#include "NetSim_utility.h"
29#include "../Firewall/Firewall.h"
30#include "Animation.h"
31#include "../SupportFunction/Scheduling.h"
32
33_declspec(dllexport) int fn_NetSim_IP_VPN_Init();
35int freeVPN(void* vpn);
36int freeDNS(void* dns);
37int freeVPNPacket(void* vpnPacket);
38void* copyVPNPacket(void* vpnPacket);
41void configure_static_ip_route(NETSIM_ID d, char* file);
42static void init_ip_anim();
43
44
45//ICMP function
54
56
58{
61
62 if (isBroadcastIP(dest))
63 {
64 if (isHost(dev))
65 return ACTION_MOVEUP;
66 else
67 return ACTION_DROP;
68 }
69
70 if (isMulticastIP(dest))
71 {
72 return check_ip_in_multicastgroup(dest, dev, packet);
73 }
74 switch (packet->pstruNetworkData->IPProtocol)
75 {
76 case IPPROTOCOL_PIM:
77 return pim_decide_action(packet, dev);
78 break;
79 }
80
81 if (isDestFoundinPacket(packet, dev))
82 return ACTION_MOVEUP;
83 else
84 return ACTION_REROUTE;
85}
86
87/**
88This function initializes the IP parameters.
89*/
90_declspec(dllexport) int fn_NetSim_IP_Init(struct stru_NetSim_Network *NETWORK_Formal,
94 int nVersion_Type,
95 void **fnPointer)
96{
97 NETSIM_ID loop;
98 if (nVersion_Type / 10 != VERSION)
99 {
100 printf("IP---Version number mismatch\nDll Version=%d\nNetSim Version=%d\nFileName=%s\nLine=%d\n", VERSION, nVersion_Type / 10, __FILE__, __LINE__);
101 exit(0);
102 }
104 init_ip_anim();
107 for (loop = 0; loop < NETWORK->nDeviceCount; loop++)
108 {
109 if (!DEVICE_NWLAYER(loop + 1))
110 continue;
111
112 NETSIM_ID nInterface;
113 unsigned int i;
114
115 set_public_ip(loop + 1);
116
118
120
121 if (devVar->staticIPTableFile && *devVar->staticIPTableFile)
123
124 if (devVar->nGatewayCount)
125 devVar->nGatewayId = calloc(devVar->nGatewayCount, sizeof* devVar->nGatewayId);
126 for (i = 0; i < devVar->nGatewayCount; i++)
127 devVar->nGatewayId[i] = fn_NetSim_Stack_GetDeviceId_asIP(devVar->GatewayIPAddress[i], &nInterface);
128 if (devVar && devVar->isFirewallConfigured)
129 {
130 //read the firewall info
131 fn_NetSim_FirewallConfig(loop + 1);
132 }
133 ipMetrics[loop] = calloc(1, sizeof* ipMetrics[loop]);
135
136 //Init the IGMP
137 if (devVar->isIGMPConfigured)
138 igmp_init(loop + 1);
139
140 //Init the PIM
141 if (devVar->isPIMConfigured)
142 Router_PIM_Init(loop + 1);
143 }
144
145 //Initialize the ICMP
147
148 //Initialize the VPN
150
151 return 1;
152}
153
155{
158
159 if (!packet)
160 return NULL;
161 if (!packet->pstruNetworkData->szNextHopIp)
162 return NULL;
163
164 ptrIP_FORWARD_ROUTE route = calloc(1, sizeof* route);
165 route->count = 1;
166
167 route->nextHop = calloc(1, sizeof* route->nextHop);
168 route->nextHop[0] = packet->pstruNetworkData->szNextHopIp;
169
170 route->gateway = calloc(1, sizeof* route->gateway);
171 route->gateway[0] = DEVICE_NWADDRESS(d, in);
172
173 route->interfaceId = calloc(1, sizeof* route->interfaceId);
174 route->interfaceId[0] = in;
175
176 route->nextHopId = calloc(1, sizeof* route->nextHopId);
177 route->nextHopId[0] = fn_NetSim_Stack_GetDeviceId_asIP(route->nextHop[0], &in);
178
179 return route;
180}
181
183{
186 NetSim_EVENTDETAILS pevent;
187
188 if (DEVICE_INTERFACE(d, in)->nLocalNetworkProtocol)
189 {
190 memcpy(&pevent, pstruEventDetails, sizeof pevent);
192 pstruEventDetails->nProtocolId = DEVICE_INTERFACE(d, in)->nLocalNetworkProtocol;
195 //Call the local network protocol
196 fnCallProtocol(DEVICE_INTERFACE(d, in)->nLocalNetworkProtocol);
197 memcpy(pstruEventDetails, &pevent, sizeof * pstruEventDetails);
198 }
199 else
200 {
201 NetSim_BUFFER* buffer = DEVICE_INTERFACE(d, in)->pstruAccessInterface->pstruAccessBuffer;
203
204 if (!fn_NetSim_GetBufferStatus(buffer))
205 {
206 memcpy(&pevent, pstruEventDetails, sizeof pevent);
207
208 //Add the MAC out event
209 pevent.nEventType = MAC_OUT_EVENT;
211 pevent.pPacket = NULL;
212 pevent.nSubEventType = 0;
213 fnpAddEvent(&pevent);
214 }
215 fn_NetSim_Packet_AddPacketToList(buffer, packet, 0);
216 }
217}
218
219/**
220This function is called by NetworkStack.dll, whenever the event gets triggered
221inside the NetworkStack.dll for IP.It includes NETWORK_OUT,NETWORK_IN and TIMER_EVENT.
222*/
224{
226 {
228 {
229 ptrIP_FORWARD_ROUTE route = NULL;
231 NETWORK_LAYER_PROTOCOL nLocalNetworkProtcol;
232 nLocalNetworkProtcol = fnGetLocalNetworkProtocol(pstruEventDetails);
233 if (nLocalNetworkProtcol)
234 {
235 fnCallProtocol(nLocalNetworkProtcol);
236 return 0;
237 }
238 if (packet->pstruNetworkData->nTTL == 0)
239 {
240 //TTL expire drop the packet
246 pstruEventDetails->pPacket = NULL;
248 return 0;
249 }
250 //set the time
253 //Set the payload
254 if (packet->pstruTransportData)
256
257 //Already got routed
258 if (packet->pstruNetworkData->szNextHopIp)
259 {
260 route = build_route(packet);
261 goto PACKET_ROUTED;
262 }
263
264 if (packet->pstruNetworkData->szNextHopIp == NULL)
265 {
266 //First route via static ip route table
269 }
270
271 packet = pstruEventDetails->pPacket;
272
273 if (!packet)
274 return -1; //Routing fails
275
276 if (route && route->count)
277 goto PACKET_ROUTED;
278
279 //Call NAT
281
282 // Recall static route
283 if (packet->pstruNetworkData->szNextHopIp == NULL)
284 {
285 //First route via static ip route table
288 }
289
290 packet = pstruEventDetails->pPacket;
291
292 if (!packet)
293 return -1; //Routing fails
294
295 if (route && route->count)
296 goto PACKET_ROUTED;
297
298 //routing function
299 //First route via routing function
300 if (DEVICE_NWLAYER(pstruEventDetails->nDeviceId)->routerFunction)
301 DEVICE_NWLAYER(pstruEventDetails->nDeviceId)->routerFunction();
302
303 packet = pstruEventDetails->pPacket;
304 if (!packet)
305 return -1; //Routing fails
306
307 if (packet->pstruNetworkData->szNextHopIp)
308 {
309 route = build_route(packet);
310 goto PACKET_ROUTED;
311 }
312
313 //Route via routing protocol
314 if (DEVICE_NWLAYER(pstruEventDetails->nDeviceId)->nRoutingProtocolId)
315 {
317 }
318
319 packet = pstruEventDetails->pPacket;
320 if (!packet)
321 return -1; //Routing fails
322
323 if (packet->pstruNetworkData->szNextHopIp)
324 {
325 route = build_route(packet);
326 goto PACKET_ROUTED;
327 }
328
329 //IP Routing
330 packet = pstruEventDetails->pPacket;
331 route = fn_NetSim_IP_RoutePacket(packet,
333
334 if (!route || !route->count)
335 goto ROUTING_FAILS;
336 else
337 goto PACKET_ROUTED;
338
339 ROUTING_FAILS:
340 {
342 //Generate ICMP dst unreachable message
344 if (var && var->isICMP)
346 packet = NULL;
347 free_ip_route(route);
348 return -2;
349 }
350
351 PACKET_ROUTED:
352 if (route)
353 {
354 NetSim_PACKET* p;
355 UINT i;
356 //Packet is routed via ip table
357 for (i = 0; i < route->count; i++)
358 {
359 if (i != route->count - 1)
360 p = fn_NetSim_Packet_CopyPacket(packet);
361 else
362 p = packet;
363
364 p->pstruNetworkData->szNextHopIp = route->nextHop[i];
365 pass_to_lower_layer(p, route, i);
366 }
367 }
368 else
369 {
370 //Packet is routed via other protocol
371 pass_to_lower_layer(packet, NULL, 0);
372 }
373 free_ip_route(route);
374 }
375 break;
376 case NETWORK_IN_EVENT:
377 {
380 {
381 //Call the local network protocol
383 }
384 if (pstruEventDetails->pPacket == NULL)
385 return 0;
386 packet = pstruEventDetails->pPacket;
387
392 if (!IP_IS_IN_SAME_NETWORK(gateway, my, sub, prefix))
393 {
395 return 0;
396 }
397
400 {
404 }
405
406 //Decrease the TTL
407 packet->pstruNetworkData->nTTL--;
408
409 //Reduce the IP overhead
412 if ((((IP_DEVVAR*)DEVICE_NWLAYER(pstruEventDetails->nDeviceId)->ipVar)->nVPNStatus == VPN_SERVER ||
413 ((IP_DEVVAR*)DEVICE_NWLAYER(pstruEventDetails->nDeviceId)->ipVar)->nVPNStatus == VPN_CLIENT) &&
416 packet = pstruEventDetails->pPacket;
417 if (!packet)
418 return 0;
419
420 //check for firewall
425 {
429 return 0;
430 }
431
432 //call routing protocol
433 if (DEVICE_NWLAYER(pstruEventDetails->nDeviceId)->nRoutingProtocolId)
435 packet = pstruEventDetails->pPacket;
436 if (!packet)
437 return 0;
438
439 //Call NAT
441
443
444 if (action == ACTION_DROP)
445 {
446 //Drop packet
449 return 0;
450 }
451
452 if (action == ACTION_MOVEUP)
453 {
456 switch (num)
457 {
458 case IPPROTOCOL_ICMP:
460 break;
461 case IPPROTOCOL_IGMP:
463 break;
464 case IPPROTOCOL_PIM:
466 break;
467 case IPPROTOCOL_DSR:
468 //Already processed by routing protocol call.
469 break;
470 case IPPROTOCOL_TCP:
471 if (txProtocol == TX_PROTOCOL_NULL)
472 txProtocol = TX_PROTOCOL_TCP;
473 case IPPROTOCOL_UDP:
474 if(txProtocol == TX_PROTOCOL_NULL)
475 txProtocol = TX_PROTOCOL_UDP;
476 default:
477 //For legacy code
478
479 //Add transport in event
482 pstruEventDetails->nProtocolId = txProtocol;
486
487 //Increment the received count
489 break;
490 }
491 }
492 else if (action == ACTION_REROUTE)
493 {
494 //Add network out event to reroute the packet
495 packet->pstruNetworkData->szNextHopIp = NULL;
496 packet->pstruNetworkData->szGatewayIP = NULL;
497
504
505 //Increment the forwarded count
507 }
508 }
509 break;
510 case TIMER_EVENT:
511 {
513 {
514 case EVENT_ICMP_POLL:
516 break;
519 break;
522 break;
528 break;
531 break;
534 break;
537 break;
540 break;
543 case EVENT_PIM_ET:
544 case EVENT_PIM_JT:
546 break;
549 NULL, NULL, 0, NULL, 0, NULL, NULL, 0, NULL);
550 break;
553 break;
556 break;
557 default:
558 {
559 char error[BUFSIZ];
560 sprintf(error, "Unknown sub event %d for IP", pstruEventDetails->nSubEventType);
561 fnNetSimError(error);
562 }
563 break;
564 }
565 }
566 break;
567 default:
568 {
569 char error[BUFSIZ];
570 sprintf(error, "Unknown event %d for IP", pstruEventDetails->nEventType);
571 fnNetSimError(error);
572 }
573 break;
574 }
575 return 0;
576}
577
578/**
579This function is called by NetworkStack.dll, once simulation end to free the
580allocated memory for the network.
581*/
583{
584 NETSIM_ID i;
585 for (i = 0; i < NETWORK->nDeviceCount; i++)
586 {
587 if (DEVICE_NWLAYER(i + 1))
588 {
589 ptrIP_ROUTINGTABLE table = IP_TABLE_GET(i+1);
591 if (devVar)
592 {
594 free(devVar->firewallConfig);
595 free(devVar->GatewayIPAddress);
596 free(devVar->nGatewayId);
597 free(devVar->nGatewayState);
598 free(devVar->nInterfaceId);
599 freeVPN(devVar->vpn);
600 freeDNS(devVar->dnsList);
601 igmp_free(i + 1);
602 free(devVar);
603 }
604 while (table)
605 {
606 LIST_FREE(&table, table);
607 }
608 }
609 free(ipMetrics[i]);
610 }
612 return 1;
613}
614
615/**
616This function is called by NetworkStack.dll, while writing the event trace
617to get the sub event as a string.
618*/
619_declspec(dllexport) char* fn_NetSim_IP_Trace(NETSIM_ID nSubeventid)
620{
621 switch (nSubeventid)
622 {
623 case EVENT_ICMP_POLL:
624 return "ICMP_POLL";
626 return "ICMP_Advertise_Router";
628 return "IGMP_DelayTimer";
630 return "IGMP_GroupMembershipTimer";
632 return "IGMP_OtherQueierPresentTimer";
634 return "IGMP_SendQuery";
636 return "IGMP_SendStartupQuery";
638 return "IGMP_UnsolicitedReportTimer";
640 return "IP_INIT_TABLE";
642 return "PIM_SEND_HELLO";
644 return "PIM_NEIGHBOR_TIMEOUT";
645 case EVENT_PIM_JT:
646 return "PIM_JT";
647 case EVENT_PIM_ET:
648 return "PIM_ET";
650 return "ICMP_SEND_ECHO";
652 return "IP_PROCESSING_DELAY";
653 default:
654 return "IP_UNKNOWN_SUBEVENT";
655 }
656}
657
658#pragma region SCHEDULER_CONFIG
659#define QUEUING_MAX_TH_MB_DEFAULT 7.0
660#define QUEUING_MIN_TH_MB_DEFAULT 4.0
661
662#define QUEUING_MAX_P_DEFAULT 0.05
663#define QUEUING_WQ_DEFAULT 0.0002
664
665#define QUEUING_LOW_MAX_TH_MB_DEFAULT 7.0
666#define QUEUING_NORMAL_MAX_TH_MB_DEFAULT 7.0
667#define QUEUING_MEDIUM_MAX_TH_MB_DEFAULT 7.0
668#define QUEUING_HIGH_MAX_TH_MB_DEFAULT 7.0
669#define QUEUING_LOW_MIN_TH_MB_DEFAULT 4.0
670#define QUEUING_NORMAL_MIN_TH_MB_DEFAULT 4.5
671#define QUEUING_MEDIUM_MIN_TH_MB_DEFAULT 5.0
672#define QUEUING_HIGH_MIN_TH_MB_DEFAULT 5.5
673
674#define QUEUING_LOW_MAX_P_DEFAULT 0.05
675#define QUEUING_NORMAL_MAX_P_DEFAULT 0.05
676#define QUEUING_MEDIUM_MAX_P_DEFAULT 0.05
677#define QUEUING_HIGH_MAX_P_DEFAULT 0.05
678
679#define SCHEDULING_MAX_LATENCY_UGS_MS_DEFAULT 100
680#define SCHEDULING_MAX_LATENCY_rtPS_MS_DEFAULT 150
681#define SCHEDULING_MAX_LATENCY_ertPS_MS_DEFAULT 300
682#define SCHEDULING_MAX_LATENCY_nrtPS_MS_DEFAULT 300
683#define SCHEDULING_MAX_LATENCY_BE_MS_DEFAULT 100000
684
685static void ip_queuing_read_config(NETSIM_ID d, NETSIM_ID in, void* xmlNetSimNode)
686{
687 char* szVal;
688 NetSim_BUFFER* pstruBuffer = DEVICE_ACCESSBUFFER(d, in);
689
690 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "QUEUING_TYPE", 0);
691 if (szVal)
692 {
693 if (_stricmp(szVal, "DROP_TAIL") == 0)
694 pstruBuffer->queuingTechnique = QUEUING_DROPTAIL;
695 else if (_stricmp(szVal, "RED") == 0)
696 {
697 pstruBuffer->queuingTechnique = QUEUING_RED;
698
699 ptrQUEUING_RED_VAR queuing_var = calloc(1, sizeof * queuing_var);
700 queuing_var->max_th = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "MAX_TH", QUEUING_MAX_TH_MB_DEFAULT, "MB");
701 queuing_var->min_th = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "MIN_TH", QUEUING_MIN_TH_MB_DEFAULT, "MB");
702 getXmlVar(&queuing_var->max_p, MAX_P, xmlNetSimNode, 1, _DOUBLE, QUEUING);
703 getXmlVar(&queuing_var->wq, WQ, xmlNetSimNode, 1, _DOUBLE, QUEUING);
704
705 queuing_var->avg_queue_size = 0;
706 queuing_var->count = -1;
707 queuing_var->random_value = NETSIM_RAND_01();
708 queuing_var->q_time = 0;
709 pstruBuffer->queuingParam = queuing_var;
710 }
711 else if (_stricmp(szVal, "WRED") == 0)
712 {
713 pstruBuffer->queuingTechnique = QUEUING_WRED;
714 ptrQUEUING_WRED_VAR queuing_var = calloc(1, sizeof * queuing_var);
715 double* min_th_values = calloc(4, sizeof * min_th_values);
716 double* max_th_values = calloc(4, sizeof * max_th_values);
717 double* max_p_values = calloc(4, sizeof * max_p_values);
718 int* count_values = calloc(4, sizeof * count_values);
719 double* random_values = calloc(4, sizeof * random_values);
720 min_th_values[0] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "LOW_MIN_TH", QUEUING_LOW_MIN_TH_MB_DEFAULT, "MB");
721 min_th_values[1] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "NORMAL_MIN_TH", QUEUING_NORMAL_MIN_TH_MB_DEFAULT, "MB");
722 min_th_values[2] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "MEDIUM_MIN_TH", QUEUING_MEDIUM_MIN_TH_MB_DEFAULT, "MB");
723 min_th_values[3] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "HIGH_MIN_TH", QUEUING_HIGH_MIN_TH_MB_DEFAULT, "MB");
724 max_th_values[0] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "LOW_MAX_TH", QUEUING_LOW_MAX_TH_MB_DEFAULT, "MB");
725 max_th_values[1] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "NORMAL_MAX_TH", QUEUING_NORMAL_MAX_TH_MB_DEFAULT, "MB");
726 max_th_values[2] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "MEDIUM_MAX_TH", QUEUING_MEDIUM_MAX_TH_MB_DEFAULT, "MB");
727 max_th_values[3] = fn_NetSim_Config_read_dataLen(xmlNetSimNode, "HIGH_MAX_TH", QUEUING_HIGH_MAX_TH_MB_DEFAULT, "MB");
728 getXmlVar(&max_p_values[0], LOW_MAX_P, xmlNetSimNode, 1, _DOUBLE, QUEUING);
729 getXmlVar(&max_p_values[1], NORMAL_MAX_P, xmlNetSimNode, 1, _DOUBLE, QUEUING);
730 getXmlVar(&max_p_values[2], MEDIUM_MAX_P, xmlNetSimNode, 1, _DOUBLE, QUEUING);
731 getXmlVar(&max_p_values[3], HIGH_MAX_P, xmlNetSimNode, 1, _DOUBLE, QUEUING);
732 getXmlVar(&queuing_var->wq, WQ, xmlNetSimNode, 1, _DOUBLE, QUEUING);
733
734
735 count_values[0] = -1;
736 count_values[1] = -1;
737 count_values[2] = -1;
738 count_values[3] = -1;
739 random_values[0] = NETSIM_RAND_01();
740 random_values[1] = NETSIM_RAND_01();
741 random_values[2] = NETSIM_RAND_01();
742 random_values[3] = NETSIM_RAND_01();
743
744 queuing_var->max_th = max_th_values;
745 queuing_var->min_th = min_th_values;
746 queuing_var->max_p = max_p_values;
747 queuing_var->avg_queue_size = 0;
748 queuing_var->count = count_values;
749 queuing_var->random_value = random_values;
750 pstruBuffer->queuingParam = queuing_var;
751 }
752 else
753 {
754 fnNetSimError("Unknwon queuing technique %s for router %d-%d.\n",
755 szVal, d, in);
756 pstruBuffer->queuingTechnique = QUEUING_NULL;
757 }
758 }
759 else
760 pstruBuffer->queuingTechnique = QUEUING_NULL;
761 free(szVal);
762}
763
764static void ip_scheduling_read_config(NETSIM_ID d, NETSIM_ID in, void* xmlNetSimNode)
765{
766 NetSim_BUFFER* pstruBuffer = DEVICE_ACCESSBUFFER(d, in);
767 char* szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "SCHEDULING_TYPE", 0);
768 if (szVal)
769 {
770 _strupr(szVal);
771 if (strcmp(szVal, "FIFO") == 0)
772 pstruBuffer->nSchedulingType = SCHEDULING_FIFO;
773 else if (strcmp(szVal, "PRIORITY") == 0)
775 else if (strcmp(szVal, "ROUND_ROBIN") == 0)
777 else if (strcmp(szVal, "WFQ") == 0)
778 pstruBuffer->nSchedulingType = SCHEDULING_WFQ;
779 else if (strcmp(szVal, "EDF") == 0)
780 {
781 pstruBuffer->nSchedulingType = SCHEDULING_EDF;
782 ptrSCHEDULING_EDF_VAR scheduling_var = calloc(1, sizeof * scheduling_var);
783 double* max_latency_values = calloc(5, sizeof * max_latency_values);
784
785 max_latency_values[0] = fn_NetSim_Config_read_time(xmlNetSimNode, "MAX_LATENCY_UGS", SCHEDULING_MAX_LATENCY_UGS_MS_DEFAULT, "ms");
786 max_latency_values[1] = fn_NetSim_Config_read_time(xmlNetSimNode, "MAX_LATENCY_rtPS", SCHEDULING_MAX_LATENCY_rtPS_MS_DEFAULT, "ms");
787 max_latency_values[2] = fn_NetSim_Config_read_time(xmlNetSimNode, "MAX_LATENCY_ertPS", SCHEDULING_MAX_LATENCY_ertPS_MS_DEFAULT, "ms");
788 max_latency_values[3] = fn_NetSim_Config_read_time(xmlNetSimNode, "MAX_LATENCY_nrtPS", SCHEDULING_MAX_LATENCY_nrtPS_MS_DEFAULT, "ms");
789 max_latency_values[4] = fn_NetSim_Config_read_time(xmlNetSimNode, "MAX_LATENCY_BE", SCHEDULING_MAX_LATENCY_BE_MS_DEFAULT, "ms");
790
791 scheduling_var->max_latency = max_latency_values;
792 pstruBuffer->schedulingParam = scheduling_var;
793 }
794 else
795 {
796 fnNetSimError("Unknown scheduling technique %s for router %d-%d.\n",
797 szVal, d, in);
798 pstruBuffer->nSchedulingType = SCHEDULING_NONE;
799 }
800 }
801 else
802 pstruBuffer->nSchedulingType = SCHEDULING_NONE;
803 free(szVal);
804}
805#pragma endregion
806
807
808#pragma region BUFFER_PLOT
809#define BUFFER_BUFFER_PLOT_DEFAULT true
810#pragma endregion
811
812/**
813This function is called by NetworkStack.dll, while configuring the device
814NETWORK layer for IP protocol.
815*/
816_declspec(dllexport) int fn_NetSim_IP_Configure(void** var)
817{
818 FILE* fpConfigLog;
819 void* xmlNetSimNode;
820 NETSIM_ID nDeviceId = 0;
821 NETSIM_ID nInterfaceId = 0;
822 LAYER_TYPE nLayerType = 0;
823 char* szVal;
824 IP_DEVVAR* devVar;
825 fpConfigLog = var[0];
826 xmlNetSimNode = var[2];
827 if (var[3])
828 nDeviceId = *((NETSIM_ID*)var[3]);
829 if (var[4])
830 nInterfaceId = *((NETSIM_ID*)var[4]);
831 if (var[5])
832 nLayerType = *((LAYER_TYPE*)var[5]);
833 if (nDeviceId)
834 {
835 devVar = NETWORK->ppstruDeviceList[nDeviceId - 1]->pstruNetworkLayer->ipVar;
836 if (devVar == NULL)
837 {
838 devVar = calloc(1, sizeof* devVar);
839 NETWORK->ppstruDeviceList[nDeviceId - 1]->pstruNetworkLayer->ipVar = devVar;
840 }
841 }
842
843 if (nDeviceId && nInterfaceId)
844 {
845 int iptype = 0;
846 NetSim_BUFFER* pstruBuffer;
847 int nDeviceType;
848 nDeviceType = DEVICE_TYPE(nDeviceId);
849
850 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "BUFFER_SIZE", 0);
851 if (szVal)
852 {
853 pstruBuffer = DEVICE_ACCESSBUFFER(nDeviceId, nInterfaceId);
854
855 pstruBuffer->deviceId = nDeviceId;
856 pstruBuffer->interfaceId = nInterfaceId;
857
858 pstruBuffer->dMaxBufferSize = atoi(szVal);
859 free(szVal);
860
861 getXmlVar(&pstruBuffer->isPlotEnable, BUFFER_PLOT, xmlNetSimNode, 0, _BOOL, BUFFER);
862
863 //Configure the Queuing
864 ip_queuing_read_config(nDeviceId, nInterfaceId, xmlNetSimNode);
865
866 //Configure the Scheduling
867 ip_scheduling_read_config(nDeviceId, nInterfaceId, xmlNetSimNode);
868 }
869
870 if (NETWORK->ppstruDeviceList[nDeviceId - 1]->ppstruInterfaceList[nInterfaceId - 1]->nProtocolId == NW_PROTOCOL_IPV4)
871 iptype = 4;
872 else if (NETWORK->ppstruDeviceList[nDeviceId - 1]->ppstruInterfaceList[nInterfaceId - 1]->nProtocolId == NW_PROTOCOL_IPV6)
873 iptype = 6;
874 //Configure the IP address
875 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "IP_ADDRESS", 1);
876 NETWORK->ppstruDeviceList[nDeviceId - 1]->ppstruInterfaceList[nInterfaceId - 1]->szAddress = STR_TO_IP(szVal, iptype);
877 free(szVal);
878
879 if (iptype == 4)
880 {
881 //Configure the subnet mask
882 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "SUBNET_MASK", 1);
883 NETWORK->ppstruDeviceList[nDeviceId - 1]->ppstruInterfaceList[nInterfaceId - 1]->szSubnetMask = STR_TO_IP4(szVal);
884 free(szVal);
885 }
886 else if (iptype == 6)
887 {
888 //Configure the subnet mask
889 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "PREFIX_LENGTH", 1);
890 NETWORK->ppstruDeviceList[nDeviceId - 1]->ppstruInterfaceList[nInterfaceId - 1]->prefix_len = atoi(szVal);
891 free(szVal);
892 }
893 else
894 return -1;
895
896 //Configure the default gateway
897 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "DEFAULT_GATEWAY", 0);
898 if (szVal)
899 NETWORK->ppstruDeviceList[nDeviceId - 1]->ppstruInterfaceList[nInterfaceId - 1]->szDefaultGateWay = STR_TO_IP(szVal, iptype);
900 free(szVal);
901 }
902 else if (nDeviceId)
903 {
904 devVar->processingDelay = fn_NetSim_Config_read_time(xmlNetSimNode, "PROCESSING_DELAY", IP_PROCESSING_DELAY_DEFAULT, "us");
905
906 getXmlVar(&devVar->isIGMPConfigured, IGMP_STATUS, xmlNetSimNode, 0, _BOOL, IP);
907
908 getXmlVar(&devVar->staticIPTableFile, STATIC_IP_ROUTE, xmlNetSimNode, 0, _STRING, IP);
909
910 if (devVar->isIGMPConfigured)
911 igmp_configure(nDeviceId, xmlNetSimNode);
912
913 getXmlVar(&devVar->isPIMConfigured, PIM_STATUS, xmlNetSimNode, 0, _BOOL, IP);
914 if (devVar->isPIMConfigured)
915 pim_configure(nDeviceId, xmlNetSimNode);
916
917 //Configure the firewall status
918 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "ACL_STATUS", 0);
919 if (szVal && _strupr(szVal) && !strcmp(szVal, "ENABLE"))
920 {
921 devVar->isFirewallConfigured = true;
922 free(szVal);
923 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "ACL_CONFIG_FILE", 1);
924 if (szVal)
925 devVar->firewallConfig = szVal;
926 else
927 devVar->isFirewallConfigured = false;
928 }
929 else
930 free(szVal);
931
932 getXmlVar(&devVar->isICMP, ICMP_STATUS, xmlNetSimNode, 0, _BOOL, IP);
933
934 if (devVar->isICMP)
935 {
936 //Configure the ICMP property
937 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "ICMP_CONTINUOUS_POLLING_TIME", 0);
938 if (szVal)
939 {
940 devVar->nICMPPollingTime = atoi(szVal);
941 free(szVal);
942 }
943 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "ROUTER_ADVERTISEMENT", 0);
944 if (szVal)
945 {
946 _strupr(szVal);
947 if (!strcmp(szVal, "TRUE"))
948 devVar->nRouterAdvertisementFlag = 1;
949 free(szVal);
950 }
951 if (devVar->nRouterAdvertisementFlag)
952 {
953 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "ROUTER_ADVERTISEMENT_MIN_INTERVAL", 0);
954 if (szVal)
955 {
956 devVar->nRouterAdverMinInterval = atoi(szVal);
957 free(szVal);
958 }
959 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "ROUTER_ADVERTISEMENT_MAX_INTERVAL", 0);
960 if (szVal)
961 {
962 devVar->nRouterAdverMaxInterval = atoi(szVal);
963 free(szVal);
964 }
965 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "ROUTER_ADVERTISEMENT_LIFE_TIME", 0);
966 if (szVal)
967 {
968 devVar->nRouterAdverLifeTime = atoi(szVal);
969 free(szVal);
970 }
971 }
972 }
973
974 //Configure the VPN
975 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "VPN_STATUS", 0);
976 if (szVal)
977 {
978 _strupr(szVal);
979 if (!strcmp(szVal, "SERVER"))
980 {
981 devVar->nVPNStatus = VPN_SERVER;
982 free(szVal);
983 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "IP_POOL_START", 1);
984 if (szVal)
985 {
986 devVar->ipPoolStart = STR_TO_IP4(szVal);
987 }
988 else
989 devVar->nVPNStatus = VPN_DISABLE;
990 free(szVal);
991 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "IP_POOL_END", 1);
992 if (szVal)
993 {
994 devVar->ipPoolEnd = STR_TO_IP4(szVal);
995 }
996 else
997 devVar->nVPNStatus = VPN_DISABLE;
998 free(szVal);
999 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "IP_POOL_MASK", 1);
1000 if (szVal)
1001 {
1002 devVar->ipPoolMask = STR_TO_IP4(szVal);
1003 }
1004 else
1005 devVar->nVPNStatus = VPN_DISABLE;
1006 free(szVal);
1007 }
1008 else if (!strcmp(szVal, "CLIENT"))
1009 {
1010 devVar->nVPNStatus = VPN_CLIENT;
1011 free(szVal);
1012 szVal = fn_NetSim_xmlConfig_GetVal(xmlNetSimNode, "SERVER_IP", 1);
1013 if (szVal)
1014 {
1015 devVar->serverIP = STR_TO_IP4(szVal);
1016 }
1017 else
1018 devVar->nVPNStatus = VPN_DISABLE;
1019 free(szVal);
1020 }
1021 else
1022 free(szVal);
1023 }
1024 }
1025 return 1;
1026}
1027
1028/**
1029This function is to free the memory allocated for packets of this protocol.
1030*/
1032{
1033 if (pstruPacket->pstruNetworkData->nPacketFlag == PACKET_VPN)
1034 {
1036 }
1037 switch (pstruPacket->pstruNetworkData->IPProtocol)
1038 {
1039 case IPPROTOCOL_IGMP:
1040 IGMP_FreePacket(pstruPacket);
1041 break;
1042 }
1043 return 1;
1044}
1045/**
1046This function is to copy the IP information from source to the destination.
1047*/
1048_declspec(dllexport) int fn_NetSim_IP_CopyPacket(NetSim_PACKET* pstruDestPacket, NetSim_PACKET* pstruSrcPacket)
1049{
1050 if (pstruSrcPacket->pstruNetworkData->nPacketFlag == PACKET_VPN)
1052 switch (pstruSrcPacket->pstruNetworkData->IPProtocol)
1053 {
1054 case IPPROTOCOL_ICMP:
1055 ICMP_copyPacket(pstruDestPacket, pstruSrcPacket);
1056 break;
1057 case IPPROTOCOL_IGMP:
1058 copy_igmp_packet(pstruDestPacket, pstruSrcPacket);
1059 break;
1060 }
1061 return 1;
1062}
1063/**
1064This function write the Metrics in Metrics.txt
1065*/
1066_declspec(dllexport) int fn_NetSim_IP_Metrics(PMETRICSWRITER metricsWriter)
1067{
1068 NETSIM_ID loop;
1069 PMETRICSNODE menu = init_metrics_node(MetricsNode_Menu, "IP_Metrics", NULL);
1070 PMETRICSNODE table = init_metrics_node(MetricsNode_Table, "IP_Metrics", NULL);
1071 add_node_to_menu(menu, table);
1072
1073 add_table_heading(table, "Device Id", true, 0);
1074 add_table_heading(table, "Packet sent", true, 0);
1075 add_table_heading(table, "Packet forwarded", true, 0);
1076 add_table_heading(table, "Packet received", true, 0);
1077 add_table_heading(table, "Packet discarded", false, 0);
1078 add_table_heading(table, "TTL expired", false, 0);
1079 add_table_heading(table, "Firewall blocked", false, 0);
1080
1081 for (loop = 0; loop < NETWORK->nDeviceCount; loop++)
1082 {
1083 if (ipMetrics[loop])
1084 {
1085 add_table_row_formatted(false, table, "%d,%d,%d,%d,%d,%d,%d,",
1086 ipMetrics[loop]->nDeviceId,
1087 ipMetrics[loop]->nPacketSent,
1088 ipMetrics[loop]->nPacketForwarded,
1089 ipMetrics[loop]->nPacketReceived,
1090 ipMetrics[loop]->nPacketDiscarded,
1091 ipMetrics[loop]->nTTLDrop,
1092 ipMetrics[loop]->nFirewallBlocked);
1093 }
1094 }
1095 write_metrics_node(metricsWriter, WriterPosition_Current, NULL, menu);
1097
1098 menu = init_metrics_node(MetricsNode_Menu, "IP_Forwarding_Table", NULL);
1099 for (loop = 0; loop < NETWORK->nDeviceCount; loop++)
1100 {
1102 IP_TABLE_GET(loop+1))
1103 {
1104 ptrIP_ROUTINGTABLE routeTable = IP_TABLE_GET(loop + 1);
1105
1107 add_node_to_menu(menu, submenu);
1109 add_node_to_menu(submenu, table);
1110
1111 add_table_heading(table, "Network Destination", true, 0);
1112 add_table_heading(table, "Netmask/Prefix len", true, 0);
1113 add_table_heading(table, "Gateway", true, 0);
1114 add_table_heading(table, "Interface", true, 0);
1115 add_table_heading(table, "Metrics", false, 0);
1116 add_table_heading(table, "Type", false, 0);
1117
1118 while (routeTable)
1119 {
1120 char ipStr[_NETSIM_IP_LEN];
1121 IP_TO_STR(routeTable->networkDestination, ipStr);
1122 add_table_row_formatted(false, table, "%s,", ipStr);
1123 if (routeTable->networkDestination && routeTable->networkDestination->type == 4)
1124 {
1125 IP_TO_STR(routeTable->netMask, ipStr);
1126 add_table_row_formatted(true, table, "%s,", ipStr);
1127 }
1128 else if (routeTable->networkDestination && routeTable->networkDestination->type == 6)
1129 {
1130 add_table_row_formatted(true, table, "%d,", routeTable->prefix_len);
1131 }
1132 if (routeTable->gateway)
1133 {
1134 IP_TO_STR(routeTable->gateway, ipStr);
1135 add_table_row_formatted(true, table, "%s,", ipStr);
1136 }
1137 else
1138 add_table_row_formatted(true, table, "on-link,");
1139
1140 UINT i;
1141 char str[BUFSIZ] = "";
1142 for (i = 0; i < routeTable->interfaceCount; i++)
1143 {
1144 strcat(str, routeTable->Interface[i]->str_ip);
1145 strcat(str, " ");
1146 }
1147 add_table_row_formatted(true, table, "%s,", str);
1148
1149 add_table_row_formatted(true, table, "%d,", routeTable->Metric);
1150
1151 if (routeTable->szType && *routeTable->szType)
1152 {
1153 add_table_row_formatted(true, table, "%s,", routeTable->szType);
1154 }
1155 else
1156 {
1157 switch (routeTable->type)
1158 {
1160 add_table_row_formatted(true, table, "Default,");
1161 break;
1162 case RoutingType_STATIC:
1163 add_table_row_formatted(true, table, "Static,");
1164 break;
1165 default:
1166 add_table_row_formatted(true, table, "-,");
1167 break;
1168 }
1169 }
1170 routeTable = LIST_NEXT(routeTable);
1171 }
1172 }
1173 }
1174 write_metrics_node(metricsWriter, WriterPosition_Current, NULL, menu);
1176 return 1;
1177}
1178int IP_packetTraceFiledFlag[4] = { 0,0,0,0 };
1179char pszTrace[BUFSIZ];
1180/**
1181This function will return the string to write packet trace heading.
1182*/
1183_declspec(dllexport) char* fn_NetSim_IP_ConfigPacketTrace(const void* xmlNetSimNode)
1184{
1185 char* szStatus;
1186 *pszTrace = 0;
1187 szStatus = fn_NetSim_xmlConfigPacketTraceField(xmlNetSimNode, "SOURCE_IP");
1188 _strupr(szStatus);
1189 if (!strcmp(szStatus, "ENABLE"))
1190 {
1192 strcat(pszTrace, "SOURCE_IP,");
1193 }
1194 else
1196 free(szStatus);
1197 szStatus = fn_NetSim_xmlConfigPacketTraceField(xmlNetSimNode, "DESTINATION_IP");
1198 _strupr(szStatus);
1199 if (!strcmp(szStatus, "ENABLE"))
1200 {
1202 strcat(pszTrace, "DESTINATION_IP,");
1203 }
1204 else
1206 free(szStatus);
1207 szStatus = fn_NetSim_xmlConfigPacketTraceField(xmlNetSimNode, "GATEWAY_IP");
1208 _strupr(szStatus);
1209 if (!strcmp(szStatus, "ENABLE"))
1210 {
1212 strcat(pszTrace, "GATEWAY_IP,");
1213 }
1214 else
1216 free(szStatus);
1217 szStatus = fn_NetSim_xmlConfigPacketTraceField(xmlNetSimNode, "NEXT_HOP_IP");
1218 _strupr(szStatus);
1219 if (!strcmp(szStatus, "ENABLE"))
1220 {
1222 strcat(pszTrace, "NEXT_HOP_IP,");
1223 }
1224 else
1226 free(szStatus);
1227 return pszTrace;
1228}
1229/**
1230This function will return the string to write packet trace.
1231*/
1232_declspec(dllexport) int fn_NetSim_IP_WritePacketTrace(NetSim_PACKET* pstruPacket, char** ppszTrace)
1233{
1234 int i = 0;
1235 char ip[_NETSIM_IP_LEN];
1236 *pszTrace = 0;
1237 *ppszTrace = calloc(BUFSIZ, sizeof(char));
1238 if (pstruPacket->pstruNetworkData == NULL)
1239 {
1240 sprintf(*ppszTrace, "-,-,-,-,");
1241 return 0;
1242 }
1243
1244
1245 if (IP_packetTraceFiledFlag[i++] == 1)
1246 {
1247 if (pstruPacket->pstruNetworkData->szSourceIP)
1248 IP_TO_STR(pstruPacket->pstruNetworkData->szSourceIP, ip);
1249 else
1250 strcpy(ip, "-");
1251 sprintf(pszTrace, "%s%s,", pszTrace, ip);
1252 }
1253 if (IP_packetTraceFiledFlag[i++] == 1)
1254 {
1255 if (pstruPacket->pstruNetworkData->szDestIP)
1256 IP_TO_STR(pstruPacket->pstruNetworkData->szDestIP, ip);
1257 else
1258 strcpy(ip, "-");
1259 sprintf(pszTrace, "%s%s,", pszTrace, ip);
1260 }
1261 if (IP_packetTraceFiledFlag[i++] == 1)
1262 {
1263 if (pstruPacket->pstruNetworkData->szGatewayIP)
1264 IP_TO_STR(pstruPacket->pstruNetworkData->szGatewayIP, ip);
1265 else
1266 strcpy(ip, "-");
1267 sprintf(pszTrace, "%s%s,", pszTrace, ip);
1268 }
1269 if (IP_packetTraceFiledFlag[i++] == 1)
1270 {
1271 if (pstruPacket->pstruNetworkData->szNextHopIp)
1272 IP_TO_STR(pstruPacket->pstruNetworkData->szNextHopIp, ip);
1273 else
1274 strcpy(ip, "-");
1275 sprintf(pszTrace, "%s%s,", pszTrace, ip);
1276 }
1277 strcpy(*ppszTrace, pszTrace);
1278 return 1;
1279}
1280
1281
1282/** This function is to get the local network protocol */
1284{
1285 switch (pstruEventDetails->nSubEventType / 100)
1286 {
1287 case NW_PROTOCOL_ARP:
1288 return NW_PROTOCOL_ARP;
1289 }
1291 {
1292 case NW_PROTOCOL_ARP:
1293 return NW_PROTOCOL_ARP;
1294 }
1295 return 0;
1296}
1297
1299{
1300 NETSIM_ID i;
1301 bool isDefault = false;
1302 bool isFound = false;
1303
1304 if (DEVICE_NWADDRESS(d, in) == NULL) return false;
1305
1306 if (DEVICE_INTERFACE(d, in)->szDefaultGateWay)
1307 isDefault = true;
1308
1309 for (i = 0; i < DEVICE(d)->nNumOfInterface; i++)
1310 {
1311 if (DEVICE_NWADDRESS(d, i + 1) == NULL) continue;
1312
1313 if (!IP_COMPARE(DEVICE_NWADDRESS(d, i + 1), DEVICE_NWADDRESS(d, in)))
1314 {
1315 if (in > i + 1)
1316 isFound = true;
1317
1318 if (DEVICE_INTERFACE(d, i + 1)->szDefaultGateWay)
1319 {
1320 if (!isDefault)
1321 return true;
1322 else if (in <= i + 1)
1323 return false;
1324 else
1325 return true;
1326 }
1327 }
1328 }
1329 return isFound;
1330}
1331
1333{
1334 NETSIM_ID i;
1335
1336 if (!DEVICE_NWLAYER(d))
1337 return; //Why i am called.
1338
1339 for (i = 1; i <= DEVICE(d)->nNumOfInterface; i++)
1340 {
1341 NETSIM_IPAddress dest = NULL;
1342 NETSIM_IPAddress mask = NULL;
1343 NETSIM_IPAddress gate;
1344 UINT pre = 0;
1345
1346 IP_DEVVAR* devVar = DEVICE_NWLAYER(d)->ipVar;
1348 NETSIM_IPAddress subnet = DEVICE_INTERFACE(d, i)->szSubnetMask;
1349 NETSIM_IPAddress gateway = DEVICE_INTERFACE(d, i)->szDefaultGateWay;
1350 UINT prefix = DEVICE_INTERFACE(d, i)->prefix_len;
1351
1352 if (!ip) continue; //Not an IP interface
1353
1354 if (isSameIPForOtherInterface(d, i))
1355 continue;
1356
1358 IP_NETWORK_ADDRESS(ip, subnet, prefix),
1359 subnet,
1360 prefix,
1361 on_link,
1362 1,
1363 &ip,
1364 &i,
1366 "LOCAL");
1367
1368 if (gateway && IP_COMPARE(ip, gateway))
1369 {
1370 if (ip->type == 4)
1371 {
1372 mask = STR_TO_IP4("0.0.0.0");
1373 dest = STR_TO_IP4("0.0.0.0");
1374 }
1375 else if (ip->type == 6)
1376 {
1377 pre = 0;
1378 dest = STR_TO_IP6("0:0:0:0:0:0:0:0");
1379 }
1381 dest,
1382 mask,
1383 pre,
1384 gateway,
1385 1,
1386 &ip,
1387 &i,
1389 "DEFAULT");
1390 devVar->nGatewayCount++;
1391 devVar->GatewayIPAddress = realloc(devVar->GatewayIPAddress, devVar->nGatewayCount*(sizeof* devVar->GatewayIPAddress));
1392 devVar->GatewayIPAddress[devVar->nGatewayCount - 1] = gateway;
1393 devVar->nGatewayState = realloc(devVar->nGatewayState, devVar->nGatewayCount*(sizeof* devVar->nGatewayState));
1394 devVar->nGatewayState[devVar->nGatewayCount - 1] = GATEWAYSTATE_UP;
1395 devVar->nInterfaceId = realloc(devVar->nInterfaceId, devVar->nGatewayCount*(sizeof* devVar->nInterfaceId));
1396 devVar->nInterfaceId[devVar->nGatewayCount - 1] = i;
1397 }
1398 if (DEVICE_INTERFACE(d, i)->nInterfaceType != INTERFACE_WAN_ROUTER)
1399 {
1400 if (ip->type == 4)
1401 {
1402 mask = STR_TO_IP4("255.255.255.255");
1403 dest = STR_TO_IP4("255.255.255.255");
1404 pre = 0;
1405 }
1406 else if (ip->type == 6)
1407 {
1408 dest = STR_TO_IP6("FF00:0:0:0:0:0:0:0");
1409 mask = NULL;
1410 pre = 8;
1411 }
1412 gate = on_link;
1414 dest,
1415 mask,
1416 pre,
1417 gate,
1418 1,
1419 &ip,
1420 &i,
1422 "BROADCAST");
1423 }
1424
1425 //Add entry for Multicast
1426 if (ip->type == 4)
1427 {
1428 mask = STR_TO_IP4("240.0.0.0");
1429 dest = STR_TO_IP4("224.0.0.0");
1430 pre = 0;
1431 }
1432 else if (ip->type == 6)
1433 {
1434 dest = STR_TO_IP6("FFX2:0:0:0:0:0:0:0");
1435 mask = NULL;
1436 pre = 16;
1437 }
1438 gate = on_link;
1440 dest,
1441 mask,
1442 pre,
1443 gate,
1444 1,
1445 &ip,
1446 &i,
1448 "MULTICAST");
1449
1450 if (ip->type == 4)
1451 {
1452 mask = STR_TO_IP4("255.255.255.255");
1453 dest = STR_TO_IP4("224.0.0.1");
1454 pre = 0;
1455 }
1456 else if (ip->type == 6)
1457 {
1458 dest = STR_TO_IP6("FFX2:0:0:0:0:0:0:1");
1459 mask = NULL;
1460 pre = 128;
1461 }
1462 gate = on_link;
1464 dest,
1465 mask,
1466 pre,
1467 gate,
1468 1,
1469 &ip,
1470 &i,
1472 "MULTICAST");
1473 }
1474}
1475
1477 NETSIM_ID d,
1478 NETSIM_ID i,
1479 double time)
1480{
1482 return; //PCAP writer is not available
1483
1484 if (DEVICE_MACLAYER(d, i)->isWiresharkWriter)
1485 return; //PCAP writer is handled by mac layer
1486
1488 wireshark_trace.pcapWriterlist[d - 1][i - 1],
1489 time);
1490}
1491
1493{
1495
1496 memset(&pe, 0, sizeof pe);
1497 pe.nDeviceId = d;
1498 pe.nDeviceType = DEVICE_TYPE(d);
1502 fnpAddEvent(&pe);
1503}
1504
1505static void init_ip_anim()
1506{
1508 ANIM_HANDLE chandle;
1509 handle = anim_add_new_menu(NULL, "IP Table", false, false, false, 0, ANIMFILETYPE_TABLE);
1510 NETSIM_ID i;
1511 for (i = 0; i < NETWORK->nDeviceCount; i++)
1512 {
1513 if (DEVICE_NWLAYER(i + 1))
1514 {
1515 chandle = anim_add_new_menu(handle,
1516 DEVICE_NAME(i + 1),
1517 false,
1518 true,
1519 true,
1520 0,
1522 DEVICE_NWLAYER(i + 1)->ipWrapper->handle = chandle;
1523 init_event_to_write(i + 1);
1524 }
1525 }
1526}
@ ANIMFILETYPE_TABLE
Definition: Animation.h:64
void * ANIM_HANDLE
Definition: Animation.h:52
unsigned int NETSIM_ID
Definition: Animation.h:45
ANIM_HANDLE anim_add_new_menu(ANIM_HANDLE handle, char *name, bool isThreadReq, bool isNewScreen, bool isFile, UINT maxDataLen, ANIMFILETYPE fileType)
static ANIM_HANDLE handle
Definition: BatteryModel.c:197
NETSIM_IPAddress dns_query(NETSIM_ID nDeviceId, NETSIM_ID id)
Definition: DNS.c:42
@ ACLACTION_DENY
Definition: Firewall.h:34
@ ACLTYPE_INBOUND
Definition: Firewall.h:27
void process_icmp_packet()
Definition: ICMP.c:533
void ICMP_copyPacket(NetSim_PACKET *d, NetSim_PACKET *s)
Definition: ICMP.c:518
void icmp_send_echo_request()
Definition: ICMP.c:668
void igmp_configure(NETSIM_ID d, void *xmlNode)
Definition: IGMP.c:43
void igmp_free(NETSIM_ID d)
Definition: IGMP.c:164
void igmp_init(NETSIM_ID d)
Definition: IGMP.c:141
void host_send_report()
Definition: IGMP_Host.c:119
void host_handle_unsolicited_report_timer()
Definition: IGMP_Host.c:183
void IGMP_FreePacket(NetSim_PACKET *packet)
Definition: IGMP_Msg.c:81
void process_igmp_packet()
Definition: IGMP_Msg.c:195
void send_query_msg(NETSIM_ID d, NETSIM_IPAddress group, double time)
Definition: IGMP_Msg.c:233
void copy_igmp_packet(NetSim_PACKET *d, NetSim_PACKET *s)
Definition: IGMP_Msg.c:77
void igmp_router_processOtherQuerierPresentTime()
Definition: IGMP_Router.c:239
void igmp_router_ProcessGroupMembershipTimer()
Definition: IGMP_Router.c:307
void configure_static_ip_route(NETSIM_ID d, char *file)
Definition: IP_Routing.c:420
int fn_NetSim_IP_ICMP_GenerateDstUnreachableMsg()
#define QUEUING_MEDIUM_MAX_TH_MB_DEFAULT
Definition: IP.c:667
int fn_NetSim_IP_Init(struct stru_NetSim_Network *NETWORK_Formal, NetSim_EVENTDETAILS *pstruEventDetails_Formal, char *pszAppPath_Formal, char *pszWritePath_Formal, int nVersion_Type, void **fnPointer)
Definition: IP.c:90
static void init_ip_anim()
Definition: IP.c:1505
static void ip_scheduling_read_config(NETSIM_ID d, NETSIM_ID in, void *xmlNetSimNode)
Definition: IP.c:764
#define QUEUING_LOW_MAX_TH_MB_DEFAULT
Definition: IP.c:665
static void ip_handle_processing_delay()
Definition: IP.c:182
#define SCHEDULING_MAX_LATENCY_rtPS_MS_DEFAULT
Definition: IP.c:680
int fn_NetSim_IP_VPN_Init()
Definition: VPN.c:25
int IP_packetTraceFiledFlag[4]
Definition: IP.c:1178
static void add_default_ip_table_entry(NETSIM_ID d)
Definition: IP.c:1332
#define QUEUING_NORMAL_MAX_TH_MB_DEFAULT
Definition: IP.c:666
int fn_NetSim_IP_CopyPacket(NetSim_PACKET *pstruDestPacket, NetSim_PACKET *pstruSrcPacket)
Definition: IP.c:1048
char * fn_NetSim_IP_Trace(NETSIM_ID nSubeventid)
Definition: IP.c:619
#define QUEUING_HIGH_MAX_TH_MB_DEFAULT
Definition: IP.c:668
#define SCHEDULING_MAX_LATENCY_UGS_MS_DEFAULT
Definition: IP.c:679
static void ip_queuing_read_config(NETSIM_ID d, NETSIM_ID in, void *xmlNetSimNode)
Definition: IP.c:685
#define QUEUING_HIGH_MIN_TH_MB_DEFAULT
Definition: IP.c:672
#define SCHEDULING_MAX_LATENCY_nrtPS_MS_DEFAULT
Definition: IP.c:682
#define QUEUING_MAX_TH_MB_DEFAULT
Definition: IP.c:659
int fn_NetSim_IP_Metrics(PMETRICSWRITER metricsWriter)
Definition: IP.c:1066
static void init_event_to_write(NETSIM_ID d)
Definition: IP.c:1492
int fn_NetSim_IP_ICMP_EchoReply()
int fn_NetSim_IP_FreePacket(NetSim_PACKET *pstruPacket)
Definition: IP.c:1031
int fn_NetSim_IP_ConfigStaticIPTable(char *szVal)
static IP_PROTOCOL_ACTION decide_action_for_packet(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP.c:57
char pszTrace[BUFSIZ]
Definition: IP.c:1179
#define QUEUING_MIN_TH_MB_DEFAULT
Definition: IP.c:660
void ip_write_to_pcap(NetSim_PACKET *packet, NETSIM_ID d, NETSIM_ID i, double time)
Definition: IP.c:1476
int fn_NetSim_IP_ICMP_POLL()
int freeDNS(void *dns)
int fn_NetSim_IP_ICMP_ProcessRouterAdvertisement()
int fn_NetSim_IP_Run()
Definition: IP.c:223
static bool isSameIPForOtherInterface(NETSIM_ID d, NETSIM_ID in)
Definition: IP.c:1298
NETWORK_LAYER_PROTOCOL fnGetLocalNetworkProtocol(NetSim_EVENTDETAILS *pstruEventDetails)
Definition: IP.c:1283
#define QUEUING_MEDIUM_MIN_TH_MB_DEFAULT
Definition: IP.c:671
char * fn_NetSim_IP_ConfigPacketTrace(const void *xmlNetSimNode)
Definition: IP.c:1183
int fn_NetSim_IP_Configure(void **var)
Definition: IP.c:816
#define SCHEDULING_MAX_LATENCY_ertPS_MS_DEFAULT
Definition: IP.c:681
int freeVPN(void *vpn)
int fn_NetSim_IP_ICMP_Init()
#define QUEUING_LOW_MIN_TH_MB_DEFAULT
Definition: IP.c:669
#define SCHEDULING_MAX_LATENCY_BE_MS_DEFAULT
Definition: IP.c:683
int fn_NetSim_IP_ICMP_AdvertiseRouter()
int freeVPNPacket(void *vpnPacket)
int fn_NetSim_IP_ICMP_ProcessDestUnreachableMsg()
int fn_NetSim_IP_ICMP_EchoRequest()
void * copyVPNPacket(void *vpnPacket)
void set_public_ip(NETSIM_ID d)
Definition: IP_Utility.c:185
static ptrIP_FORWARD_ROUTE build_route(NetSim_PACKET *packet)
Definition: IP.c:154
#define QUEUING_NORMAL_MIN_TH_MB_DEFAULT
Definition: IP.c:670
int fn_NetSim_IP_Finish()
Definition: IP.c:582
int fn_NetSim_IP_WritePacketTrace(NetSim_PACKET *pstruPacket, char **ppszTrace)
Definition: IP.c:1232
IP_PROTOCOL_ACTION pim_decide_action(NetSim_PACKET *packet, NETSIM_ID d)
Definition: PIM_SM.c:139
@ GATEWAYSTATE_UP
Definition: IP.h:124
IP_PROTOCOL_ACTION
Definition: IP.h:138
@ ACTION_DROP
Definition: IP.h:139
@ ACTION_MOVEUP
Definition: IP.h:140
@ ACTION_REROUTE
Definition: IP.h:141
#define on_link
Definition: IP.h:41
#define IPV4_HEADER_SIZE
Definition: IP.h:45
void pim_configure(NETSIM_ID d, void *xmlNetSimNode)
Definition: PIM_SM.c:107
int fn_NetSim_NAT_NetworkIn(NETSIM_ID ndev, NetSim_PACKET *packet)
Definition: NAT.c:116
#define IP_PROCESSING_DELAY_DEFAULT
Definition: IP.h:39
#define GET_IP_DEVVAR(d)
Definition: IP.h:49
IP_PROTOCOL_ACTION check_ip_in_multicastgroup(NETSIM_IPAddress ip, NETSIM_ID d, NetSim_PACKET *packet)
ptrIP_FORWARD_ROUTE fn_NetSim_IP_RoutePacketViaStaticEntry(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:558
ptrIP_FORWARD_ROUTE fn_NetSim_IP_RoutePacket(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:371
void process_pim_packet()
Definition: PIM_SM.c:149
void free_ip_route(ptrIP_FORWARD_ROUTE route)
Definition: IP_Routing.c:157
ptrIP_ROUTINGTABLE iptable_add(ptrIP_WRAPPER wrapper, NETSIM_IPAddress dest, NETSIM_IPAddress subnet, unsigned int prefix_len, NETSIM_IPAddress gateway, UINT interfaceCount, NETSIM_IPAddress *interfaceIp, NETSIM_ID *interfaceId, unsigned int metric, char *type)
@ EVENT_PIM_JT
Definition: IP.h:108
@ EVENT_IGMP_SendQuery
Definition: IP.h:100
@ EVENT_PIM_NEIGHBOR_TIMEOUT
Definition: IP.h:107
@ EVENT_PIM_ET
Definition: IP.h:109
@ EVENT_ADVERTISE_ROUTER
Definition: IP.h:95
@ EVENT_IP_PROCESSING_DELAY
Definition: IP.h:117
@ EVENT_IGMP_OtherQuerierPresentTimer
Definition: IP.h:101
@ EVENT_IGMP_DelayTimer
Definition: IP.h:102
@ EVENT_ICMP_POLL
Definition: IP.h:94
@ EVENT_IGMP_SendStartupQuery
Definition: IP.h:99
@ EVENT_IGMP_GroupMembershipTimer
Definition: IP.h:103
@ EVENT_IGMP_Unsolicited_report
Definition: IP.h:98
@ EVENT_IP_INIT_TABLE
Definition: IP.h:111
@ EVENT_ICMP_SEND_ECHO
Definition: IP.h:114
@ EVENT_PIM_SEND_HELLO
Definition: IP.h:106
struct stru_IP_Metrics ** ipMetrics
Definition: IP.h:291
void Router_PIM_Init(NETSIM_ID d)
Definition: PIM_SM.c:67
@ VPN_CLIENT
Definition: IP.h:134
@ VPN_SERVER
Definition: IP.h:133
@ VPN_DISABLE
Definition: IP.h:132
#define DEFAULT_METRIC
Definition: IP.h:42
@ RoutingType_DEFAULT
Definition: IP.h:56
@ RoutingType_STATIC
Definition: IP.h:57
#define MULTICAST_METRIC
Definition: IP.h:44
@ PACKET_VPN
Definition: IP.h:70
#define ONLINK_METRIC
Definition: IP.h:43
int fn_NetSim_IP_VPN_Run()
Definition: VPN.c:212
void pim_handle_timer_event()
Definition: PIM_SM.c:187
void multicast_join_group()
void pass_to_lower_layer(NetSim_PACKET *packet, ptrIP_FORWARD_ROUTE route, UINT c)
Definition: IP_Routing.c:568
int fn_NetSim_NAT_NetworkOut(NETSIM_ID ndev, NetSim_PACKET *packet)
Definition: NAT.c:47
#define _NETSIM_IP_LEN
Definition: IP_Addressing.h:29
#define IP_TO_STR(ip, ipstr)
Definition: IP_Addressing.h:71
#define STR_TO_IP6(ipstr)
Definition: IP_Addressing.h:95
NETSIM_IPAddress STR_TO_IP(char *ipStr, int type)
bool isBroadcastIP(NETSIM_IPAddress ip)
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 STR_TO_IP4(ipstr)
Definition: IP_Addressing.h:94
int IP_IS_IN_SAME_NETWORK(NETSIM_IPAddress ip1, NETSIM_IPAddress ip2, NETSIM_IPAddress subnet, unsigned int prefix_len)
bool isMulticastIP(NETSIM_IPAddress ip)
char * _strupr(char *s)
#define _stricmp
Definition: Linux.h:127
#define UINT
Definition: Linux.h:38
#define _declspec(dllexport)
This function is used to trigger the update.
Definition: Linux.h:41
#define fnNetSimError(x,...)
Definition: Linux.h:56
#define LIST_NEXT(ls)
Definition: List.h:29
#define LIST_FREE(ls, mem)
Definition: List.h:32
#define realloc(p, s)
Definition: Memory.h:32
#define free(p)
Definition: Memory.h:31
#define calloc(c, s)
Definition: Memory.h:29
@ WriterPosition_Current
Definition: MetricsWriter.h:15
void write_metrics_node(PMETRICSWRITER writer, WRITER_POSITION writerPosition, char *writer_name, PMETRICSNODE node)
PMETRICSNODE init_metrics_node(METRICS_NODE type, char *name, char *secondarg)
void * PMETRICSNODE
Definition: MetricsWriter.h:21
void * PMETRICSWRITER
Definition: MetricsWriter.h:27
void add_table_heading(PMETRICSNODE node, char *name, bool isShow, int subheadingcount,...)
void delete_metrics_node(PMETRICSNODE node)
void add_node_to_menu(PMETRICSNODE menu, PMETRICSNODE node)
void add_table_row_formatted(bool issame, PMETRICSNODE node, char *format,...)
@ MetricsNode_Menu
Definition: MetricsWriter.h:5
@ MetricsNode_Table
Definition: MetricsWriter.h:6
NETSIM_UTILITY_EXPORT WIRESHARKTRACE wireshark_trace
bool fn_NetSim_GetBufferStatus(NetSim_BUFFER *pstruBuffer)
Definition: Scheduling.c:41
IP_PROTOCOL_NUMBER
Definition: Packet.h:125
@ IPPROTOCOL_ICMP
Definition: Packet.h:127
@ IPPROTOCOL_UDP
Definition: Packet.h:130
@ IPPROTOCOL_PIM
Definition: Packet.h:133
@ IPPROTOCOL_IGMP
Definition: Packet.h:128
@ IPPROTOCOL_DSR
Definition: Packet.h:131
@ IPPROTOCOL_TCP
Definition: Packet.h:129
bool isDestFoundinPacket(NetSim_PACKET *packet, NETSIM_ID dest)
@ PacketStatus_TTL_Expired
Definition: Packet.h:105
int fnCallProtocol(int nProtocol)
NetSim_EVENTDETAILS * pstruEventDetails_Formal
Definition: RIP.h:178
NetSim_EVENTDETAILS char * pszAppPath_Formal
Definition: RIP.h:178
NetSim_EVENTDETAILS char char int nVersion_Type
Definition: RIP.h:178
NetSim_EVENTDETAILS char char * pszWritePath_Formal
Definition: RIP.h:178
NetSim_EVENTDETAILS char char int void ** fnPointer
Definition: RIP.h:178
NETSIM_ID fn_NetSim_Stack_GetConfigIdOfDeviceById(NETSIM_ID nDeviceId)
@ SUBEVENT_JOIN_MULTICAST_GROUP
Definition: Stack.h:121
#define DEVICE(DeviceId)
Definition: Stack.h:769
EXPORTED fndns_query fnDNS
Definition: Stack.h:1016
char * fn_NetSim_xmlConfigPacketTraceField(const void *xmlNetSimNode, const char *name)
#define DEVICE_NAME(DeviceId)
Definition: Stack.h:774
@ SCHEDULING_ROUNDROBIN
Definition: Stack.h:347
@ SCHEDULING_EDF
Definition: Stack.h:349
@ SCHEDULING_PRIORITY
Definition: Stack.h:346
@ SCHEDULING_WFQ
Definition: Stack.h:348
@ SCHEDULING_NONE
Definition: Stack.h:344
@ SCHEDULING_FIFO
Definition: Stack.h:345
#define DEVICE_MACLAYER(DeviceId, InterfaceId)
Definition: Stack.h:786
char * fn_NetSim_xmlConfig_GetVal(void *xmlNetSimNode, const char *szName, int flag)
#define getXmlVar(var, name, xmlNode, flag, type, protocol)
Definition: Stack.h:1046
#define DEVICE_TYPE(DeviceId)
Definition: Stack.h:773
#define DEVICE_NWADDRESS(DeviceId, InterfaceId)
Definition: Stack.h:805
@ _BOOL
Definition: Stack.h:1034
@ _STRING
Definition: Stack.h:1033
@ _DOUBLE
Definition: Stack.h:1031
@ NW_PROTOCOL_ARP
Definition: Stack.h:191
@ NW_PROTOCOL_IPV6
Definition: Stack.h:190
@ NW_PROTOCOL_IPV4
Definition: Stack.h:189
@ QUEUING_DROPTAIL
Definition: Stack.h:356
@ QUEUING_RED
Definition: Stack.h:357
@ QUEUING_NULL
Definition: Stack.h:355
@ QUEUING_WRED
Definition: Stack.h:358
@ TX_PROTOCOL_UDP
Definition: Stack.h:181
@ TX_PROTOCOL_TCP
Definition: Stack.h:180
@ TX_PROTOCOL_NULL
Definition: Stack.h:179
bool isHost(NETSIM_ID d)
MAC_LAYER_PROTOCOL fn_NetSim_Stack_GetMacProtocol(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
EXPORTED struct stru_NetSim_Network * NETWORK
Definition: Stack.h:742
@ NETWORK_OUT_EVENT
Definition: Stack.h:108
@ TIMER_EVENT
Definition: Stack.h:114
@ NETWORK_IN_EVENT
Definition: Stack.h:109
@ TRANSPORT_IN_EVENT
Definition: Stack.h:111
@ MAC_OUT_EVENT
Definition: Stack.h:106
#define DEVICE_ACCESSBUFFER(DeviceId, InterfaceId)
Definition: Stack.h:794
double fn_NetSim_Config_read_dataLen(void *xmlNetSimNode, const char *name, double defaultDataLen, const char *returnUnit)
#define DEVICE_NWLAYER(DeviceId)
Definition: Stack.h:785
double fn_NetSim_Config_read_time(void *xmlNetSimNode, const char *name, double defaultTime, const char *returnUnit)
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define NETSIM_RAND_01()
Definition: Stack.h:860
#define DEVICE_INTERFACE(DeviceId, InterfaceId)
Definition: Stack.h:780
@ INTERFACE_WAN_ROUTER
Definition: Stack.h:254
#define IP_WRAPPER_GET(DeviceId)
Definition: Stack.h:801
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asIP(NETSIM_IPAddress ip, NETSIM_ID *nInterfaceId)
#define IP_TABLE_GET(DeviceId)
Definition: Stack.h:802
PMETRICSNODE menu
Definition: SwitchTable.c:48
void IP(uint state[], uchar in[])
Definition: des.c:116
int fn_NetSim_FirewallConfig(NETSIM_ID nDeviceId)
Definition: firewall.c:235
ACL_ACTION fn_NetSim_NETWORK_Firewall(NETSIM_ID nDeviceId, NETSIM_ID interfaceId, NetSim_PACKET *packet, ACL_TYPE type)
Definition: firewall.c:333
void fn_NetSim_Firewall_Free(NETSIM_ID d)
Definition: firewall.c:338
#define fn_NetSim_Packet_CopyPacket(pstruPacket)
Definition: main.h:182
enum enum_LayerType LAYER_TYPE
Definition: main.h:136
#define VERSION
Definition: main.h:84
#define fn_NetSim_Packet_FreePacket(pstruPacket)
Definition: main.h:177
#define fn_NetSim_WritePacketTrace(pstruPacket)
Definition: main.h:188
enum enum_NWProtocol NETWORK_LAYER_PROTOCOL
Definition: main.h:133
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
enum enum_TrxProtocol TRANSPORT_LAYER_PROTOCOL
Definition: main.h:132
#define fn_NetSim_Packet_AddPacketToList(pstruBuffer, pstruPacket, nInsertionType)
Definition: main.h:179
UINT count
Definition: IP.h:146
NETSIM_IPAddress * nextHop
Definition: IP.h:147
NETSIM_ID * nextHopId
Definition: IP.h:150
NETSIM_IPAddress * gateway
Definition: IP.h:148
NETSIM_ID * interfaceId
Definition: IP.h:149
Structure to store the device ip details.
Definition: IP.h:226
NETSIM_IPAddress ipPoolEnd
Definition: IP.h:258
NETSIM_IPAddress * GatewayIPAddress
Definition: IP.h:245
NETSIM_IPAddress ipPoolStart
Definition: IP.h:257
unsigned int nRouterAdverLifeTime
Definition: IP.h:241
unsigned int nRouterAdverMaxInterval
Definition: IP.h:240
bool isICMP
Definition: IP.h:236
NETSIM_IPAddress ipPoolMask
Definition: IP.h:259
IP_GATEWAYSTATE * nGatewayState
Definition: IP.h:248
NETSIM_ID * nGatewayId
Definition: IP.h:246
char * staticIPTableFile
Definition: IP.h:228
unsigned int nRouterAdvertisementFlag
Definition: IP.h:238
unsigned int nICMPPollingTime
Definition: IP.h:243
double processingDelay
Definition: IP.h:278
bool isFirewallConfigured
Definition: IP.h:232
VPN_STATE nVPNStatus
Definition: IP.h:251
bool isPIMConfigured
Definition: IP.h:274
void * vpn
Definition: IP.h:260
NETSIM_IPAddress serverIP
Definition: IP.h:255
unsigned int nRouterAdverMinInterval
Definition: IP.h:239
NETSIM_ID * nInterfaceId
Definition: IP.h:247
char * firewallConfig
Definition: IP.h:233
unsigned int nGatewayCount
Definition: IP.h:244
void * dnsList
Definition: IP.h:261
bool isIGMPConfigured
Definition: IP.h:270
unsigned int nFirewallBlocked
Definition: IP.h:288
NETSIM_ID nDeviceId
Definition: IP.h:283
unsigned int nPacketReceived
Definition: IP.h:285
unsigned int nPacketDiscarded
Definition: IP.h:287
unsigned int nPacketForwarded
Definition: IP.h:286
unsigned int nTTLDrop
Definition: IP.h:289
SCHEDULING_TYPE nSchedulingType
Definition: Stack.h:574
NETSIM_ID interfaceId
Definition: Stack.h:569
QUEUINGTECHNIQUE queuingTechnique
Definition: Stack.h:575
NETSIM_Name szDeviceName
Definition: Stack.h:713
struct stru_NetSim_NetworkLayer * pstruNetworkLayer
Definition: Stack.h:721
struct stru_NetSim_Interface ** ppstruInterfaceList
Definition: Stack.h:717
EVENT_TYPE nEventType
Definition: Stack.h:747
NETSIM_ID nProtocolId
Definition: Stack.h:748
struct stru_NetSim_Packet * pPacket
Definition: Stack.h:754
NETSIM_ID nSubEventType
Definition: Stack.h:757
NETSIM_ID nDeviceId
Definition: Stack.h:750
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:749
NETSIM_ID nInterfaceId
Definition: Stack.h:751
Structure to store ip routing table.
Definition: IP.h:157
unsigned int prefix_len
Definition: IP.h:163
NETSIM_IPAddress * Interface
Definition: IP.h:162
NETSIM_IPAddress networkDestination
Definition: IP.h:158
NETSIM_IPAddress gateway
Definition: IP.h:160
ROUTING_TYPE type
Definition: IP.h:165
unsigned int Metric
Definition: IP.h:164
NETSIM_IPAddress netMask
Definition: IP.h:159
NETWORK_LAYER_PROTOCOL nLocalNetworkProtocol
Definition: Stack.h:695
unsigned int prefix_len
Definition: Stack.h:691
NETSIM_IPAddress szSubnetMask
Definition: Stack.h:690
NETWORK_LAYER_PROTOCOL nProtocolId
Definition: Stack.h:687
NETSIM_IPAddress szDefaultGateWay
Definition: Stack.h:692
NETSIM_IPAddress szAddress
Definition: Stack.h:688
struct stru_NetSim_Device ** ppstruDeviceList
Definition: Stack.h:737
NETSIM_IPAddress szGatewayIP
Definition: Packet.h:200
IP_PROTOCOL_NUMBER IPProtocol
Definition: Packet.h:203
NETSIM_IPAddress szDestIP
Definition: Packet.h:199
NETSIM_IPAddress szNextHopIp
Definition: Packet.h:201
NETSIM_IPAddress szSourceIP
Definition: Packet.h:198
PACKET_STATUS nPacketStatus
Definition: Packet.h:272
struct stru_NetSim_Packet_NetworkLayer * pstruNetworkData
Definition: Packet.h:275
NETSIM_ID nReceiverId
Definition: Packet.h:266
unsigned int nControlDataType
Definition: Packet.h:258
NETSIM_ID nTransmitterId
Definition: Packet.h:265
struct stru_NetSim_Packet_TransportLayer * pstruTransportData
Definition: Packet.h:274
char str_ip[_NETSIM_IP_LEN]
Definition: IP_Addressing.h:54
double avg_queue_size
Definition: Scheduling.h:35
double random_value
Definition: Scheduling.h:37
double * max_th
Definition: Scheduling.h:45
double * max_p
Definition: Scheduling.h:46
double * min_th
Definition: Scheduling.h:44
double avg_queue_size
Definition: Scheduling.h:47
double * random_value
Definition: Scheduling.h:49
double * max_latency
Definition: Scheduling.h:56
PPCAP_WRITER ** pcapWriterlist
void(* convert_sim_to_real_packet)(void *netsim_packet, void *pcap_handle, double dTime)