NetSim Source Code Help
Loading...
Searching...
No Matches
Stack.h
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#ifndef _NETSIM_STACK_H_
25#define _NETSIM_STACK_H_
26#ifdef __cplusplus
27extern "C" {
28#endif
29#include "List.h"
30#include "Wireless.h"
31
32#ifdef _WIN32
33#ifdef _NETSIM_CODE_
34#define EXPORTED _declspec(dllexport)
35#else
36#define EXPORTED _declspec(dllimport)
37#endif
38#ifdef _NETSIM_METRIC_CODE_
39#undef EXPORTED
40#define EXPORTED
41#endif
42#else
43#ifdef _NETSIM_CODE_
44#define EXPORTED
45#else
46#define EXPORTED extern
47#endif
48#ifdef _NETSIM_METRIC_CODE_
49#undef EXPORTED
50#define EXPORTED
51#endif
52
53#endif
55
56//Time Definition
57#define MICROSECOND (1.0)
58#define NANOSECOND (MICROSECOND/1000.0)
59#define MILLISECOND (1000.0*MICROSECOND)
60#define SECOND (1000.0*MILLISECOND)
61#define MINUTE (60.0*SECOND)
62#define HOUR (60.0*MINUTE)
63
64
65#ifndef INFINITY
66#define INFINITY (0xFFFFFFFF)
67#endif
68#ifndef NEGATIVE_INFINITY
69#define NEGATIVE_INFINITY (-1.0*INFINITY)
70#endif
71
72
73/* Enumeration for flag*/
75{
78};
79
80typedef enum enum_sim_state
81{
87_declspec(dllexport) void netsim_set_simstate(SIMSTATE state);
89
90/* Enumeration for Layer type*/
92{
94 PHYSICAL_LAYER = 1, //Interface layer in linux
95 MAC_LAYER, //Protocol layer in linux
96 NETWORK_LAYER, //Socket layer in linux
97 TRANSPORT_LAYER, //Socket layer in linux
98 APPLICATION_LAYER, //Process layer in linux
99};
100/* Enumeration for event type*/
102{
116};
117
119{
120 SUBEVENT_GETLINKQUALITY= TIMER_EVENT*100+1, //Must be provided by link layer protocol to get link quality
130
131static char subeventName[SUBEVNET_LAST][100] = { "GET_LINK_QUALITY",
132"JOIN_MULTICAST_GROUP",
133"LINKUP",
134"LINKDOWN",
135"HWIRECV",
136"HWI_CLEANUP",
137"PAUSE_SIMULATION",
138"EXECUTE_COMMAND"};
139
140///Internal module
141#define PROTOCOL_METRICS 2
142#define PROTOCOL_MOBILITY 3
143#define PROTOCOL_APPLICATION 4
144#define PROTOCOL_LINK 5
145#define PROTOCOL_HWI 6
146#define PROTOCOL_CLI 7
147
148/* Enumeration for Application layer protocol*/
150{
152
153 // Routing protocol
156
157 //Application
160
161 //Traffic
174};
175
176/* Enumeration for transport layer protocol*/
178{
182 TX_PROTOCOL_WSMP, //IEEE1609.3
183};
184
185/* Enumeration for network layer protocol*/
187{
188 /* IP protocol*/
194
195 /* Routing Protocol*/
200 NW_PROTOCOL_RPL, //RFC 6550
201};
202
203/* Enumeration for MAC layer protocol*/
205{
207 /***WIRELESS***/
210 MAC_PROTOCOL_IEEE802_22, //Cognitive Radio
211
212 /***WIRED***/
214 MAC_PROTOCOL_P2P, //Point to point link
215
216 /***Cellular Protocol***/
220 MAC_PROTOCOL_LTE_NR, //LTE-NR (5G)
221
222 /***/
224 MAC_PROTOCOL_DTDMA, //Dynamic TDMA
225
229
230 MAC_PROTOCOL_IEEE1609, //IEEE 1609, WAVE, VANET
231
232 MAC_PROTOCOL_UWAN, // Underwater acoutics network. Not really a protocol
233
234 MAC_PROTOCOL_SATELLITE, // Satellite network, Not really a protocol
235};
236
237
238/*Enumeration for physical medium type. Must be compatible with MAC layer*/
240{
244};
245
246/*Enumeration for interface type. Must be compatible with network layer, MAC layer and physical medium*/
248{
253 INTERFACE_LAN_802_22, //Cognitive radio
255 INTERFACE_VIRTUAL, //Virtual interface
256 INTERFACE_GSM, //GSM Interface
257 INTERFACE_CDMA, //CDMA Interface
258 INTERFACE_LTE, //LTE Interface
259 INTERFACE_LTE_NR, //LTE-NR Interface
261 INTERFACE_ALOHA, // Aloha Interface
262 INTERFACE_TOKEN_RING, //Token ring interface
263 INTERFACE_TOKEN_BUS, //Token bus interface
264 INTERFACE_IEEE1609, // WAVE, VANET Interface
265 INTERFACE_P2P, // Point to Point Interface
266};
267
268/* Enumeration for device type*/
270{
272 /* Node 5-layer device */
273 NODE=1, //Wired or wireless
274 CPE=1, //Wired
275 MOBILESTATION=1,//Wireless
276 UE=1, //Wireless LTE user equipment
277 SENSOR=1, //Wireless
278 RSU=1, //Road side Unit, wireless
279 SATELLITE_UT=1, //Satellite user terminal
280
281 /***Intermediate Device***/
282 /* 2-layer device*/
283 SWITCH=2, //Wired
284 SATELLITE = 2, //Satellite
285 HUB=3, //Wired
287 BASESTATION=4, //Wireless
288 eNB=4, //Wireless LTE base station
289 gNB=4, //Wireless LTE-NR base station
290 ACCESSPOINT=5, //Wireless
291
292 /*5-Layer routing device*/
293 ROUTER=6, //Wired and/or wireless
294 MME=6, //LTE Mobile management entity
295 HNB_GATEWAY=6, //LTE Femtocell Gateway
296 EPC=6, //Evolved Packet Core (LTE, LTE-NR)
297 SINKNODE = 6, //Wireless
298 PANCOORDINATOR = 6, //Wireless
299 SATELLITE_GW=6, //Satellite gateway
300
301 /* 5 layer device without routing or switching protocol*/
305
306 MSC=8, //Mobile Switching center
307
308 RELAY = 9, //Phy layer device
309};
310
311/* Enumeration for link type */
313{
315 LinkType_P2P=1, //Point to point
316 LinkType_P2MP=2,//Point to multipoint
317 LinkType_MP2MP=3,//multipoint to multipoint
318};
319
320/* Enumeration for link state */
322{
325};
326
327/* Enumerator for link mode */
329{
333};
334
335/* Enumeration for Simulation exit type*/
337{
338 SimEndType_TIME=1, //End simulation after specified time
339};
340
341/*Enumeration for scheduling type*/
343{
351};
352
354{
360
362{
366};
367
368/* enumeration for wireshark option */
370{
374};
375
376/*enumeration for Node action */
377typedef enum enum_NodeAction
378{
384
385/* Structure of mac address*/
386typedef struct stru_macaddress
387{
388 unsigned long long int nmacaddress;
389 char szmacaddress[13];
390 char szBinary[50];
392
394
395#ifndef M_PI
396#define M_PI 3.14159265358979323846
397#endif
398#define DegreesToRadians(degree) ((degree) * (M_PI / 180.0))
399#define RadiansToDegrees(radian) ((radian) * (180.0 / M_PI))
400
401/*Coordinate of point in 3-d space*/
403{
407
408 REFERENCEELLIPSOID_COUNT, //keep me at last
410
411typedef enum enum_corrType
412{
417
419{
421
422 //Map or geo
423 double lat;
424 double lon;
425
426 //Geo
427 double altitude;
429
430 //Cartesian
431 double X;
432 double Y;
433 double Z;
434};
435//Used to convert Lat/Lon to X,Y,Z
436_declspec(dllexport) void fn_NetSim_Coordinate_ConvertMapToCartesian(double lat, double lon, NetSim_COORDINATES* pos);
438
439_declspec(dllexport) void fn_NetSim_Coordinate_ConvertGeoToCartesian(double lat, double lon,
440 double altitude, char* strRefEllipsoid,
441 NetSim_COORDINATES* pos);
443 GEOCORR_REFERENCEELLIPSOID refEllipsoid);
444
445/*Store the simulation parameter*/
447{
449 double dVal; //Value at which simulation end occurs for a particular simulation end type.
450 //For example Time = 100000 Sec.
451};
452
453/* Socket Interface*/
455{
466 int appProtocol,
468 UINT16 localPort,
469 UINT16 remotePort);
473 UINT16 localPort,
474 UINT16 remotePort);
476 NetSim_PACKET* packet,
477 ptrSOCKETINTERFACE socketInterface);
478
479
480/* Stores the application layer of device*/
482{
483 LAYER_TYPE nLayerType; //Layer type
485 UINT* nAppProtocol; //Application layer protocol list
486 void** appVar; //Application protocol variable
487};
489 UINT appProtocol);
491 UINT appProtocol);
493 UINT appProtocol,
494 void* data);
497 int moveFlag);
498
499/* Stores the transport layer of device*/
501{
502 unsigned int isTCP:1; //Flag to enable or disable TCP
503 unsigned int isUDP:1; //Flag to enable or disable UDP;
505 LAYER_TYPE nLayerType; //Layer type
506 double dMSS; //Updated by tx layer protocol
507 void* TCPVar; //Pointer for TCP variable
508 void* UDPVar;//Pointer for UDP variable
509 void* TransportProtocolVar; //Pointer to transport layer protocol
510};
511
512typedef struct stru_ip_wrapper
513{
514 bool isInit;
515 void* handle; //Animation handle
516 void* table; //IP routing tables
518
519/*Stores the network layer of device*/
521{
522 LAYER_TYPE nLayerType; //Layer type
524 void* RoutingVar; //Routing variable
525 int (*routerFunction)(); //Routing function used by app layer routing protocol
526 // like RIP, OSPF
528 void* ipVar; //IP configuration variable
530};
531
532/*Stores the MAC layer of device*/
534{
535 LAYER_TYPE nLayerType; //Layer type
537 PNETSIM_MACADDRESS szMacAddress; //MAC address of the device
539 double dFragmentSize; //Updated by mac layer protocol
540 void* MacVar; //MAC protocol variable
541};
542
543/*Stores the physical layer of device*/
545{
546 LAYER_TYPE nLayerType; //Layer type
547 PHYSICAL_LAYER_MEDIUM nPhyMedium; //Physical medium type. Must be compatible with mac layer
548 NETSIM_ID nLinkId; //Connected link id
549 struct stru_NetSim_Links* pstruNetSimLinks; //Pointer to connected link
550 void* phyVar; //Phy layer variable
551 double dLastPacketEndTime; //Last packet end time
552
553 union
554 {
555 //For wireless
557 //For Wired
558 struct
559 {
563};
564
565/* Stores the buffer information of device*/
567{
570
571 double dMaxBufferSize; //Max buffer size in bytes
572 double dCurrentBufferSize; //Current buffer size in bytes
573
576
581
582 unsigned int nQueuedPacket;
583 unsigned int nDequeuedPacket;
584 unsigned int nDroppedPacket;
585 struct stru_NetSim_Packet* pstruPacketlist; //Packet list
587};
588
589/* Stores the MAC-NW interface of device*/
591{
593};
594
595/* structure for node join profile */
597{
599 double time;
603#define JOIN_PROFILE_ALLOC() (PNODE_JOIN_PROFILE)list_alloc(sizeof(NODE_JOIN_PROFILE),offsetof(NODE_JOIN_PROFILE,ele))
604#define JOIN_PROFILE_NEXT(profile) profile=(PNODE_JOIN_PROFILE)LIST_NEXT(profile)
605#define JOIN_PROFILE_ADD(lprofile,profile) LIST_ADD_LAST((void**)lprofile,profile)
606
607/* stores the links information*/
609{
610 NETSIM_ID nConfigLinkId; //Link id setted in config file
616 {
618 {
619 double dDistance;
628 {
635 {
637 {
644 {
645 NETSIM_ID nConnectedDeviceCount;//Count of connected device through this wireless link
648 NETSIM_ID* anDevIds; //List of all the device belong to this wireless medium
652 {
653 NETSIM_ID nConnectedDeviceCount;//Count of connected device through this wireless link
654 NETSIM_ID* anDevIds; //List of all the device belong to this shared medium
660 {
662 unsigned int nLinkUpCount;
663 double* dLinkUPTime;
664 unsigned int nLinkDownCount;
670};
671
672/*Stores the interface information of device*/
674{
675 NETSIM_ID nInterfaceId; //Interface id. Unique for each interface for a device.
679
680 //For virtual interface
686
688 NETSIM_IPAddress szAddress; //IP address of the interface
690 NETSIM_IPAddress szSubnetMask; //Subnet mask of the interface in case of IPV4
691 unsigned int prefix_len; //Prefix length in case of IPV6
693 void* ipVar;
694 void* interfaceVar; //Variable used to store the common interface variable.
697 struct stru_NetSim_Access_Interface* pstruAccessInterface; //Network-MAC interface
698 struct stru_NetSim_MacLayer* pstruMACLayer; //MAC layer of interface
699 struct stru_NetSim_PhysicalLayer* pstruPhysicalLayer; //Physical layer of interface
702};
704
705#define SEED_COUNT 2
706/* Stores the device information in network*/
708{
709 NETSIM_ID nConfigDeviceId; //Device id setted in the config file
710 NETSIM_ID nDeviceId; //Unique id for all type of device. Auto assigned by backend.This is mapped to device name from front end
713 NETSIM_Name szDeviceName; //Name of the device in GUI
714 NETSIM_ID nNumOfInterface; //Number of interface in device
715 unsigned long ulSeed[SEED_COUNT];//Unique seed
716 void* deviceVar; //Variable used to store to device specific variable. Common for all interface
718 struct stru_NetSim_ApplicationLayer* pstruApplicationLayer;//Application layer of device
719 ptrSOCKETINTERFACE pstruSocketInterface; // Socket interface of device
720 struct stru_NetSim_TransportLayer* pstruTransportLayer; //Transport layer of device
721 struct stru_NetSim_NetworkLayer* pstruNetworkLayer; //Network layer of device
722 struct stru_NetSim_Coordinates* pstruDevicePosition; //Position of device in simulation workspace
723 struct stru_NetSim_Mobility* pstruDeviceMobility; //Mobility information of mobile device
729};
730
731/* Store the Network structure*/
733{
734 UINT nDeviceCount; //Total number of device
735 UINT nLinkCount; //Total number of links in network
736 UINT nApplicationCount; //Total number of application running
737 struct stru_NetSim_Device** ppstruDeviceList; //List of all device in network
739 void** appInfo; //Information of application. Refer ../ApplicationDll/Application.h
740 struct stru_NetSim_SimulationParameter* pstruSimulationParameter;//Simulation parameter for end type and value
741};
744{
745 unsigned long long int nEventId; //Unique id of event
746 double dEventTime; //Event time when packet is processed.
747 EVENT_TYPE nEventType; //Type of event
750 NETSIM_ID nDeviceId; //Unique id of device
751 NETSIM_ID nInterfaceId; //Unique id of interface
752 NETSIM_ID nApplicationId; //Unique id of application
753 double dPacketSize; //Packet size of current event
754 struct stru_NetSim_Packet *pPacket; //Packet for current event
755 long long int nPacketId; //Unique id for packet
757 NETSIM_ID nSubEventType; //Sub event type
758 void* szOtherDetails; //Details specific to protocol.
759 unsigned long long int nPrevEventId;
760 int line;
761 char* file;
764};
765
766/* Stack API */
767
768/*MACROS*/
769#define DEVICE(DeviceId) NETWORK->ppstruDeviceList[DeviceId-1]
770 #ifdef DEVICE_TYPE
771 #undef DEVICE_TYPE
772 #endif
773#define DEVICE_TYPE(DeviceId) DEVICE(DeviceId)->nDeviceType
774#define DEVICE_NAME(DeviceId) DEVICE(DeviceId)->szDeviceName
775#define DEVICE_VAR(DeviceId) DEVICE(DeviceId)->deviceVar
776#define DEVICE_SEED0(DeviceId) &(DEVICE(DeviceId)->ulSeed[0])
777#define DEVICE_SEED1(DeviceId) &(DEVICE(DeviceId)->ulSeed[1])
778#define DEVICE_SEED(DeviceId) DEVICE_SEED0(DeviceId),DEVICE_SEED1(DeviceId)
779#define DEVICE_CONFIGID(DeviceId) DEVICE(DeviceId)->nConfigDeviceId
780#define DEVICE_INTERFACE(DeviceId,InterfaceId) DEVICE(DeviceId)->ppstruInterfaceList[InterfaceId-1]
781#define DEVICE_INTERFACE_CONFIGID(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->nConfigInterfaceId
782#define DEVICE_APPLAYER(DeviceId) DEVICE(DeviceId)->pstruApplicationLayer
783#define DEVICE_APPVAR(DeviceId,protocolId) (fn_NetSim_Stack_GetAppProtocolData(DeviceId,protocolId))
784#define DEVICE_TRXLayer(DeviceId) DEVICE(DeviceId)->pstruTransportLayer
785#define DEVICE_NWLAYER(DeviceId) DEVICE(DeviceId)->pstruNetworkLayer
786#define DEVICE_MACLAYER(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->pstruMACLayer
787#define DEVICE_MACPROTOCOL(DeviceId,InterfaceId) DEVICE_MACLAYER(DeviceId,InterfaceId)->nMacProtocolId
788#define DEVICE_PHYLAYER(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->pstruPhysicalLayer
789#define DEVICE_LINK(DeviceId,InterfaceId) (DEVICE_PHYLAYER(DeviceId,InterfaceId)->pstruNetSimLinks)
790#define DEVICE_POSITION(DeviceId) DEVICE(DeviceId)->pstruDevicePosition
791#define DEVICE_MOBILITY(DeviceId) DEVICE(DeviceId)->pstruDeviceMobility
792#define DEVICE_SOCKETINTERFACE(DeviceId) DEVICE(DeviceId)->pstruSocketInterface
793#define DEVICE_MAC_NW_INTERFACE(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->pstruAccessInterface
794#define DEVICE_ACCESSBUFFER(DeviceId,InterfaceId) DEVICE_MAC_NW_INTERFACE(DeviceId,InterfaceId)->pstruAccessBuffer
795#define DEVICE_MYACCESSBUFFER() DEVICE_ACCESSBUFFER(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId)
796#define DEVICE_PHYMEDIUM(DeviceId,InterfaceId) DEVICE_PHYLAYER(DeviceId,InterfaceId)->nPhyMedium
797#define DEVICE_PHYVAR(DeviceId,InterfaceId) DEVICE_PHYLAYER(DeviceId,InterfaceId)->phyVar
798#define DEVICE_MACVAR(DeviceId,InterfaceId) DEVICE_MACLAYER(DeviceId,InterfaceId)->MacVar
799#define DEVICE_HWADDRESS(DeviceId,InterfaceId) DEVICE_MACLAYER(DeviceId,InterfaceId)->szMacAddress
800#define DEVICE_NWROUTINGVAR(DeviceId) DEVICE_NWLAYER(DeviceId)->RoutingVar
801#define IP_WRAPPER_GET(DeviceId) ((ptrIP_WRAPPER)(DEVICE_NWLAYER(DeviceId)->ipWrapper))
802#define IP_TABLE_GET(DeviceId) ((ptrIP_ROUTINGTABLE)(IP_WRAPPER_GET(DeviceId)->table))
803#define PIP_TABLE_GET(DeviceId) (&IP_TABLE_GET(DeviceId))
804#define DEVICE_NWPROTOCOL(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->nProtocolId
805#define DEVICE_NWADDRESS(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->szAddress
806#define DEVICE_MYIP() DEVICE_NWADDRESS(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId)
807#define DEVICE_SUBNETMASK(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->szSubnetMask
808#define DEVICE_MYMASK() DEVICE_SUBNETMASK(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId)
809#define DEVICE_PUBLICIP(DeviceId,InterfaceId) DEVICE_INTERFACE(DeviceId,InterfaceId)->publicIP
810#define DEVICE_FIRST_PUBLICIP(DeviceId) DEVICE_PUBLICIP(DeviceId,1)
811#define DEVICE_TCPVAR(DeviceId) DEVICE_TRXLayer(DeviceId)->TCPProtocol
812#define DEVICE_UDPVAR(DeviceId) DEVICE_TRXLayer(DeviceId)->UDPProtocol
813#define DEVICE_APPINFO(DeviceId) DEVICE_APPLAYER(DeviceId)->pstruApplicationInfo
814#define DEVICE_DISTANCE(d1,d2) (fn_NetSim_Utilities_CalculateDistance(DEVICE_POSITION(d1), DEVICE_POSITION(d2)))
815/* Stack API end*/
816
817/*Event API*/
818#define EVENT_TYPE(EventDetails) (EventDetails)->nEventType
819#define EVENT_TIME(EventDetails) (EventDetails)->dEventTime
820#define EVENT_DEVICETYPE(EventDetails) (EventDetails)->nDeviceType
821#define EVENT_DEVICEID(EventDetails) (EventDetails)->nDeviceId
822#define EVENT_INTERFACEID(EventDetails) (EventDetails)->nInterfaceId
823#define EVENT_APPID(EventDetails) (EventDetails)->nApplicationId
824#define EVENT_PACKETSIZE(EventDetails) (EventDetails)->dPacketSize
825#define EVENT_PACKET(EventDetails) (EventDetails)->pPacket
826#define EVENT_PACKETID(EventDetails) (EventDetails)->nPacketId
827#define EVENT_SUBEVENTTYPE(EventDetails) (EventDetails)->nSubEventType
828#define EVENT_OTHERDETAILS(EventDetails) (EventDetails)->szOtherDetails
829/*Event API End*/
830
831//Simulation kernel api
832typedef unsigned long long int (*fn_NetSim_Utilities_AddEvent)(struct stru_NetSim_EventDetails*,int,const char*); /* Add an event to event list.*/
833_declspec(dllexport) int fnDeleteEvent(unsigned long long int nEventId);
834_declspec(dllexport) void set_thread_safe_kernel(bool status);
835
836/* Stack Variable declaration*/
837EXPORTED struct stru_NetSim_EventDetails* pstruEventDetails; //Stores the event details. Only one time memory is allocated. Most used variable
838EXPORTED double ldEventTime; //Stores the current event time
839EXPORTED EVENT_TYPE nEventType; //Stores the current event type
840EXPORTED char* pszAppPath; //Stores the application path
841
842EXPORTED char* pszIOPath; //Stores the I/O path
844EXPORTED NETSIM_VERSIONTYPE nVersionType; //Stores the version type of netsim
845EXPORTED int nDbgFlag; //Stores the debug flag
846
848
849#define NETSIM_RAND_MAX (double)10000000000
850
851_declspec(dllexport) bool isHost(NETSIM_ID d);
852_declspec(dllexport) bool isRouter(NETSIM_ID d);
853_declspec(dllexport) bool isL3Device(NETSIM_ID d);
854
855//Calculate distance
857//Random Number Generator
858_declspec(dllexport) double fn_NetSim_Utilities_GenerateRandomNo(unsigned long *uSeed, unsigned long *uSeed1);
859#define NETSIM_RAND() fn_NetSim_Utilities_GenerateRandomNo(DEVICE_SEED(1))
860#define NETSIM_RAND_01() (NETSIM_RAND()/NETSIM_RAND_MAX)
861#define NETSIM_RAND_RN(max,min) (min+NETSIM_RAND_01()*(max-min))
862
863//Con cat string
864_declspec(dllexport) int fn_NetSim_Utilities_ConcatString(int num,char* arg1,const char* arg2,...);
865
866
867//Used to generate number based on distribution.
868_declspec(dllexport) int fn_NetSim_Utils_Distribution(int nDistributionType, double *fDistOut,unsigned long *uSeed, unsigned long *uSeed1,double fFirstArg,double fSecondArg);
869
870//return the device id. This function take input as device name and return the device is of the device if found else return 0.
872
873//Device Id by IP address. This function take input as IP address and return the device id and also update the interface id(passed as reference)
875
876//Device Id by Mac address. This function take the MAC address as input and return the device id and also update the interface id (Passed as reference)
878
879//Wireless interface of a device. This function takes the link id and device id as input and return the interface id of wireless port if connected else return 0.
881
882//Used to get interface id from IP address of a device.
884
885//Used to get all interface id by running mac protocol. Caller must free return value.
887
888//Used to get all interface id by interface type. Caller must free return value.
890
891/* Function used to get connection.
892 * Take four parameter
893 * 1. Device id
894 * 2. Interface id
895 * 3. pointer to connected device id
896 * 4. pointer to connected interface id
897 * return link id.
898 * Update connected device id and connected interface id.
899 * return 0 in case of no connection found.
900 */
903
904// Find the connected device interface id
906
907//Used to find the connected device interface id both ways. Return link id. Costly function to use if network size grows.
909
910//Used to remove a device from link. Call only for P2MP or MP2MP link
912
913//Used to add a device to link. Call only for P2MP or MP2MP link
915
916//Used to get the MAC protocol running on interface of a device
918//Used to get Network layer protocol running on the device
920//Used to get network layer routing protocol running on device
922
923/* Configuration API*/
924//Used to get an attributes value from an xml tag
925_declspec (dllexport) char* fn_NetSim_xmlConfig_GetVal(void* xmlNetSimNode,const char* szName,int flag);
926//Used to configure packet trace field
927_declspec (dllexport) char* fn_NetSim_xmlConfigPacketTraceField(const void* xmlNetSimNode,const char* name);
928//Used to write error log in config log file
929_declspec(dllexport) int NetSimxmlError(const char* msg, char* val, const void* xmlNetSimNode);
930
931//Used to get child node of any node
932_declspec(dllexport) void* fn_NetSim_xmlGetChildElement(void* xmlNetSimNode,const char* childName,int count);
933#define fn_NetSim_xmlGetFirstChildElement(xmlNetSimNode,childName) fn_NetSim_xmlGetChildElement(xmlNetSimNode,childName,0)
934_declspec(dllexport) void* fn_NetSim_xmlGetNextChildElement(void* xmlNetSimNode, void* prevChild);
935
936//Used to iterate over child element
937_declspec(dllexport) void fn_NetSim_xmlIterateOverChildElement(void* xmlNetSimNode, const char* childName,
938 int(*fun)(void* childNode, int argc, char* argv[]),
939 int argc,
940 char* argv[]);
941//convert string link type to enum
943//Covert string suppression model to enum
945//Convert string service type to enum
947//FConvert string device type to enum
949//Convert the string distribution to enum
950_declspec(dllexport) DISTRIBUTION fn_NetSim_Config_GetDistribution(const char* szDistribution);
951//Convert the string interface type to enum
953//convert string protocol to enum
954_declspec(dllexport) int fn_NetSim_Config_GetProtocol(const char* value);
955//Convert string propagation model to enum
961
962//Used to get the IP address from name and interface id
964//Used to get the mac address from IP address
966//used to get the IP address from MAC address
968//Used to get the first configure interface ip address of a device
970//used to get the ip address from device id and interface id
972//Used to get the first configured interface ip address of a device
974//Used to get config id of link by back-end id of link
977//Used to get config id of device by back-end id of device
979// Used to get the device id from config id
981
983
985
986//Used to get Application by config id
988//Used to get interface id by config id
990//Convert Connection medium string to enum
992//Used to configure protocol
995 LAYER_TYPE layer,
996 UINT protocol);
997/* Metrics */
998#define fn_NetSim_Metrics_Add(packet) fn_NetSim_Metrics_Add_new(packet,__LINE__,__FILE__,__FUNCTION__)
999_declspec(dllexport) void fn_NetSim_Metrics_Add_new(const NetSim_PACKET* pPacket, int line, char* file, char* function);
1000
1001#define DEFAULT_MAC_FRAGMENT_SIZE 1500 //Bytes
1002#define DEFAULT_TRX_MSS 1472 //Bytes
1003#define DEFAULT_NW_LAYER_SIZE 1480 //Bytes
1005
1006//Interlayer communication function
1007//Register call back back when an ICMP error arrive
1008_declspec(dllexport) int fn_NetSim_Stack_RegisterICMPCallback(int (*fnCallBack)(NetSim_PACKET* errPacket,NETSIM_ID nDeviceId,unsigned int nICMPErr));
1009//Called by IP layer when an ICMP error arrives
1011//Called by upper layer to get link quality from phy layer. Must be implemented by phy layer protocol
1013
1014//Function pointer called to resolve id to ip
1018
1019//Callback function for mobility. Must include Mobility.lib
1022
1023//Callback function for node join. Must include Mobility.lib
1026
1027//Xml configuration automatic reading
1028typedef enum xmlDataType
1029{
1030 _INT = 1,
1042 _RATIO, //Double in form of a/b
1043 _SPECIALBOOL, // Enable = true, Disable = false
1045_declspec(dllexport) int GetXmlVal(void* var,const char* name,void* xmlNode,int flag, XMLDATATYPE type);
1046#define getXmlVar(var,name,xmlNode,flag,type,protocol) if(!GetXmlVal(var,#name,xmlNode,flag,type)) *(var)= protocol##_##name##_DEFAULT
1047
1048//Default config property reader
1049
1050/**
1051Used to read freqency and bandwidth.
1052/param: XmlNode
1053/Param: name of variable in config file except units. Config file name must be <NAME>_<UNIT>
1054/Param: default value. Units must be same as return units
1055/Param: return unit type. Valid units are- GHz, MHz, kHz,Hz
1056*/
1057_declspec(dllexport) double fn_NetSim_Config_read_Frequency(void* xmlNetSimNode,
1058 const char* name,
1059 double defaultval,
1060 const char* returnUnit);
1061
1062/**
1063Used to read data rate.
1064/param: XmlNode
1065/Param: name of variable in config file except units. Config file name must be <NAME>_<UNIT>
1066/Param: default value. Units must be same as return units
1067/Param: return unit type. Valid units are- gbps,mbps,kbps,bps
1068*/
1069_declspec(dllexport) double fn_NetSim_Config_read_dataRate(void* xmlNetSimNode,
1070 const char* name,
1071 double defaultDataRate,
1072 const char* returnUnit);
1073
1074/**
1075Used to read data rate.
1076/param: XmlNode
1077/Param: name of variable in config file except units. Config file name must be <NAME>_<UNIT>
1078/Param: default value. Units must be same as return units
1079/Param: return unit type. Valid units are- GB,MB,KB,B,bits
1080*/
1081_declspec(dllexport) double fn_NetSim_Config_read_dataLen(void* xmlNetSimNode,
1082 const char* name,
1083 double defaultDataLen,
1084 const char* returnUnit);
1085/**
1086Used to read transmitter power.
1087/param: XmlNode
1088/Param: name of variable in config file except units. Config file name must be <NAME>_<UNIT>
1089/Param: default value. Units must be same as return units
1090/Param: return unit type. Valid units are- mW,W,dBm,dB
1091*/
1092_declspec(dllexport) double fn_NetSim_Config_read_txPower(void* xmlNetSimNode,
1093 const char* name,
1094 double defaultTxPower,
1095 const char* returnUnit);
1096
1097/**
1098Used to read time/duration.
1099/param: XmlNode
1100/Param: name of variable in config file except units. Config file name must be <NAME>_<UNIT>
1101/Param: default value. Units must be same as return units
1102/Param: return unit type. Valid units are- Hr(hour),min(minute),sec(second),ms(millisecond),us(microsecond),ns(nanosecond)
1103*/
1104_declspec(dllexport) double fn_NetSim_Config_read_time(void* xmlNetSimNode,
1105 const char* name,
1106 double defaultTime,
1107 const char* returnUnit);
1108
1109_declspec(dllexport) int fn_NetSim_Config_ConvertStrToEnum(void* xmlNode, const char* attributeName, const char** enumstr, const char* enumName, int length, bool isErrorMsg);
1110#define ConfigReadEnum(xmlNode,attriName,enumName,isErrorMsg) fn_NetSim_Config_ConvertStrToEnum(xmlNode,attriName,(const char**)str ## enumName, #enumName, sizeof(str ## enumName)/sizeof(str ## enumName ## [0]), isErrorMsg)
1111
1112//Mac address API
1118_declspec(dllexport) void MAC_FREE_ALL();
1122
1123//Stack Utility
1124_declspec(dllexport) void sim_time_to_string(double time, char* strTime/*Min 256 char*/);
1125
1126//Emulation
1127_declspec(dllexport) void set_emulation(bool isCustom,
1128 int(*load_emulation)(void* emuInterface));
1129
1130// Interface state
1131typedef int(*fun)(NETSIM_ID, NETSIM_ID, bool);
1133 NETSIM_ID in,
1134 fun foo);
1137
1138//Link failure model
1140 int(*fnLinkCallBack)(NETSIM_ID, LINK_STATE));
1141
1142//Fast emulation
1143_declspec(dllexport) bool isFastEmulation();
1144
1145//Virtual Interface
1148 bool isNwChanged, bool isMacChanged, bool isPhyChanged);
1151
1152//Progress report
1155
1156//Timer
1157_declspec(dllexport) UINT64 start_timer(NETSIM_ID d, NETSIM_ID in, UINT eventId, double time, void* data);
1158_declspec(dllexport) void cancel_timer(UINT64 eventId);
1159#ifdef __cplusplus
1160}
1161#endif
1162#endif //_NETSIM_STACK_H_
unsigned int NETSIM_ID
Definition: Animation.h:45
#define NETSIM_ID
Definition: CLIInterface.h:46
LINK_STATE
Definition: CSMACD.h:33
static char virtualInterfaceName[MAX_AC_CATEGORY][50]
struct stru_ip * NETSIM_IPAddress
Definition: IP_Addressing.h:32
#define UINT64
Definition: Linux.h:37
#define UINT
Definition: Linux.h:38
#define _declspec(dllexport)
This function is used to trigger the update.
Definition: Linux.h:41
#define UINT16
Definition: Linux.h:33
static MEDIUM medium
Definition: Medium.c:81
PATHLOSS_MODEL
SHADOW_MODEL
PROPAGATION_MODEL
PROP_MEDIUM
FADING_MODEL
void notify_interface_down(NETSIM_ID d, NETSIM_ID in)
enum_LinkMode
Definition: Stack.h:329
@ LinkMode_NULL
Definition: Stack.h:330
@ LinkMode_HalfDuplex
Definition: Stack.h:331
@ LinkMode_FullDuplex
Definition: Stack.h:332
#define PROTOCOL_APPLICATION
Definition: Stack.h:143
NETSIM_ID fn_NetSim_Stack_GetConfigIdOfDeviceById(NETSIM_ID nDeviceId)
NETSIM_IPAddress fn_NetSim_Stack_GetIPAddressByName(const NETSIM_Name szDeviceName, NETSIM_ID nInterfaceId)
enum_common_subevent
Definition: Stack.h:119
@ SUBEVENT_LINKUP
Definition: Stack.h:122
@ SUBEVNET_LAST
Definition: Stack.h:128
@ SUBEVENT_EXECUTECOMMAND
Definition: Stack.h:127
@ SUBEVENT_HWIRECV
Definition: Stack.h:124
@ SUBEVENT_LINKDOWN
Definition: Stack.h:123
@ SUBEVENT_HWI_CLEANUP
Definition: Stack.h:125
@ SUBEVENT_PAUSESIMULATION
Definition: Stack.h:126
@ SUBEVENT_GETLINKQUALITY
Definition: Stack.h:120
@ SUBEVENT_JOIN_MULTICAST_GROUP
Definition: Stack.h:121
EXPORTED double ldEventTime
Definition: Stack.h:838
struct stru_NetSim_SocketInterface * ptrSOCKETINTERFACE
int fn_NetSim_Stack_CallICMPErrorFun(NetSim_PACKET *packet, NETSIM_ID nDeviceId, unsigned int nICMPErr)
void fn_NetSim_Stack_SetAppProtocolData(NETSIM_ID deviceId, UINT appProtocol, void *data)
EXPORTED fndns_query fnDNS
Definition: Stack.h:1016
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asName(const char *name)
int fn_NetSim_Utilities_ConcatString(int num, char *arg1, const char *arg2,...)
NETSIM_ID fn_NetSim_Stack_GetWirelessInterface(NETSIM_ID nLinkId, NETSIM_ID nDevId)
void fn_NetSim_xmlIterateOverChildElement(void *xmlNetSimNode, const char *childName, int(*fun)(void *childNode, int argc, char *argv[]), int argc, char *argv[])
int fnMobilityRegisterCallBackFunction(_fnMobilityCallBack fnCallBack)
Definition: Mobility.c:590
int fn_NetSim_xmlConfigureProtocolProperty(void *xmlChildNode, NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, LAYER_TYPE nLayerType, UINT nProtocolId)
NetSim_LINKS * fn_NetSim_Stack_RemoveDeviceFromlink(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nLinkId)
struct stru_macaddress * PNETSIM_MACADDRESS
int fn_NetSim_Config_GetProtocol(const char *value)
NETSIM_ID fn_NetSim_Stack_GetConnectedDevice(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID *nConnectedDevId, NETSIM_ID *nConnectedInterfaceId)
static char subeventName[SUBEVNET_LAST][100]
Definition: Stack.h:131
NETSIM_ID fn_NetSim_Stack_GetConfigIdOfLinkById(NETSIM_ID nLinkId)
int(* _fnNodeJoinCallBack)(NETSIM_ID nDeviceId, double time, NODE_ACTION)
Definition: Stack.h:1024
NETWORK_LAYER_PROTOCOL fn_NetSim_Stack_GetNWProtocol(NETSIM_ID nDeviceId)
void fn_NetSim_Coordinate_ConvertCartesianToMap(NetSim_COORDINATES *pos)
PHYSICAL_LAYER_MEDIUM fn_NetSim_Cofig_GetConnectionMedium(char *medium)
void MAC_FREE_ALL()
NETSIM_ID fn_NetSim_GetDeviceIdByConfigId(NETSIM_ID id)
char * fn_NetSim_xmlConfigPacketTraceField(const void *xmlNetSimNode, const char *name)
EXPORTED bool isSimulationContinued
Definition: Stack.h:54
EXPORTED int nDbgFlag
Definition: Stack.h:845
PNETSIM_MACADDRESS STR_TO_MAC(char *mac)
enum enum_QueuingTechnique QUEUINGTECHNIQUE
PNETSIM_MACADDRESS multicastIP_to_Mac(NETSIM_IPAddress multicastIP)
enum_sim_state
Definition: Stack.h:81
@ SIMSTATE_PAUSED
Definition: Stack.h:83
@ SIMSTATE_RUNNING
Definition: Stack.h:84
@ SIMSTATE_NOTSTARTED
Definition: Stack.h:82
@ SIMSTATE_STOPPED
Definition: Stack.h:85
void cancel_timer(UINT64 eventId)
void MAC_FREE(PNETSIM_MACADDRESS mac)
NETSIM_ID * fn_NetSim_Stack_GetInterfaceIdbyMacProtocol(NETSIM_ID devId, MAC_LAYER_PROTOCOL protocol, unsigned int *count)
double fn_NetSim_Stack_GetMSS(const NetSim_PACKET *pPacket)
void * fn_NetSim_Stack_GetAppProtocolData(NETSIM_ID deviceId, UINT appProtocol)
double fn_NetSim_Config_read_Frequency(void *xmlNetSimNode, const char *name, double defaultval, const char *returnUnit)
void fn_NetSim_Socket_PassPacketToInterface(NETSIM_ID deviceId, NetSim_PACKET *packet, ptrSOCKETINTERFACE socketInterface)
void fn_NetSim_Coordinate_ConvertMapToCartesian(double lat, double lon, NetSim_COORDINATES *pos)
enum enum_refEllipsoid GEOCORR_REFERENCEELLIPSOID
EXPORTED EVENT_TYPE nEventType
Definition: Stack.h:839
enum_SchedulingType
Definition: Stack.h:343
@ SCHEDULING_ROUNDROBIN
Definition: Stack.h:347
@ SCHEDULING_EDF
Definition: Stack.h:349
@ SCHEDULING_CLASSBASED
Definition: Stack.h:350
@ SCHEDULING_PRIORITY
Definition: Stack.h:346
@ SCHEDULING_WFQ
Definition: Stack.h:348
@ SCHEDULING_NONE
Definition: Stack.h:344
@ SCHEDULING_FIFO
Definition: Stack.h:345
EXPORTED int wireshark_flag
Definition: Stack.h:847
int(* fun)(NETSIM_ID, NETSIM_ID, bool)
Definition: Stack.h:1131
EXPORTED char * pszIOPath
Definition: Stack.h:842
bool isVirtualInterface(NETSIM_ID d, NETSIM_ID in)
NETSIM_ID fn_NetSim_Stack_CreateVirtualInterface(NETSIM_ID deviceId, NETSIM_ID parentInterfaceId, char *virtualInterfaceName, bool isNwChanged, bool isMacChanged, bool isPhyChanged)
EXPORTED PNETSIM_MACADDRESS BROADCAST_MAC
Definition: Stack.h:393
int fn_NetSim_Utils_Distribution(int nDistributionType, double *fDistOut, unsigned long *uSeed, unsigned long *uSeed1, double fFirstArg, double fSecondArg)
enum_Flag
Definition: Stack.h:75
@ ONE
Definition: Stack.h:77
@ ZERO
Definition: Stack.h:76
struct stru_NodeJoinProfile * PNODE_JOIN_PROFILE
int fn_NetSim_Stack_RegisterICMPCallback(int(*fnCallBack)(NetSim_PACKET *errPacket, NETSIM_ID nDeviceId, unsigned int nICMPErr))
char * fn_NetSim_xmlConfig_GetVal(void *xmlNetSimNode, const char *szName, int flag)
ptrSOCKETINTERFACE fn_NetSim_Socket_CreateNewSocket(NETSIM_ID deviceId, int appProtocol, TRANSPORT_LAYER_PROTOCOL trxProtocol, UINT16 localPort, UINT16 remotePort)
NETSIM_IPAddress fn_NetSim_Stack_GetIPAddressFromMac(const PNETSIM_MACADDRESS szMacAddress)
enum_NodeAction
Definition: Stack.h:378
@ JOIN
Definition: Stack.h:381
@ CONNECTED
Definition: Stack.h:380
@ NOT_CONNECTED
Definition: Stack.h:379
@ LEAVE
Definition: Stack.h:382
SHADOW_MODEL fn_NetSim_Config_GetShadowModel(char *model)
enum_PhyMedium
Definition: Stack.h:240
@ PHY_MEDIUM_NULL
Definition: Stack.h:241
@ PHY_MEDIUM_WIRED
Definition: Stack.h:243
@ PHY_MEDIUM_WIRELESS
Definition: Stack.h:242
xmlDataType
Definition: Stack.h:1029
@ _BOOL
Definition: Stack.h:1034
@ _UINT
Definition: Stack.h:1037
@ _USHORT
Definition: Stack.h:1039
@ _SHORT
Definition: Stack.h:1036
@ _INT
Definition: Stack.h:1030
@ _STRING
Definition: Stack.h:1033
@ _CHAR
Definition: Stack.h:1035
@ _RATIO
Definition: Stack.h:1042
@ _UCHAR
Definition: Stack.h:1038
@ _DOUBLE
Definition: Stack.h:1031
@ _UINT16
Definition: Stack.h:1041
@ _UINT8
Definition: Stack.h:1040
@ _FLOAT
Definition: Stack.h:1032
@ _SPECIALBOOL
Definition: Stack.h:1043
enum_NWProtocol
Definition: Stack.h:187
@ NW_PROTOCOL_ZRP
Definition: Stack.h:198
@ NW_PROTOCOL_DSR
Definition: Stack.h:196
@ NW_PROTOCOL_ICMP
Definition: Stack.h:192
@ NW_PROTOCOL_IGMP
Definition: Stack.h:193
@ NW_PROTOCOL_ARP
Definition: Stack.h:191
@ NW_PROTOCOL_RPL
Definition: Stack.h:200
@ NW_PROTOCOL_AODV
Definition: Stack.h:197
@ NW_PROTOCOL_OLSR
Definition: Stack.h:199
@ NW_PROTOCOL_IPV6
Definition: Stack.h:190
@ NW_PROTOCOL_IPV4
Definition: Stack.h:189
NETSIM_ID fn_NetSim_Stack_FindVirtualInterface(NETSIM_ID d, NETSIM_ID parentIf, char *name)
enum_QueuingTechnique
Definition: Stack.h:354
@ QUEUING_DROPTAIL
Definition: Stack.h:356
@ QUEUING_RED
Definition: Stack.h:357
@ QUEUING_NULL
Definition: Stack.h:355
@ QUEUING_WRED
Definition: Stack.h:358
enum_DeviceType
Definition: Stack.h:270
@ MME
Definition: Stack.h:294
@ _5G_CORE_UPF
Definition: Stack.h:304
@ ACCESSPOINT
Definition: Stack.h:290
@ SATELLITE_UT
Definition: Stack.h:279
@ UE
Definition: Stack.h:276
@ CONCENTRATOR
Definition: Stack.h:286
@ _5G_CORE_SMF
Definition: Stack.h:303
@ MSC
Definition: Stack.h:306
@ SWITCH
Definition: Stack.h:283
@ NODE
Definition: Stack.h:273
@ HNB_GATEWAY
Definition: Stack.h:295
@ SENSOR
Definition: Stack.h:277
@ MOBILESTATION
Definition: Stack.h:275
@ _5G_CORE_AMF
Definition: Stack.h:302
@ SINKNODE
Definition: Stack.h:297
@ HUB
Definition: Stack.h:285
@ Not_Device
Definition: Stack.h:271
@ RELAY
Definition: Stack.h:308
@ gNB
Definition: Stack.h:289
@ BASESTATION
Definition: Stack.h:287
@ RSU
Definition: Stack.h:278
@ CPE
Definition: Stack.h:274
@ ROUTER
Definition: Stack.h:293
@ eNB
Definition: Stack.h:288
@ SATELLITE_GW
Definition: Stack.h:299
@ PANCOORDINATOR
Definition: Stack.h:298
@ SATELLITE
Definition: Stack.h:284
@ EPC
Definition: Stack.h:296
enum enum_NodeAction NODE_ACTION
enum_AppProtocol
Definition: Stack.h:150
@ APP_PROTOCOL_BSM
Definition: Stack.h:166
@ APP_PROTOCOL_NULL
Definition: Stack.h:151
@ APP_PROTOCOL_VIDEO
Definition: Stack.h:172
@ APP_PROTOCOL_RIP
Definition: Stack.h:154
@ APP_PROTOCOL_FTP
Definition: Stack.h:164
@ APP_PROTOCOL_CBR
Definition: Stack.h:162
@ APP_PROTOCOL_OSPF
Definition: Stack.h:155
@ APP_PROTOCOL_OPENFLOW
Definition: Stack.h:158
@ APP_PROTOCOL_ERLANGCALL
Definition: Stack.h:171
@ APP_PROTOCOL_HTTP
Definition: Stack.h:165
@ APP_PROTOCOL_VOICE
Definition: Stack.h:163
@ APP_PROTOCOL_DATABASE
Definition: Stack.h:168
@ APP_PROTOCOL_RTP
Definition: Stack.h:159
@ APP_PROTOCOL_EMULATION
Definition: Stack.h:173
@ APP_PROTOCOL_COAP
Definition: Stack.h:167
@ APP_PROTOCOL_CUSTOM
Definition: Stack.h:169
@ APP_PROTOCOL_EMAIL
Definition: Stack.h:170
enum_TrxProtocol
Definition: Stack.h:178
@ TX_PROTOCOL_UDP
Definition: Stack.h:181
@ TX_PROTOCOL_TCP
Definition: Stack.h:180
@ TX_PROTOCOL_NULL
Definition: Stack.h:179
@ TX_PROTOCOL_WSMP
Definition: Stack.h:182
DISTRIBUTION fn_NetSim_Config_GetDistribution(const char *szDistribution)
bool isFastEmulation()
NETSIM_ID fn_NetSim_GetInterfaceIdByConfigId(NETSIM_ID devId, NETSIM_ID id)
NETSIM_IPAddress fn_NetSim_Stack_GetFirstIPAddressAsId(NETSIM_ID nDeviceId, unsigned int type)
UINT64 start_timer(NETSIM_ID d, NETSIM_ID in, UINT eventId, double time, void *data)
bool isHost(NETSIM_ID d)
NETSIM_ID fn_NetSim_Stack_GetInterfaceIdByName(NETSIM_ID nDeviceId, const char *szInterfaceName)
void fn_NetSim_Coordinate_ConvertGeoToCartesian(double lat, double lon, double altitude, char *strRefEllipsoid, NetSim_COORDINATES *pos)
FADING_MODEL fn_NetSim_Config_GetFadingModel(char *model)
double fn_NetSim_Utilities_GenerateRandomNo(unsigned long *uSeed, unsigned long *uSeed1)
#define SEED_COUNT
Definition: Stack.h:705
double fn_NetSim_Config_read_txPower(void *xmlNetSimNode, const char *name, double defaultTxPower, const char *returnUnit)
NETSIM_ID fn_NetSim_Stack_GetLinkIdByConfigId(NETSIM_ID nLinkId)
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asMac(PNETSIM_MACADDRESS mac, NETSIM_ID *nInterfaceId)
PNETSIM_MACADDRESS fn_NetSim_Stack_GetMacAddressFromIP(const NETSIM_IPAddress szIPAddress)
MAC_LAYER_PROTOCOL fn_NetSim_Stack_GetMacProtocol(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
double fn_NetSim_stack_get_link_quality(NETSIM_ID trx, NETSIM_ID tri, NETSIM_ID rx, NETSIM_ID ri)
enum_MACProtocol
Definition: Stack.h:205
@ MAC_PROTOCOL_IEEE802_11
Definition: Stack.h:208
@ MAC_PROTOCOL_UWAN
Definition: Stack.h:232
@ MAC_PROTOCOL_IEEE802_3
Definition: Stack.h:213
@ MAC_PROTOCOL_SATELLITE
Definition: Stack.h:234
@ MAC_PROTOCOL_GSM
Definition: Stack.h:218
@ MAC_PROTOCOL_CSMACD
Definition: Stack.h:227
@ MAC_PROTOCOL_CDMA
Definition: Stack.h:217
@ MAC_PROTOCOL_IEEE802_22
Definition: Stack.h:210
@ MAC_PROTOCOL_LTE
Definition: Stack.h:219
@ MAC_PROTOCOL_TOKEN_RING_BUS
Definition: Stack.h:228
@ MAC_PROTOCOL_IEEE1609
Definition: Stack.h:230
@ MAC_PROTOCOL_ALOHA
Definition: Stack.h:226
@ MAC_PROTOCOL_DTDMA
Definition: Stack.h:224
@ MAC_PROTOCOL_NULL
Definition: Stack.h:206
@ MAC_PROTOCOL_IEEE802_15_4
Definition: Stack.h:209
@ MAC_PROTOCOL_P2P
Definition: Stack.h:214
@ MAC_PROTOCOL_LTE_NR
Definition: Stack.h:220
@ MAC_PROTOCOL_TDMA
Definition: Stack.h:223
void netsim_set_simstate(SIMSTATE state)
void set_emulation(bool isCustom, int(*load_emulation)(void *emuInterface))
INTERFACE_TYPE fn_NetSim_Config_GetInterfaceType(const char *value)
NetSim_PACKET * fn_NetSim_Socket_GetPacketFromInterface(ptrSOCKETINTERFACE s, int moveFlag)
NETSIM_ID fn_NetSim_Stack_GetInterfaceIdFromIP(NETSIM_ID nDeviceId, NETSIM_IPAddress ip)
int fnNodeJoinRegisterCallBackFunction(_fnNodeJoinCallBack fnCallBack)
Definition: NodeJoin.c:125
int GetXmlVal(void *var, const char *name, void *xmlNode, int flag, XMLDATATYPE type)
struct stru_NetSim_SocketInterface SOCKETINTERFACE
NETSIM_ID fn_NetSim_Stack_GetFirstConnectedDevice(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID *nConnectedDevId, NETSIM_ID *nConnectedInterfaceId)
void set_thread_safe_kernel(bool status)
void * fn_NetSim_xmlGetNextChildElement(void *xmlNetSimNode, void *prevChild)
struct stru_ip_wrapper * ptrIP_WRAPPER
int fn_NetSim_Link_RegisterLinkFailureCallback(NETSIM_ID linkId, int(*fnLinkCallBack)(NETSIM_ID, LINK_STATE))
EXPORTED char * pszIOLogPath
Definition: Stack.h:843
EXPORTED struct stru_NetSim_Network * NETWORK
Definition: Stack.h:742
SIMSTATE netsim_get_simstate()
NetSim_LINKS * fn_NetSim_Stack_AddDeviceTolink(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nLinkId)
int fn_NetSim_Config_ConvertStrToEnum(void *xmlNode, const char *attributeName, const char **enumstr, const char *enumName, int length, bool isErrorMsg)
bool isIPForSameDevice(NETSIM_IPAddress ip, NETSIM_ID d)
ptrSOCKETINTERFACE fn_NetSim_Socket_GetSocketInterface(NETSIM_ID deviceId, APPLICATION_LAYER_PROTOCOL appProtocol, TRANSPORT_LAYER_PROTOCOL trxProtocol, UINT16 localPort, UINT16 remotePort)
enum_EventType
Definition: Stack.h:102
@ INTERNAL_NETSIM_EVENT
Definition: Stack.h:115
@ NETWORK_OUT_EVENT
Definition: Stack.h:108
@ TIMER_EVENT
Definition: Stack.h:114
@ APPLICATION_IN_EVENT
Definition: Stack.h:113
@ END_EVENT
Definition: Stack.h:103
@ NETWORK_IN_EVENT
Definition: Stack.h:109
@ APPLICATION_OUT_EVENT
Definition: Stack.h:112
@ TRANSPORT_IN_EVENT
Definition: Stack.h:111
@ PHYSICAL_OUT_EVENT
Definition: Stack.h:104
@ MAC_OUT_EVENT
Definition: Stack.h:106
@ MAC_IN_EVENT
Definition: Stack.h:107
@ TRANSPORT_OUT_EVENT
Definition: Stack.h:110
@ PHYSICAL_IN_EVENT
Definition: Stack.h:105
LINK_TYPE fn_NetSim_Config_GetLinkType(const char *value)
SUPPRESSION_MODEL fn_NetSim_Config_GetSuppressionModel(char *model)
NETSIM_ID fn_NetSim_Stack_GetConnectedInterface_Both(NETSIM_ID d, NETSIM_ID r, NETSIM_ID *din, NETSIM_ID *rin)
void netsim_pause_progress()
EXPORTED char * pszAppPath
Definition: Stack.h:840
void fn_NetSim_Coordinate_ConvertCartesianToGeo(NetSim_COORDINATES *pos, GEOCORR_REFERENCEELLIPSOID refEllipsoid)
int(* _fnMobilityCallBack)(NETSIM_ID nDeviceId)
Definition: Stack.h:1020
int MAC_COMPARE(PNETSIM_MACADDRESS mac1, PNETSIM_MACADDRESS mac2)
double fn_NetSim_Config_read_dataRate(void *xmlNetSimNode, const char *name, double defaultDataRate, const char *returnUnit)
NETSIM_IPAddress fn_NetSim_Stack_GetIPAddressAsId(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
void sim_time_to_string(double time, char *strTime)
bool isBroadcastMAC(PNETSIM_MACADDRESS mac)
enum_LayerType
Definition: Stack.h:92
@ APPLICATION_LAYER
Definition: Stack.h:98
@ PHYSICAL_LAYER
Definition: Stack.h:94
@ TRANSPORT_LAYER
Definition: Stack.h:97
@ LAYER_NULL
Definition: Stack.h:93
@ NETWORK_LAYER
Definition: Stack.h:96
@ MAC_LAYER
Definition: Stack.h:95
SERVICE_TYPE fn_NetSim_Config_GetServiceType(char *type)
PROPAGATION_MODEL fn_NetSim_Config_GetPropagationModel(char *model)
void fn_NetSim_Metrics_Add_new(const NetSim_PACKET *pPacket, int line, char *file, char *function)
bool fn_NetSim_Stack_isProtocolConfigured(NETSIM_ID d, LAYER_TYPE layer, UINT protocol)
double fn_NetSim_Config_read_dataLen(void *xmlNetSimNode, const char *name, double defaultDataLen, const char *returnUnit)
void notify_interface_up(NETSIM_ID d, NETSIM_ID in)
void * fn_NetSim_Stack_RegisterNewApplicationProtocol(NETSIM_ID deviceId, UINT appProtocol)
NETWORK_LAYER_PROTOCOL fn_NetSim_Stack_GetNWRoutingProtocol(NETSIM_ID nDeviceId)
int fnDeleteEvent(unsigned long long int nEventId)
struct stru_NodeJoinProfile NODE_JOIN_PROFILE
PNETSIM_MACADDRESS MAC_COPY(PNETSIM_MACADDRESS mac)
PROP_MEDIUM fn_NetSim_Config_GetPropagationMedium(char *med)
bool fn_NetSim_Socket_GetBufferStatus(ptrSOCKETINTERFACE s)
void netsim_resume_progress()
double fn_NetSim_Config_read_time(void *xmlNetSimNode, const char *name, double defaultTime, const char *returnUnit)
emum_wireshark_option
Definition: Stack.h:370
@ wireshark_offline
Definition: Stack.h:373
@ wireshark_online
Definition: Stack.h:372
@ wireshark_disable
Definition: Stack.h:371
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
int NetSimxmlError(const char *msg, char *val, const void *xmlNetSimNode)
char * MAC_TO_STR(PNETSIM_MACADDRESS mac)
struct stru_macaddress NETSIM_MACADDRESS
netsimDEVICE_TYPE fn_NetSim_Config_GetDeviceType(const char *type)
NETSIM_ID * fn_NetSim_Stack_GetInterfaceIdbyInterfaceType(NETSIM_ID devId, INTERFACE_TYPE ifType, unsigned int *count)
struct stru_ip_wrapper IP_WRAPPER
NETSIM_IPAddress(* fndns_query)(NETSIM_ID nDeviceId, NETSIM_ID id)
Definition: Stack.h:1015
NETSIM_ID fn_NetSim_Stack_GetApplicationIdByConfigId(NETSIM_ID id)
enum_TransmissionType
Definition: Stack.h:362
@ UNICAST
Definition: Stack.h:363
@ MULTICAST
Definition: Stack.h:365
@ BROADCAST
Definition: Stack.h:364
bool isMulticastMAC(PNETSIM_MACADDRESS mac)
NETSIM_ID fn_NetSim_Stack_GetConnectedInterface(NETSIM_ID devId, NETSIM_ID ifid, NETSIM_ID conId)
void * fn_NetSim_xmlGetChildElement(void *xmlNetSimNode, const char *childName, int count)
NETSIM_IPAddress DNS_QUERY(NETSIM_ID nDeviceId, NETSIM_ID id)
PATHLOSS_MODEL fn_NetSim_Config_GetPathLossModel(char *model)
NETSIM_IPAddress fn_NetSim_Stack_GetFirstIPAddressByName(const NETSIM_Name szDeviceName)
enum xmlDataType XMLDATATYPE
NETSIM_IPAddress get_ip_from_same_subnet(NETSIM_ID d, NETSIM_IPAddress ip)
bool isL3Device(NETSIM_ID d)
enum enum_sim_state SIMSTATE
enum_InterfaceType
Definition: Stack.h:248
@ INTERFACE_LAN_802_22
Definition: Stack.h:253
@ INTERFACE_LAN_802_15_4
Definition: Stack.h:252
@ INTERFACE_TOKEN_BUS
Definition: Stack.h:263
@ INTERFACE_VIRTUAL
Definition: Stack.h:255
@ INTERFACE_CDMA
Definition: Stack.h:257
@ INTERFACE_LTE_NR
Definition: Stack.h:259
@ INTERFACE_LAN_802_11
Definition: Stack.h:251
@ INTERFACE_ALOHA
Definition: Stack.h:261
@ INTERFACE_GSM
Definition: Stack.h:256
@ INTERFACE_LTE
Definition: Stack.h:258
@ INTERFACE_NULL
Definition: Stack.h:249
@ INTERFACE_5G
Definition: Stack.h:260
@ INTERFACE_LAN_802_3
Definition: Stack.h:250
@ INTERFACE_TOKEN_RING
Definition: Stack.h:262
@ INTERFACE_IEEE1609
Definition: Stack.h:264
@ INTERFACE_WAN_ROUTER
Definition: Stack.h:254
@ INTERFACE_P2P
Definition: Stack.h:265
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asIP(NETSIM_IPAddress ip, NETSIM_ID *nInterfaceId)
enum_LinkType
Definition: Stack.h:313
@ LinkType_NULL
Definition: Stack.h:314
@ LinkType_P2P
Definition: Stack.h:315
@ LinkType_P2MP
Definition: Stack.h:316
@ LinkType_MP2MP
Definition: Stack.h:317
void register_interface_state_change(NETSIM_ID d, NETSIM_ID in, fun foo)
enum_refEllipsoid
Definition: Stack.h:403
@ REFERENCEELLIPSOID_GRS80
Definition: Stack.h:406
@ REFERENCEELLIPSOID_SPHERE
Definition: Stack.h:404
@ REFERENCEELLIPSOID_WGS84
Definition: Stack.h:405
@ REFERENCEELLIPSOID_COUNT
Definition: Stack.h:408
enum_corrType
Definition: Stack.h:412
@ CORRTYPE_MAP
Definition: Stack.h:414
@ CORRTYPE_CARTESIAN
Definition: Stack.h:413
@ CORRTYPE_GEO
Definition: Stack.h:415
unsigned long long int(* fn_NetSim_Utilities_AddEvent)(struct stru_NetSim_EventDetails *, int, const char *)
Definition: Stack.h:832
enum_LinkState
Definition: Stack.h:322
@ LINKSTATE_UP
Definition: Stack.h:323
@ LINKSTATE_DOWN
Definition: Stack.h:324
enum enum_corrType NETSIM_COORDINATETYPE
enum_SimulationEndType
Definition: Stack.h:337
@ SimEndType_TIME
Definition: Stack.h:338
bool isRouter(NETSIM_ID d)
enum enum_common_subevent COMMON_SUBEVENT
#define EXPORTED
Definition: Stack.h:46
EXPORTED NETSIM_VERSIONTYPE nVersionType
Definition: Stack.h:844
double fn_NetSim_Utilities_CalculateDistance(NetSim_COORDINATES *coordinate1, NetSim_COORDINATES *coordinates2)
enum enum_SchedulingType SCHEDULING_TYPE
Definition: main.h:143
enum enum_LayerType LAYER_TYPE
Definition: main.h:136
enum enum_LinkMode LINK_MODE
Definition: main.h:140
enum enum_MACProtocol MAC_LAYER_PROTOCOL
Definition: main.h:134
enum enum_DeviceType netsimDEVICE_TYPE
Definition: main.h:138
enum enum_Distribution DISTRIBUTION
Definition: main.h:122
char * NETSIM_Name
Definition: main.h:152
enum enum_ServiceType SERVICE_TYPE
Definition: main.h:125
enum enum_SimulationEndType SIMULATION_END_TYPE
Definition: main.h:142
enum enum_NWProtocol NETWORK_LAYER_PROTOCOL
Definition: main.h:133
enum enum_InterfaceType INTERFACE_TYPE
Definition: main.h:137
NETSIM_VERSIONTYPE
Definition: main.h:158
enum enum_SuppressionModel SUPPRESSION_MODEL
Definition: main.h:124
enum enum_PhyMedium PHYSICAL_LAYER_MEDIUM
Definition: main.h:135
enum enum_LinkType LINK_TYPE
Definition: main.h:139
enum enum_EventType EVENT_TYPE
Definition: main.h:130
enum enum_TrxProtocol TRANSPORT_LAYER_PROTOCOL
Definition: main.h:132
enum enum_AppProtocol APPLICATION_LAYER_PROTOCOL
Definition: main.h:131
enum emum_wireshark_option WIRESHARK_OPTION
Definition: main.h:146
Definition: List.h:43
struct stru_NetSim_Device_Buffer * pstruAccessBuffer
Definition: Stack.h:592
GEOCORR_REFERENCEELLIPSOID refEllipsoid
Definition: Stack.h:428
NETSIM_COORDINATETYPE corrType
Definition: Stack.h:420
unsigned int nDroppedPacket
Definition: Stack.h:584
SCHEDULING_TYPE nSchedulingType
Definition: Stack.h:574
struct stru_NetSim_Packet * last
Definition: Stack.h:586
unsigned int nQueuedPacket
Definition: Stack.h:582
NETSIM_ID interfaceId
Definition: Stack.h:569
QUEUINGTECHNIQUE queuingTechnique
Definition: Stack.h:575
struct stru_NetSim_Packet * pstruPacketlist
Definition: Stack.h:585
unsigned int nDequeuedPacket
Definition: Stack.h:583
WIRESHARK_OPTION wireshark_option
Definition: Stack.h:724
NETSIM_Name szDeviceName
Definition: Stack.h:713
PNODE_JOIN_PROFILE node_join_profile
Definition: Stack.h:725
struct stru_NetSim_TransportLayer * pstruTransportLayer
Definition: Stack.h:720
struct stru_NetSim_NetworkLayer * pstruNetworkLayer
Definition: Stack.h:721
void * deviceVar
Definition: Stack.h:716
NETSIM_ID nDeviceId
Definition: Stack.h:710
NETSIM_ID nConfigDeviceId
Definition: Stack.h:709
struct stru_NetSim_Interface ** ppstruInterfaceList
Definition: Stack.h:717
NETSIM_Name type
Definition: Stack.h:712
NETSIM_ID nNumOfInterface
Definition: Stack.h:714
ptrSOCKETINTERFACE pstruSocketInterface
Definition: Stack.h:719
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:711
struct stru_NetSim_Device * pstruNextDevice
Definition: Stack.h:727
unsigned long ulSeed[SEED_COUNT]
Definition: Stack.h:715
struct stru_NetSim_Device * pstruPrevDevice
Definition: Stack.h:728
struct stru_NetSim_Coordinates * pstruDevicePosition
Definition: Stack.h:722
struct stru_NetSim_Mobility * pstruDeviceMobility
Definition: Stack.h:723
struct stru_NetSim_ApplicationLayer * pstruApplicationLayer
Definition: Stack.h:718
NODE_ACTION node_status
Definition: Stack.h:726
NETSIM_ID nApplicationId
Definition: Stack.h:752
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
long long int nPacketId
Definition: Stack.h:755
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:749
unsigned long long int nPrevEventId
Definition: Stack.h:759
NETSIM_ID nInterfaceId
Definition: Stack.h:751
unsigned long long int nEventId
Definition: Stack.h:745
NETWORK_LAYER_PROTOCOL nLocalNetworkProtocol
Definition: Stack.h:695
unsigned int prefix_len
Definition: Stack.h:691
NETSIM_ID nParentInterfaceId
Definition: Stack.h:681
struct stru_NetSim_PhysicalLayer * pstruPhysicalLayer
Definition: Stack.h:699
NETSIM_IPAddress szSubnetMask
Definition: Stack.h:690
struct stru_NetSim_MacLayer * pstruMACLayer
Definition: Stack.h:698
NETSIM_ID nInterfaceId
Definition: Stack.h:675
bool isNwAddressChanged
Definition: Stack.h:683
INTERFACE_TYPE nInterfaceType
Definition: Stack.h:677
struct stru_NetSim_Interface * pstruPrevInterface
Definition: Stack.h:701
NETSIM_IPAddress publicIP
Definition: Stack.h:689
char * szInterfaceName
Definition: Stack.h:678
char * virtualInterfaceName
Definition: Stack.h:682
NETWORK_LAYER_PROTOCOL nProtocolId
Definition: Stack.h:687
struct stru_NetSim_Interface * pstruNextInterface
Definition: Stack.h:700
NETSIM_IPAddress szDefaultGateWay
Definition: Stack.h:692
struct stru_NetSim_Access_Interface * pstruAccessInterface
Definition: Stack.h:697
void * localProtocolVar
Definition: Stack.h:696
NETSIM_IPAddress szAddress
Definition: Stack.h:688
void * interfaceVar
Definition: Stack.h:694
NETSIM_ID nConfigInterfaceId
Definition: Stack.h:676
bool isWiresharkWriter
Definition: Stack.h:538
MAC_LAYER_PROTOCOL nMacProtocolId
Definition: Stack.h:536
double dFragmentSize
Definition: Stack.h:539
PNETSIM_MACADDRESS szMacAddress
Definition: Stack.h:537
LAYER_TYPE nLayerType
Definition: Stack.h:535
struct stru_NetSim_Links ** ppstruNetSimLinks
Definition: Stack.h:738
void ** appInfo
Definition: Stack.h:739
UINT nApplicationCount
Definition: Stack.h:736
struct stru_NetSim_Device ** ppstruDeviceList
Definition: Stack.h:737
struct stru_NetSim_SimulationParameter * pstruSimulationParameter
Definition: Stack.h:740
LAYER_TYPE nLayerType
Definition: Stack.h:522
int(* routerFunction)()
Definition: Stack.h:525
NETWORK_LAYER_PROTOCOL nRoutingProtocolId
Definition: Stack.h:523
ptrIP_WRAPPER ipWrapper
Definition: Stack.h:527
PHYSICAL_LAYER_MEDIUM nPhyMedium
Definition: Stack.h:547
PHYPROP_WIRELESS wireless
Definition: Stack.h:556
LAYER_TYPE nLayerType
Definition: Stack.h:546
struct stru_NetSim_PhysicalLayer::@6::@7 WIRED
union stru_NetSim_PhysicalLayer::@6 phyProp
struct stru_NetSim_Links * pstruNetSimLinks
Definition: Stack.h:549
SIMULATION_END_TYPE nSimulationExitType
Definition: Stack.h:448
TRANSPORT_LAYER_PROTOCOL trxProtocol
Definition: Stack.h:459
struct stru_NetSim_SocketInterface * next
Definition: Stack.h:463
APPLICATION_LAYER_PROTOCOL appProtocol
Definition: Stack.h:458
struct stru_NetSim_Device_Buffer * pstruSocketBuffer
Definition: Stack.h:462
NETSIM_ID applicationInstance
Definition: Stack.h:457
unsigned int isUDP
Definition: Stack.h:503
LAYER_TYPE nLayerType
Definition: Stack.h:505
TRANSPORT_LAYER_PROTOCOL nTransportLayerProtocol
Definition: Stack.h:504
unsigned int isTCP
Definition: Stack.h:502
NETSIM_ID NodeId
Definition: Stack.h:598
NODE_ACTION action
Definition: Stack.h:600
void * handle
Definition: Stack.h:515
bool isInit
Definition: Stack.h:514
void * table
Definition: Stack.h:516
char szmacaddress[13]
Definition: Stack.h:389
unsigned long long int nmacaddress
Definition: Stack.h:388
char szBinary[50]
Definition: Stack.h:390