-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmac802_11.h
107 lines (94 loc) · 2.07 KB
/
mac802_11.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef INC_mac802_11_H
#define INC_mac802_11_H
#include"scheduler.h"
#include"packet.h"
class node;
class flow;
enum MacState{Idle,//0
WaitingForDIFS,//1
BackingOff,//2
WaitingToXmitDATA,//3
XmittingDATA,//4
WaitingForACK,//5
WaitingToXmitACK,//6
XmittingACK,//7
WaitingToXmitACK2//8
};
class MAC802_11
{
node* n;
flow* f;
Scheduler* sp;
int i;
int N;
int F;
public:
//variables
double CST;
double Pt;
static double DIFS;
static double SIFS;
static double EIFS;
static double aSlotTime;
static double MaxPropagationDelay;
static double InterleavingTime;
int CWmin;
int CWmax;
int CWprev;
//int LastRecvPktID[16][30];
int DummyPkt2Send[100][100];
int *RecvPkts;
int TotalXmitPkts[100];
int TotalRecvPkts[100];
int TotalDroppedPkts[100];
double cw;
double BackOffEndTime;
double InterferencePower;
double NoisePower;
//double NavEndTime;
double ExpireTime;
double NextRTSXmissionTime;
double NextDATAXmissionTime;
static double BasicRate;
static double DataRate;
int tx_active;
int ShortRetry;
int LongRetry;
int AGTReceived[100];
int call;
//int DontCare2Xmit;
//functions
MAC802_11();
void setscheduler(Scheduler* S);
void setnode(node* x, flow* y, int index,int N, int F);
void idle();
int checkmedium();
double getpower(Packet* p);
double resetCW();
double IncreaseCW(int CWprev);
//void sendRTS();
//void sendCTS(int ReceiverNodeID,double RTSduration);
void sendDATA();
void sendACK(int ReceiverNodeID, int ReceivedFlow);
double txtime(int PacketSize,double DataRate);
double txtime(Packet* p);
void transmit(Packet* p, double timeout);
//void RetransmitRTS();
void RetransmitDATA(int NodeID,int FlowID, double Rate);
void recv(Packet* p);
void recv_timer(Packet* p);
//void recvRTS(Packet* p);
//void recvCTS(Packet* p);
void recvDATA(Packet* p);
void recvACK(Packet* p);
void ProcessReceivedDATA(Packet* p);
double SINRThreshold(Packet* p);
void CheckBackOff();
//void CheckNav();
//classes
MacState macstate;
Packet* Pmac;
Packet* PktRecv1;
Packet* PktRecv2;
};
#endif