NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
Aloha.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_ALOHA_H_
15#define _NETSIM_ALOHA_H_
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20///For MSVC compiler. For GCC link via Linker command
21#pragma comment(lib,"Metrics.lib")
22#pragma comment(lib,"NetworkStack.lib")
23#pragma comment(lib,"Mobility.lib")
24#pragma comment(lib,"PropagationModel.lib")
25#include "ErrorModel.h"
26
27//Default Battery Config Parameter
28#define BATTERY_RECHARGING_CURRENT_MA_DEFAULT 0
29#define BATTERY_VOLTAGE_V_DEFAULT 0
30#define BATTERY_INITIAL_ENERGY_DEFAULT 0
31#define BATTERY_TRANSMITTING_CURRENT_MA_DEFAULT 0
32#define BATTERY_RECEIVING_CURRENT_MA_DEFAULT 0
33#define BATTERY_IDLEMODE_CURRENT_MA_DEFAULT 0
34
35#define ALOHA_SLOT_LENGTH_DEFAULT 0 //Microsec
36#define ALOHA_RETRY_LIMIT_DEFAULT 0
37#define ALOHA_IS_MAC_BUFFER_DEFAULT false
38#define ALOHA_FREQUENCY_DEFAULT 900 //MHz
39#define ALOHA_BANDWIDTH_DEFAULT 5 //MHz
40#define ALOHA_TX_POWER_DEFAULT 100 //mW
41#define ALOHA_RECEIVER_SENSITIVITY_DBM_DEFAULT -85 //dBm
42#define ALOHA_MODULATION_DEFAULT _strdup("QPSK");
43#define ALOHA_DATA_RATE_DEFAULT 10 //mbps
44
45#define ALOHA_MAC_OVERHEAD 0 //Bytes
46#define ALOHA_PHY_OVERHEAD 0 //Bytes
47
48 typedef struct stru_aloha_mac_var
49 {
50 //Config parameter
51 bool isSlotted;
52 double slotlength;
53 UINT retryLimit;
54 bool isMACBuffer;
55
56 double rateLimit;
57 UINT backoffCounter;
58 UINT retryCount;
59 double waitTime;
60 NetSim_PACKET* currPacket;
61 }ALOHA_MAC_VAR,*PALOHA_MAC_VAR;
62#define ALOHA_MAC(devid,ifid) ((PALOHA_MAC_VAR)DEVICE_MACVAR(devid,ifid))
63#define ALOHA_CURR_MAC (ALOHA_MAC(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId))
64
65 typedef struct stru_aloha_phy_var
66 {
67 PHY_MODULATION modulation;
68 double frequency;
69 double bandwidth;
70 double tx_power;
71 double rx_sensitivity;
72 double data_rate;
73 double dAntennaHeight;
74 double dAntennaGain;
75
76 PHY_TX_STATUS transmitter_status;
77 double dInterferencePower;
78 void* battery;
79 PPROPAGATION_INFO PropagationInfo;
80 }ALOHA_PHY_VAR,*PALOHA_PHY_VAR;
81#define ALOHA_PHY(devid,ifid) ((PALOHA_PHY_VAR)DEVICE_PHYVAR(devid,ifid))
82#define ALOHA_CURR_PHY (ALOHA_PHY(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId))
83
84#define get_slot_length(phy) ((1500*8)/(phy->data_rate))
85
86 //Propagation Model
87 PPROPAGATION_INFO get_aloha_propagation_info(NETSIM_ID TX, NETSIM_ID RX);
88 double get_received_power(NETSIM_ID TX,NETSIM_ID RX, double time);
89 int fn_NetSim_Aloha_CalulateReceivedPower();
90
91 int fn_NetSim_Aloha_Handle_MacOut();
92
93 int fn_NetSim_Aloha_PhyOut();
94 void fn_NetSim_Aloha_PhyIn();
95 int fn_NetSim_Aloha_handleMobility(NETSIM_ID d);
96 int fn_NetSim_Aloha_FreePropagationInfo();
97
98 int fn_NetSim_Configure_UWAN_POWER(xmlNetSimNode, nDeviceId, nInterfaceId);
99 bool set_radio_state(NETSIM_ID DeviceId, NETSIM_ID InterfaceId, PHY_TX_STATUS state);
100
101#ifdef __cplusplus
102}
103#endif
104#endif //_NETSIM_ALOHA_H_