NetSim Source Code Help
Loading...
Searching...
No Matches
Medium.c File Reference
#include "main.h"
#include "Medium.h"
#include "ErrorModel.h"
#include "PropagationModel.h"
Include dependency graph for Medium.c:

Go to the source code of this file.

Data Structures

struct  stru_Packet_info
 
struct  stru_Device
 
struct  stru_medium
 

Macros

#define _NETSIM_MDEIUM_CODE_
 
#define BOLTZMANN   1.38064852e-23
 
#define TEMPERATURE   300
 

Typedefs

typedef struct stru_Packet_info PACKETINFO
 
typedef struct stru_Packet_infoptrPACKETINFO
 
typedef struct stru_Device DEVICE_IN_MEDIUM
 
typedef struct stru_DeviceptrDEVICE_IN_MEDIUM
 
typedef struct stru_medium MEDIUM
 
typedef struct stru_mediumptrMEDIUM
 

Functions

static ptrDEVICE_IN_MEDIUM medium_find_device (NETSIM_ID devId, NETSIM_ID devIf)
 
static void write_log (char *format,...)
 
static double GetRXPowerdBm (NETSIM_ID t, NETSIM_ID ti, NETSIM_ID r, NETSIM_ID ri, double time)
 
void medium_add_device (NETSIM_ID d, NETSIM_ID ifid, double dFrequency_MHz, double dBandwidth_MHz, double dRxSensitivity_dBm, double dEdThreshold_dBm, void(*medium_change_callback)(NETSIM_ID, NETSIM_ID, bool, NetSim_PACKET *), bool(*isRadioIdle)(NETSIM_ID, NETSIM_ID), bool(*isTransmitterBusy)(NETSIM_ID, NETSIM_ID), void *(*propagationinfo_find)(NETSIM_ID, NETSIM_ID, NETSIM_ID, NETSIM_ID), void(*packetsentnotify)(NETSIM_ID, NETSIM_ID, NetSim_PACKET *))
 
void medium_update_frequency (NETSIM_ID d, NETSIM_ID in, double f_MHz)
 
void medium_update_bandwidth (NETSIM_ID d, NETSIM_ID in, double bw_MHz)
 
void medium_update_rxsensitivity (NETSIM_ID d, NETSIM_ID in, double p_dbm)
 
void medium_update_edthershold (NETSIM_ID d, NETSIM_ID in, double p_dbm)
 
void medium_update_modulation (NETSIM_ID d, NETSIM_ID in, PHY_MODULATION m, double coderate)
 
void medium_update_datarate (NETSIM_ID d, NETSIM_ID in, double r_mbps)
 
static void medium_remove_device (NETSIM_ID d, NETSIM_ID ifId)
 
static ptrPACKETINFO packetInfo_add (NetSim_PACKET *packet, NETSIM_ID txId, NETSIM_ID txIf, NETSIM_ID rxId, NETSIM_ID rxIf)
 
static ptrPACKETINFO packetInfo_remove (NetSim_PACKET *packet)
 
static void packetInfo_free (ptrPACKETINFO info)
 
static double compute_sinr (double p, double i, double bw)
 
static double GetRXPowerMW (NETSIM_ID t, NETSIM_ID ti, NETSIM_ID r, NETSIM_ID ri, double time)
 
static void medium_update_interference (ptrPACKETINFO info)
 
static bool isAnypacketIsThereForThisTransmitter (ptrPACKETINFO info)
 
static bool CheckFrequencyInterfrence (double dFrequency1, double dFrequency2, double bandwidth)
 
static void update_power_due_to_transmission (ptrPACKETINFO info)
 
static void update_power_due_to_transmission_stop (ptrPACKETINFO info)
 
static void medium_mark_packet_error (ptrPACKETINFO info)
 
void medium_notify_packet_send (NetSim_PACKET *packet, NETSIM_ID txId, NETSIM_ID txIf, NETSIM_ID rxId, NETSIM_ID rxIf)
 
void medium_notify_packet_received (NetSim_PACKET *packet)
 
bool medium_isIdle (NETSIM_ID d, NETSIM_ID in)
 

Variables

static MEDIUM medium
 
static FILE * fplog = NULL
 

Macro Definition Documentation

◆ _NETSIM_MDEIUM_CODE_

#define _NETSIM_MDEIUM_CODE_

Definition at line 24 of file Medium.c.

◆ BOLTZMANN

#define BOLTZMANN   1.38064852e-23

Definition at line 330 of file Medium.c.

◆ TEMPERATURE

#define TEMPERATURE   300

Definition at line 331 of file Medium.c.

Typedef Documentation

◆ DEVICE_IN_MEDIUM

typedef struct stru_Device DEVICE_IN_MEDIUM

◆ MEDIUM

typedef struct stru_medium MEDIUM

◆ PACKETINFO

typedef struct stru_Packet_info PACKETINFO

◆ ptrDEVICE_IN_MEDIUM

typedef struct stru_Device * ptrDEVICE_IN_MEDIUM

◆ ptrMEDIUM

typedef struct stru_medium* ptrMEDIUM

◆ ptrPACKETINFO

typedef struct stru_Packet_info * ptrPACKETINFO

Function Documentation

◆ CheckFrequencyInterfrence()

static bool CheckFrequencyInterfrence ( double  dFrequency1,
double  dFrequency2,
double  bandwidth 
)
static

Definition at line 399 of file Medium.c.

