29#include "../Firewall/Firewall.h"
31#include "../SupportFunction/Scheduling.h"
100 printf(
"IP---Version number mismatch\nDll Version=%d\nNetSim Version=%d\nFileName=%s\nLine=%d\n",
VERSION,
nVersion_Type / 10, __FILE__, __LINE__);
233 if (nLocalNetworkProtcol)
276 if (route && route->
count)
295 if (route && route->
count)
334 if (!route || !route->
count)
357 for (i = 0; i < route->
count; i++)
359 if (i != route->
count - 1)
549 NULL, NULL, 0, NULL, 0, NULL, NULL, 0, NULL);
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";
650 return "ICMP_SEND_ECHO";
652 return "IP_PROCESSING_DELAY";
654 return "IP_UNKNOWN_SUBEVENT";
658#pragma region SCHEDULER_CONFIG
659#define QUEUING_MAX_TH_MB_DEFAULT 7.0
660#define QUEUING_MIN_TH_MB_DEFAULT 4.0
662#define QUEUING_MAX_P_DEFAULT 0.05
663#define QUEUING_WQ_DEFAULT 0.0002
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
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
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
693 if (
_stricmp(szVal,
"DROP_TAIL") == 0)
695 else if (
_stricmp(szVal,
"RED") == 0)
706 queuing_var->
count = -1;
711 else if (
_stricmp(szVal,
"WRED") == 0)
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);
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);
735 count_values[0] = -1;
736 count_values[1] = -1;
737 count_values[2] = -1;
738 count_values[3] = -1;
744 queuing_var->
max_th = max_th_values;
745 queuing_var->
min_th = min_th_values;
746 queuing_var->
max_p = max_p_values;
748 queuing_var->
count = count_values;
754 fnNetSimError(
"Unknwon queuing technique %s for router %d-%d.\n",
771 if (strcmp(szVal,
"FIFO") == 0)
773 else if (strcmp(szVal,
"PRIORITY") == 0)
775 else if (strcmp(szVal,
"ROUND_ROBIN") == 0)
777 else if (strcmp(szVal,
"WFQ") == 0)
779 else if (strcmp(szVal,
"EDF") == 0)
783 double* max_latency_values =
calloc(5,
sizeof * max_latency_values);
796 fnNetSimError(
"Unknown scheduling technique %s for router %d-%d.\n",
808#pragma region BUFFER_PLOT
809#define BUFFER_BUFFER_PLOT_DEFAULT true
825 fpConfigLog = var[0];
826 xmlNetSimNode = var[2];
838 devVar =
calloc(1,
sizeof* devVar);
843 if (nDeviceId && nInterfaceId)
886 else if (iptype == 6)
919 if (szVal &&
_strupr(szVal) && !strcmp(szVal,
"ENABLE"))
947 if (!strcmp(szVal,
"TRUE"))
979 if (!strcmp(szVal,
"SERVER"))
1008 else if (!strcmp(szVal,
"CLIENT"))
1085 add_table_row_formatted(
false, table,
"%d,%d,%d,%d,%d,%d,%d,",
1141 char str[BUFSIZ] =
"";
1157 switch (routeTable->
type)
1189 if (!strcmp(szStatus,
"ENABLE"))
1199 if (!strcmp(szStatus,
"ENABLE"))
1202 strcat(
pszTrace,
"DESTINATION_IP,");
1209 if (!strcmp(szStatus,
"ENABLE"))
1219 if (!strcmp(szStatus,
"ENABLE"))
1237 *ppszTrace =
calloc(BUFSIZ,
sizeof(
char));
1240 sprintf(*ppszTrace,
"-,-,-,-,");
1301 bool isDefault =
false;
1302 bool isFound =
false;
1309 for (i = 0; i <
DEVICE(d)->nNumOfInterface; i++)
1322 else if (in <= i + 1)
1339 for (i = 1; i <=
DEVICE(d)->nNumOfInterface; i++)
1375 else if (ip->
type == 6)
1406 else if (ip->
type == 6)
1432 else if (ip->
type == 6)
1456 else if (ip->
type == 6)
1496 memset(&pe, 0,
sizeof pe);
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
NETSIM_IPAddress dns_query(NETSIM_ID nDeviceId, NETSIM_ID id)
void process_icmp_packet()
void ICMP_copyPacket(NetSim_PACKET *d, NetSim_PACKET *s)
void icmp_send_echo_request()
void igmp_configure(NETSIM_ID d, void *xmlNode)
void igmp_free(NETSIM_ID d)
void igmp_init(NETSIM_ID d)
void host_handle_unsolicited_report_timer()
void IGMP_FreePacket(NetSim_PACKET *packet)
void process_igmp_packet()
void send_query_msg(NETSIM_ID d, NETSIM_IPAddress group, double time)
void copy_igmp_packet(NetSim_PACKET *d, NetSim_PACKET *s)
void igmp_router_processOtherQuerierPresentTime()
void igmp_router_ProcessGroupMembershipTimer()
void configure_static_ip_route(NETSIM_ID d, char *file)
int fn_NetSim_IP_ICMP_GenerateDstUnreachableMsg()
#define QUEUING_MEDIUM_MAX_TH_MB_DEFAULT
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)
static void init_ip_anim()
static void ip_scheduling_read_config(NETSIM_ID d, NETSIM_ID in, void *xmlNetSimNode)
#define QUEUING_LOW_MAX_TH_MB_DEFAULT
static void ip_handle_processing_delay()
#define SCHEDULING_MAX_LATENCY_rtPS_MS_DEFAULT
int fn_NetSim_IP_VPN_Init()
int IP_packetTraceFiledFlag[4]
static void add_default_ip_table_entry(NETSIM_ID d)
#define QUEUING_NORMAL_MAX_TH_MB_DEFAULT
int fn_NetSim_IP_CopyPacket(NetSim_PACKET *pstruDestPacket, NetSim_PACKET *pstruSrcPacket)
char * fn_NetSim_IP_Trace(NETSIM_ID nSubeventid)
#define QUEUING_HIGH_MAX_TH_MB_DEFAULT
#define SCHEDULING_MAX_LATENCY_UGS_MS_DEFAULT
static void ip_queuing_read_config(NETSIM_ID d, NETSIM_ID in, void *xmlNetSimNode)
#define QUEUING_HIGH_MIN_TH_MB_DEFAULT
#define SCHEDULING_MAX_LATENCY_nrtPS_MS_DEFAULT
#define QUEUING_MAX_TH_MB_DEFAULT
int fn_NetSim_IP_Metrics(PMETRICSWRITER metricsWriter)
static void init_event_to_write(NETSIM_ID d)
int fn_NetSim_IP_ICMP_EchoReply()
int fn_NetSim_IP_FreePacket(NetSim_PACKET *pstruPacket)
int fn_NetSim_IP_ConfigStaticIPTable(char *szVal)
static IP_PROTOCOL_ACTION decide_action_for_packet(NetSim_PACKET *packet, NETSIM_ID dev)
#define QUEUING_MIN_TH_MB_DEFAULT
void ip_write_to_pcap(NetSim_PACKET *packet, NETSIM_ID d, NETSIM_ID i, double time)
int fn_NetSim_IP_ICMP_POLL()
int fn_NetSim_IP_ICMP_ProcessRouterAdvertisement()
static bool isSameIPForOtherInterface(NETSIM_ID d, NETSIM_ID in)
NETWORK_LAYER_PROTOCOL fnGetLocalNetworkProtocol(NetSim_EVENTDETAILS *pstruEventDetails)
#define QUEUING_MEDIUM_MIN_TH_MB_DEFAULT
char * fn_NetSim_IP_ConfigPacketTrace(const void *xmlNetSimNode)
int fn_NetSim_IP_Configure(void **var)
#define SCHEDULING_MAX_LATENCY_ertPS_MS_DEFAULT
int fn_NetSim_IP_ICMP_Init()
#define QUEUING_LOW_MIN_TH_MB_DEFAULT
#define SCHEDULING_MAX_LATENCY_BE_MS_DEFAULT
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)
static ptrIP_FORWARD_ROUTE build_route(NetSim_PACKET *packet)
#define QUEUING_NORMAL_MIN_TH_MB_DEFAULT
int fn_NetSim_IP_Finish()
int fn_NetSim_IP_WritePacketTrace(NetSim_PACKET *pstruPacket, char **ppszTrace)
IP_PROTOCOL_ACTION pim_decide_action(NetSim_PACKET *packet, NETSIM_ID d)
void pim_configure(NETSIM_ID d, void *xmlNetSimNode)
int fn_NetSim_NAT_NetworkIn(NETSIM_ID ndev, NetSim_PACKET *packet)
#define IP_PROCESSING_DELAY_DEFAULT
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)
ptrIP_FORWARD_ROUTE fn_NetSim_IP_RoutePacket(NetSim_PACKET *packet, NETSIM_ID dev)
void process_pim_packet()
void free_ip_route(ptrIP_FORWARD_ROUTE route)
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_NEIGHBOR_TIMEOUT
@ EVENT_IP_PROCESSING_DELAY
@ EVENT_IGMP_OtherQuerierPresentTimer
@ EVENT_IGMP_SendStartupQuery
@ EVENT_IGMP_GroupMembershipTimer
@ EVENT_IGMP_Unsolicited_report
struct stru_IP_Metrics ** ipMetrics
void Router_PIM_Init(NETSIM_ID d)
int fn_NetSim_IP_VPN_Run()
void pim_handle_timer_event()
void multicast_join_group()
void pass_to_lower_layer(NetSim_PACKET *packet, ptrIP_FORWARD_ROUTE route, UINT c)
int fn_NetSim_NAT_NetworkOut(NETSIM_ID ndev, NetSim_PACKET *packet)
#define IP_TO_STR(ip, ipstr)
#define STR_TO_IP6(ipstr)
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)
#define STR_TO_IP4(ipstr)
int IP_IS_IN_SAME_NETWORK(NETSIM_IPAddress ip1, NETSIM_IPAddress ip2, NETSIM_IPAddress subnet, unsigned int prefix_len)
bool isMulticastIP(NETSIM_IPAddress ip)
#define _declspec(dllexport)
This function is used to trigger the update.
#define fnNetSimError(x,...)
#define LIST_FREE(ls, mem)
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 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,...)
NETSIM_UTILITY_EXPORT WIRESHARKTRACE wireshark_trace
bool fn_NetSim_GetBufferStatus(NetSim_BUFFER *pstruBuffer)
bool isDestFoundinPacket(NetSim_PACKET *packet, NETSIM_ID dest)
@ PacketStatus_TTL_Expired
int fnCallProtocol(int nProtocol)
NetSim_EVENTDETAILS * pstruEventDetails_Formal
NetSim_EVENTDETAILS char * pszAppPath_Formal
NetSim_EVENTDETAILS char char int nVersion_Type
NetSim_EVENTDETAILS char char * pszWritePath_Formal
NetSim_EVENTDETAILS char char int void ** fnPointer
NETSIM_ID fn_NetSim_Stack_GetConfigIdOfDeviceById(NETSIM_ID nDeviceId)
@ SUBEVENT_JOIN_MULTICAST_GROUP
EXPORTED fndns_query fnDNS
char * fn_NetSim_xmlConfigPacketTraceField(const void *xmlNetSimNode, const char *name)
#define DEVICE_NAME(DeviceId)
#define DEVICE_MACLAYER(DeviceId, InterfaceId)
char * fn_NetSim_xmlConfig_GetVal(void *xmlNetSimNode, const char *szName, int flag)
#define getXmlVar(var, name, xmlNode, flag, type, protocol)
#define DEVICE_TYPE(DeviceId)
#define DEVICE_NWADDRESS(DeviceId, InterfaceId)
MAC_LAYER_PROTOCOL fn_NetSim_Stack_GetMacProtocol(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
EXPORTED struct stru_NetSim_Network * NETWORK
#define DEVICE_ACCESSBUFFER(DeviceId, InterfaceId)
double fn_NetSim_Config_read_dataLen(void *xmlNetSimNode, const char *name, double defaultDataLen, const char *returnUnit)
#define DEVICE_NWLAYER(DeviceId)
double fn_NetSim_Config_read_time(void *xmlNetSimNode, const char *name, double defaultTime, const char *returnUnit)
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
#define DEVICE_INTERFACE(DeviceId, InterfaceId)
#define IP_WRAPPER_GET(DeviceId)
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asIP(NETSIM_IPAddress ip, NETSIM_ID *nInterfaceId)
#define IP_TABLE_GET(DeviceId)
void IP(uint state[], uchar in[])
int fn_NetSim_FirewallConfig(NETSIM_ID nDeviceId)
ACL_ACTION fn_NetSim_NETWORK_Firewall(NETSIM_ID nDeviceId, NETSIM_ID interfaceId, NetSim_PACKET *packet, ACL_TYPE type)
void fn_NetSim_Firewall_Free(NETSIM_ID d)
#define fn_NetSim_Packet_CopyPacket(pstruPacket)
enum enum_LayerType LAYER_TYPE
#define fn_NetSim_Packet_FreePacket(pstruPacket)
#define fn_NetSim_WritePacketTrace(pstruPacket)
enum enum_NWProtocol NETWORK_LAYER_PROTOCOL
#define fnpAddEvent(pstruEvent)
enum enum_TrxProtocol TRANSPORT_LAYER_PROTOCOL
#define fn_NetSim_Packet_AddPacketToList(pstruBuffer, pstruPacket, nInsertionType)
NETSIM_IPAddress * nextHop
NETSIM_IPAddress * gateway
Structure to store the device ip details.
NETSIM_IPAddress ipPoolEnd
NETSIM_IPAddress * GatewayIPAddress
NETSIM_IPAddress ipPoolStart
unsigned int nRouterAdverLifeTime
unsigned int nRouterAdverMaxInterval
NETSIM_IPAddress ipPoolMask
IP_GATEWAYSTATE * nGatewayState
unsigned int nRouterAdvertisementFlag
unsigned int nICMPPollingTime
bool isFirewallConfigured
NETSIM_IPAddress serverIP
unsigned int nRouterAdverMinInterval
unsigned int nGatewayCount
unsigned int nFirewallBlocked
unsigned int nPacketReceived
unsigned int nPacketDiscarded
unsigned int nPacketForwarded
SCHEDULING_TYPE nSchedulingType
QUEUINGTECHNIQUE queuingTechnique
struct stru_NetSim_NetworkLayer * pstruNetworkLayer
struct stru_NetSim_Interface ** ppstruInterfaceList
struct stru_NetSim_Packet * pPacket
netsimDEVICE_TYPE nDeviceType
Structure to store ip routing table.
NETSIM_IPAddress * Interface
NETSIM_IPAddress networkDestination
NETWORK_LAYER_PROTOCOL nLocalNetworkProtocol
NETSIM_IPAddress szSubnetMask
NETWORK_LAYER_PROTOCOL nProtocolId
NETSIM_IPAddress szDefaultGateWay
NETSIM_IPAddress szAddress
struct stru_NetSim_Device ** ppstruDeviceList
NETSIM_IPAddress szGatewayIP
IP_PROTOCOL_NUMBER IPProtocol
NETSIM_IPAddress szDestIP
void * Packet_NetworkProtocol
NETSIM_IPAddress szNextHopIp
NETSIM_IPAddress szSourceIP
PACKET_STATUS nPacketStatus
struct stru_NetSim_Packet_NetworkLayer * pstruNetworkData
unsigned int nControlDataType
struct stru_NetSim_Packet_TransportLayer * pstruTransportData
char str_ip[_NETSIM_IP_LEN]
PPCAP_WRITER ** pcapWriterlist
void(* convert_sim_to_real_packet)(void *netsim_packet, void *pcap_handle, double dTime)