NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
CSMACD.h
1/************************************************************************************
2* Copyright (C) 2023 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14#ifndef _NETSIM_CSMACD_H_
15#define _NETSIM_CSMACD_H_
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20 ///For MSVC compiler. For GCC link via Linker command
21#pragma comment(lib,"CSMACDlib.lib")
22#pragma comment(lib,"Metrics.lib")
23#pragma comment(lib,"NetworkStack.lib")
24
25#include "CSMACD_enum.h"
26
27#define CSMACD_MAC_OVERHEAD 26 //Bytes
28#define CSMACD_PHY_OVERHEAD 0
29
30 FILE *file_collision,*file_contention;
31
32 typedef enum
33 {
34 LinkState_DOWN,
35 LinkState_UP,
36 }LINK_STATE;
37
38 typedef enum
39 {
40 Idle,
41 Busy,
42 }MAC_STATE;
43
44 typedef struct stru_CSMACD_MacVar
45 {
46 double dPersistance;
47 double dSlotTime;
48 unsigned int nRetryLimit;
49
50 MAC_STATE macState;
51 unsigned int nRetryCount;
52 NetSim_PACKET* currentPacket;
53 double waittime;
54 bool iswaited;
55 }CSMACD_MACVAR,*PCSMACD_MACVAR;
56#define CSMACD_MAC(devid,ifid) ((PCSMACD_MACVAR)DEVICE_MACVAR(devid,ifid))
57#define CSMACD_CURRMAC (CSMACD_MAC(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId))
58
59 typedef struct struc_CSMACD_PhyVar
60 {
61 LINK_STATE link_state;
62 int collision_count;
63 }CSMACD_PHYVAR,*PCSMACD_PHYVAR;
64#define CSMACD_PHY(devid,ifid) (PCSMACD_PHYVAR)DEVICE_PHYVAR(devid,ifid)
65#define CSMACD_CURRPHY CSMACD_PHY(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId)
66
67
68 bool isMediumIdle();
69 void fn_NetSim_CSMACD_MacOut();
70 void fn_NetSim_CSMACD_MacIn();
71 void fn_NetSim_CSMACD_PhyOut();
72 void fn_NetSim_CSMACD_PhyIn();
73 void fn_NetSim_CSMACS_PersistanceWait();
74
75#ifdef __cplusplus
76}
77#endif
78#endif //_NETSIM_CSMACD_H_