Here is the caller graph for this function:

◆ compute_sinr()

static double compute_sinr ( double  p,
double  i,
double  bw 
)
static

Definition at line 332 of file Medium.c.

◆ GetRXPowerdBm()

static double GetRXPowerdBm ( NETSIM_ID  t,
NETSIM_ID  ti,
NETSIM_ID  r,
NETSIM_ID  ri,
double  time 
)
static

Definition at line 116 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRXPowerMW()

static double GetRXPowerMW ( NETSIM_ID  t,
NETSIM_ID  ti,
NETSIM_ID  r,
NETSIM_ID  ri,
double  time 
)
static

Definition at line 341 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAnypacketIsThereForThisTransmitter()

static bool isAnypacketIsThereForThisTransmitter ( ptrPACKETINFO  info)
static

Definition at line 383 of file Medium.c.

Here is the caller graph for this function:

◆ medium_add_device()

void medium_add_device ( NETSIM_ID  d,
NETSIM_ID  ifid,
double  dFrequency_MHz,
double  dBandwidth_MHz,
double  dRxSensitivity_dBm,
double  dEdThreshold_dBm,
void(*)(NETSIM_ID, NETSIM_ID, bool, NetSim_PACKET *)  medium_change_callback,
bool(*)(NETSIM_ID, NETSIM_ID isRadioIdle,
bool(*)(NETSIM_ID, NETSIM_ID isTransmitterBusy,
void *(*)(NETSIM_ID, NETSIM_ID, NETSIM_ID, NETSIM_ID propagationinfo_find,
void(*)(NETSIM_ID, NETSIM_ID, NetSim_PACKET *)  packetsentnotify 
)

Definition at line 135 of file Medium.c.

◆ medium_find_device()

static ptrDEVICE_IN_MEDIUM medium_find_device ( NETSIM_ID  devId,
NETSIM_ID  devIf 
)
static

Definition at line 82 of file Medium.c.

Here is the caller graph for this function:

◆ medium_isIdle()

bool medium_isIdle ( NETSIM_ID  d,
NETSIM_ID  in 
)

Definition at line 560 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ medium_mark_packet_error()

static void medium_mark_packet_error ( ptrPACKETINFO  info)
static

Definition at line 516 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ medium_notify_packet_received()

void medium_notify_packet_received ( NetSim_PACKET packet)

Definition at line 551 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ medium_notify_packet_send()

void medium_notify_packet_send ( NetSim_PACKET packet,
NETSIM_ID  txId,
NETSIM_ID  txIf,
NETSIM_ID  rxId,
NETSIM_ID  rxIf 
)

Definition at line 538 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ medium_remove_device()

static void medium_remove_device ( NETSIM_ID  d,
NETSIM_ID  ifId 
)
static

Definition at line 241 of file Medium.c.

Here is the call graph for this function:

◆ medium_update_bandwidth()

void medium_update_bandwidth ( NETSIM_ID  d,
NETSIM_ID  in,
double  bw_MHz 
)

Definition at line 180 of file Medium.c.

Here is the call graph for this function:

◆ medium_update_datarate()

void medium_update_datarate ( NETSIM_ID  d,
NETSIM_ID  in,
double  r_mbps 
)

Definition at line 229 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ medium_update_edthershold()

void medium_update_edthershold ( NETSIM_ID  d,
NETSIM_ID  in,
double  p_dbm 
)

Definition at line 204 of file Medium.c.

Here is the call graph for this function:

◆ medium_update_frequency()

void medium_update_frequency ( NETSIM_ID  d,
NETSIM_ID  in,
double  f_MHz 
)

Definition at line 168 of file Medium.c.

Here is the call graph for this function:

◆ medium_update_interference()

static void medium_update_interference ( ptrPACKETINFO  info)
static

Definition at line 346 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ medium_update_modulation()

void medium_update_modulation ( NETSIM_ID  d,
NETSIM_ID  in,
PHY_MODULATION  m,
double  coderate 
)

Definition at line 216 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ medium_update_rxsensitivity()

void medium_update_rxsensitivity ( NETSIM_ID  d,
NETSIM_ID  in,
double  p_dbm 
)

Definition at line 192 of file Medium.c.

Here is the call graph for this function:

◆ packetInfo_add()

static ptrPACKETINFO packetInfo_add ( NetSim_PACKET packet,
NETSIM_ID  txId,
NETSIM_ID  txIf,
NETSIM_ID  rxId,
NETSIM_ID  rxIf 
)
static

Definition at line 252 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ packetInfo_free()

static void packetInfo_free ( ptrPACKETINFO  info)
static

Definition at line 325 of file Medium.c.

Here is the caller graph for this function:

◆ packetInfo_remove()

static ptrPACKETINFO packetInfo_remove ( NetSim_PACKET packet)
static

Definition at line 295 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_power_due_to_transmission()

static void update_power_due_to_transmission ( ptrPACKETINFO  info)
static

Definition at line 417 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_power_due_to_transmission_stop()

static void update_power_due_to_transmission_stop ( ptrPACKETINFO  info)
static

Definition at line 466 of file Medium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_log()

static void write_log ( char *  format,
  ... 
)
static

Definition at line 98 of file Medium.c.

Here is the caller graph for this function:

Variable Documentation

◆ fplog

FILE* fplog = NULL
static

Definition at line 97 of file Medium.c.

◆ medium

MEDIUM medium
static

Definition at line 81 of file Medium.c.