-
Notifications
You must be signed in to change notification settings - Fork 2
/
tfrc.h
85 lines (74 loc) · 2.31 KB
/
tfrc.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
/*********************************************************
*
* Module Name: tfrc client/server header file
*
* File Name: tfrc.h
*
* Summary:
* This file contains common stuff for the client and server
*
* Revisions:
*
*********************************************************/
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <string.h> /* for memset() */
#include <netinet/in.h> /* for in_addr */
#include <sys/socket.h> /* for socket(), connect(), sendto(), and recvfrom() */
#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
#include <stdlib.h> /* for atoi() and exit() */
#include <unistd.h> /* for close() */
/*largest amount of data on a socket read*/
#define MAX_BUFFER 6500
/* largest queue number */
#define MAXN 65
/* Message type */
#define CONTROL (0x01)
#define DATA (0x02)
#define ACK (0x03)
/* Code */
#define START (0x01)
#define STOP (0x02)
#define OK (0x03)
#define REDO (0x04)
/* Message length */
#define MSGMAX 4096
#define CONT_LEN 14
#define ACK_LEN 32
#define DATA_HEADER_LEN 24
/* Flow control params */
#define N_MAX 8
/* Considered as Control Message */
struct control_t {
uint16_t msgLength; /* Msg Length */
uint8_t msgType; /* Msg Type */
uint8_t code; /* Code */
uint32_t CxID; /* connection ID */
uint32_t seqNum; /* Sequence Number*/
uint16_t msgSize; /* Send Msg Size */
};
/* Considered as Data Message Format */
struct data_t {
uint16_t msgLength; /* Msg Length */
uint8_t msgType; /* Msg Type */
uint8_t code; /* Code */
uint32_t CxID; /* connection ID */
uint32_t seqNum; /* Sequence Number */
uint32_t RTT; /* Sender's RTT Estimate (in microsecond) */
uint64_t timeStamp; /* TimeStamp */
uint8_t* X; /* Holds Msg Data */
};
/* Considered as ACK Message Format */
struct ACK_t {
uint16_t msgLength; /* Msg Length */
uint8_t msgType; /* Msg Type */
uint8_t code; /* Code */
uint32_t CxID; /* connection ID */
uint32_t ackNum; /* ACK Number */
uint64_t timeStamp; /* TimeStamp */
uint32_t T_delay; /* T_delay (in microsecond) */
uint32_t lossRate; /* Loss Event Rate */
uint32_t recvRate; /* Receive Rate (in bits per second) */
};
void DieWithError(char *errorMessage); /* External error handling function */