NetSim Source Code Help
Loading...
Searching...
No Matches
Channel.c
Go to the documentation of this file.
1
/************************************************************************************
2
* Copyright (C) 2020 *
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
#include "
main.h
"
15
#include "
IEEE1609.h
"
16
17
void
Init_Channel_Switching
(
NETSIM_ID
ndeviceId,
NETSIM_ID
nInterfaceId)
18
{
19
memset(
pstruEventDetails
, 0,
sizeof
*
pstruEventDetails
);
20
pstruEventDetails
->
nDeviceId
= ndeviceId;
21
pstruEventDetails
->
nDeviceType
=
DEVICE_TYPE
(ndeviceId);
22
pstruEventDetails
->
nEventType
=
TIMER_EVENT
;
23
pstruEventDetails
->
nInterfaceId
= nInterfaceId;
24
pstruEventDetails
->
nProtocolId
=
MAC_PROTOCOL_IEEE1609
;
25
pstruEventDetails
->
nSubEventType
= CHANNEL_SWITCH_END;
26
fnpAddEvent
(
pstruEventDetails
);
27
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.prevChannel =
IEEE1609_ChannelType_SCH
;
28
}
29
30
void
fn_NetSim_IEEE1609_ChannelSwitch_End
()
31
{
32
double
t;
33
NetSim_EVENTDETAILS
pevent;
34
memcpy(&pevent,
pstruEventDetails
,
sizeof
pevent);
35
36
switch
(
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.prevChannel)
37
{
38
case
IEEE1609_ChannelType_SCH
:
39
t =
GET_IEEE1609_CURR_MAC_VAR
->dCCH_Time;
40
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.channel_type =
IEEE1609_ChannelType_CCH
;
41
break
;
42
case
IEEE1609_ChannelType_CCH
:
43
t =
GET_IEEE1609_CURR_MAC_VAR
->dSCH_Time;
44
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.channel_type =
IEEE1609_ChannelType_SCH
;
45
break
;
46
default
:
47
fnNetSimError
(
"Unknown channel type %d for IEEE1609 protocol\n"
,
48
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.prevChannel);
49
break
;
50
}
51
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.dStartTime =
pstruEventDetails
->
dEventTime
;
52
pstruEventDetails
->
dEventTime
+= t;
53
pstruEventDetails
->
nSubEventType
= CHANNEL_SWITCH_START;
54
fnpAddEvent
(
pstruEventDetails
);
55
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.dEndTime =
pstruEventDetails
->
dEventTime
;
56
57
//restore
58
memcpy(
pstruEventDetails
, &pevent,
sizeof
*
pstruEventDetails
);
59
restart_transmission
();
60
}
61
62
void
fn_NetSim_IEEE1609_ChannelSwitch_Start
()
63
{
64
pstruEventDetails
->
dEventTime
+=
GET_IEEE1609_CURR_MAC_VAR
->dGuard_Time;
65
pstruEventDetails
->
nSubEventType
= CHANNEL_SWITCH_END;
66
fnpAddEvent
(
pstruEventDetails
);
67
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.prevChannel =
68
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.channel_type;
69
GET_IEEE1609_CURR_MAC_VAR
->CHANNEL_INFO.channel_type =
IEEE1609_ChannelType_GUARD
;
70
}
NETSIM_ID
unsigned int NETSIM_ID
Definition:
Animation.h:45
fn_NetSim_IEEE1609_ChannelSwitch_Start
void fn_NetSim_IEEE1609_ChannelSwitch_Start()
Definition:
Channel.c:62
Init_Channel_Switching
void Init_Channel_Switching(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
Definition:
Channel.c:17
fn_NetSim_IEEE1609_ChannelSwitch_End
void fn_NetSim_IEEE1609_ChannelSwitch_End()
Definition:
Channel.c:30
restart_transmission
void restart_transmission()
Definition:
IEEE1609.c:161
IEEE1609.h
IEEE1609_ChannelType_GUARD
@ IEEE1609_ChannelType_GUARD
Definition:
IEEE1609_Interface.h:24
IEEE1609_ChannelType_CCH
@ IEEE1609_ChannelType_CCH
Definition:
IEEE1609_Interface.h:22
IEEE1609_ChannelType_SCH
@ IEEE1609_ChannelType_SCH
Definition:
IEEE1609_Interface.h:23
GET_IEEE1609_CURR_MAC_VAR
#define GET_IEEE1609_CURR_MAC_VAR
Definition:
IEEE1609_Interface.h:57
fnNetSimError
#define fnNetSimError(x,...)
Definition:
Linux.h:56
DEVICE_TYPE
#define DEVICE_TYPE(DeviceId)
Definition:
Stack.h:773
MAC_PROTOCOL_IEEE1609
@ MAC_PROTOCOL_IEEE1609
Definition:
Stack.h:230
TIMER_EVENT
@ TIMER_EVENT
Definition:
Stack.h:114
pstruEventDetails
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition:
Stack.h:837
main.h
fnpAddEvent
#define fnpAddEvent(pstruEvent)
Definition:
main.h:191
stru_NetSim_EventDetails
Definition:
Stack.h:744
stru_NetSim_EventDetails::nEventType
EVENT_TYPE nEventType
Definition:
Stack.h:747
stru_NetSim_EventDetails::nProtocolId
NETSIM_ID nProtocolId
Definition:
Stack.h:748
stru_NetSim_EventDetails::nSubEventType
NETSIM_ID nSubEventType
Definition:
Stack.h:757
stru_NetSim_EventDetails::nDeviceId
NETSIM_ID nDeviceId
Definition:
Stack.h:750
stru_NetSim_EventDetails::nDeviceType
netsimDEVICE_TYPE nDeviceType
Definition:
Stack.h:749
stru_NetSim_EventDetails::nInterfaceId
NETSIM_ID nInterfaceId
Definition:
Stack.h:751
stru_NetSim_EventDetails::dEventTime
double dEventTime
Definition:
Stack.h:746
ALL
Component 9
IEEE1609
Channel.c
Generated on Fri Dec 9 2022 10:22:48 for NetSim Source Code Help by
1.9.5