-
Notifications
You must be signed in to change notification settings - Fork 2
/
tfrc_client.h
98 lines (87 loc) · 2.88 KB
/
tfrc_client.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
/*************************************************************************
> File Name: tfrc_client.h
> Author: Xubin Zhuge
> Mail: [email protected]
> Created Time: Sat 7 Nov 2015 06:45:17 PM EST
************************************************************************/
#include "tfrc.h"
#include "clientresources.h"
#include <sys/time.h>
#include <signal.h>
#define CNTRLMSGSIZE 14
#define ACKMSGSIZE 36
#define DATAHEADERSIZE 24
#define MAXSEQ 10000
#define DATAMAX 1448 //MSS = MTU-IP Header-UDP Header-TFRC Header = 1500-20-8-24=1448
#define MAXINITTRY 10
#define MEG 1000000.0
#define TIMESTAMPWINDOW 10
#define t_mbi 64.0 // t_mbi = 64 seconds in usec
#define true 1
#define false 0
typedef enum {
CLIENT_START,
CLIENT_SENDING,
CLIENT_STOP,
} ClientStatus;
struct ClientPrms {
/*********Socket Things***********/
int sock; /* socket descriptor */
struct sockaddr_in servAddr; /* echo server address */
struct sockaddr_in clientAddr;
uint32_t clientAddrLen;
uint32_t servAddrLen;
uint16_t servPort; /* echo server port */
uint16_t clientPort;
char *servIP; /* ip address of server */
struct hostent *thehost; /* hostent from gethostbyname() */
uint32_t connectionID;
/********TRFC Params**************/
uint32_t msgSize; /* message size in bytes */
float simulatedLossRate;
double maxAllowedThroughput;
double timebetnPackets; // packet scheduling time duration
double X_calc;
double X_trans; // allowed transmit rate in bytes/s
double X_bps; // average tramsmit rate in bytes/s
double X_recv; // rate seen by receiver
double t_RTO; // tcp retransmission timeout value in secs, default = 4*R
double tld; //time since last doubled during slow-start
uint64_t t_recvdata; // timestamp contained in ACK
uint32_t t_delay; // t_delay contained in ACK
uint64_t t_now;
uint32_t R; // Round trip time in seconds
uint32_t R_sample;
float p; // loss event rate
uint16_t b; // max number of packets acknowledged by a single TCP ACK, default=1
int alarmtimeout;
double sessionTime;
struct sigaction displaytimer;
double numDropped;
uint64_t latestPktTimestamp;
double lastAckreceived;
double lossEventCounter;
double numSent;
double numReceived;
uint32_t cntrlTimeout; // timeout value for control message, default = 10 sec
uint32_t cntrlTimeoutCounter; //count at most 10 times for control msg
double noFeedbackTimer; // start of no feedback interval
int feedbackRecvd;
uint32_t sequencenum;
uint32_t expectedACK;
double timestore[TIMESTAMPWINDOW]; // for storing last 10 Time stamps
double avgLossEvents;
double avgThroughput;
int sendSTOP;
uint64_t noStopAckTimer;
uint64_t noAckTimer;
};
/****** Global variables *****/
struct control_t control;
struct data_t data;
struct ACK_t ack;
struct ClientPrms tfrc_client;
ClientStatus cStatus;
int CNTCStop;
uint64_t usec1, usec2,usec3,usec4;
void initializeparams();