OLD | NEW |
| (Empty) |
1 /***************************************************************************** | |
2 Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois. | |
3 All rights reserved. | |
4 | |
5 Redistribution and use in source and binary forms, with or without | |
6 modification, are permitted provided that the following conditions are | |
7 met: | |
8 | |
9 * Redistributions of source code must retain the above | |
10 copyright notice, this list of conditions and the | |
11 following disclaimer. | |
12 | |
13 * Redistributions in binary form must reproduce the | |
14 above copyright notice, this list of conditions | |
15 and the following disclaimer in the documentation | |
16 and/or other materials provided with the distribution. | |
17 | |
18 * Neither the name of the University of Illinois | |
19 nor the names of its contributors may be used to | |
20 endorse or promote products derived from this | |
21 software without specific prior written permission. | |
22 | |
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | |
24 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
25 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
26 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
34 *****************************************************************************/ | |
35 | |
36 /***************************************************************************** | |
37 written by | |
38 Yunhong Gu, last updated 01/22/2011 | |
39 *****************************************************************************/ | |
40 | |
41 #ifndef __UDT_WINDOW_H__ | |
42 #define __UDT_WINDOW_H__ | |
43 | |
44 | |
45 #ifndef WIN32 | |
46 #include <sys/time.h> | |
47 #include <time.h> | |
48 #endif | |
49 #include "udt.h" | |
50 | |
51 | |
52 class CACKWindow | |
53 { | |
54 public: | |
55 CACKWindow(const int& size = 1024); | |
56 ~CACKWindow(); | |
57 | |
58 // Functionality: | |
59 // Write an ACK record into the window. | |
60 // Parameters: | |
61 // 0) [in] seq: ACK seq. no. | |
62 // 1) [in] ack: DATA ACK no. | |
63 // Returned value: | |
64 // None. | |
65 | |
66 void store(const int32_t& seq, const int32_t& ack); | |
67 | |
68 // Functionality: | |
69 // Search the ACK-2 "seq" in the window, find out the DATA "ack" and ca
luclate RTT . | |
70 // Parameters: | |
71 // 0) [in] seq: ACK-2 seq. no. | |
72 // 1) [out] ack: the DATA ACK no. that matches the ACK-2 no. | |
73 // Returned value: | |
74 // RTT. | |
75 | |
76 int acknowledge(const int32_t& seq, int32_t& ack); | |
77 | |
78 private: | |
79 int32_t* m_piACKSeqNo; // Seq. No. for the ACK packet | |
80 int32_t* m_piACK; // Data Seq. No. carried by the ACK packet | |
81 uint64_t* m_pTimeStamp; // The timestamp when the ACK was sent | |
82 | |
83 int m_iSize; // Size of the ACK history window | |
84 int m_iHead; // Pointer to the lastest ACK record | |
85 int m_iTail; // Pointer to the oldest ACK record | |
86 | |
87 private: | |
88 CACKWindow(const CACKWindow&); | |
89 CACKWindow& operator=(const CACKWindow&); | |
90 }; | |
91 | |
92 //////////////////////////////////////////////////////////////////////////////// | |
93 | |
94 class CPktTimeWindow | |
95 { | |
96 public: | |
97 CPktTimeWindow(const int& asize = 16, const int& psize = 16); | |
98 ~CPktTimeWindow(); | |
99 | |
100 // Functionality: | |
101 // read the minimum packet sending interval. | |
102 // Parameters: | |
103 // None. | |
104 // Returned value: | |
105 // minimum packet sending interval (microseconds). | |
106 | |
107 int getMinPktSndInt() const; | |
108 | |
109 // Functionality: | |
110 // Calculate the packes arrival speed. | |
111 // Parameters: | |
112 // None. | |
113 // Returned value: | |
114 // Packet arrival speed (packets per second). | |
115 | |
116 int getPktRcvSpeed() const; | |
117 | |
118 // Functionality: | |
119 // Estimate the bandwidth. | |
120 // Parameters: | |
121 // None. | |
122 // Returned value: | |
123 // Estimated bandwidth (packets per second). | |
124 | |
125 int getBandwidth() const; | |
126 | |
127 // Functionality: | |
128 // Record time information of a packet sending. | |
129 // Parameters: | |
130 // 0) currtime: timestamp of the packet sending. | |
131 // Returned value: | |
132 // None. | |
133 | |
134 void onPktSent(const int& currtime); | |
135 | |
136 // Functionality: | |
137 // Record time information of an arrived packet. | |
138 // Parameters: | |
139 // None. | |
140 // Returned value: | |
141 // None. | |
142 | |
143 void onPktArrival(); | |
144 | |
145 // Functionality: | |
146 // Record the arrival time of the first probing packet. | |
147 // Parameters: | |
148 // None. | |
149 // Returned value: | |
150 // None. | |
151 | |
152 void probe1Arrival(); | |
153 | |
154 // Functionality: | |
155 // Record the arrival time of the second probing packet and the interva
l between packet pairs. | |
156 // Parameters: | |
157 // None. | |
158 // Returned value: | |
159 // None. | |
160 | |
161 void probe2Arrival(); | |
162 | |
163 private: | |
164 int m_iAWSize; // size of the packet arrival history window | |
165 int* m_piPktWindow; // packet information window | |
166 int* m_piPktReplica; | |
167 int m_iPktWindowPtr; // position pointer of the packet info. window. | |
168 | |
169 int m_iPWSize; // size of probe history window size | |
170 int* m_piProbeWindow; // record inter-packet time for probing packet p
airs | |
171 int* m_piProbeReplica; | |
172 int m_iProbeWindowPtr; // position pointer to the probing window | |
173 | |
174 int m_iLastSentTime; // last packet sending time | |
175 int m_iMinPktSndInt; // Minimum packet sending interval | |
176 | |
177 uint64_t m_LastArrTime; // last packet arrival time | |
178 uint64_t m_CurrArrTime; // current packet arrival time | |
179 uint64_t m_ProbeTime; // arrival time of the first probing packet | |
180 | |
181 private: | |
182 CPktTimeWindow(const CPktTimeWindow&); | |
183 CPktTimeWindow &operator=(const CPktTimeWindow&); | |
184 }; | |
185 | |
186 | |
187 #endif | |
OLD | NEW |