├── .gitignore ├── LICENSE ├── bench_mark.md ├── bench_mark_log ├── kcp_500.log ├── udt_dgram_500.log ├── udt_stream_200_per_20millisecond.log └── udt_stream_500.log ├── install_pack └── udt.sdk.4.11.tar.gz ├── readme.md └── udt_bench_mark ├── allmake.sh ├── clean.sh ├── udt_dgram_client ├── Makefile ├── main.cpp ├── test_util.cpp ├── test_util.h ├── threadsafe_queue.hpp ├── udt_client.cpp └── udt_client.h ├── udt_dgram_server ├── Makefile ├── main.cpp ├── test_util.cpp ├── test_util.h ├── udt_server.cpp └── udt_server.h ├── udt_readme.md ├── udt_stream_client ├── Makefile ├── main.cpp ├── test_util.cpp ├── test_util.h ├── threadsafe_queue.hpp ├── udt_client.cpp └── udt_client.h └── udt_stream_server ├── Makefile ├── main.cpp ├── test_util.cpp ├── test_util.h ├── udt_server.cpp └── udt_server.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | tags 31 | udt4 32 | state.log 33 | 34 | udt_bench_mark/udt_dgram_client/udt_dgram_client 35 | udt_bench_mark/udt_dgram_server/udt_dgram_server 36 | udt_bench_mark/udt_stream_client/udt_stream_client 37 | udt_bench_mark/udt_stream_server/udt_stream_server 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /bench_mark.md: -------------------------------------------------------------------------------- 1 | ### Bench mark of udp reliable framework: 2 | * UDT - UDP-based Data Transfer Protocol [official website](https://sourceforge.net/projects/udt/) 3 | * kcp - A Fast and Reliable ARQ Protocol [official website](https://github.com/skywind3000/kcp) 4 | * enet - Reliable UDP networking library [official website](http://enet.bespin.org/index.html) 5 | 6 | ### Purpose 7 | * This bench mark is for the situation of realtime pvp game. For example, the multiplayer first person shooting game. 8 | * The requirement of realtime pvp game is packet is small and frequently. It wants a minimal delay. And the worst delay should be not so worse. 9 | 10 | ### Test environment 11 | * The tests run server on a server on internet. The Bandwidth of internet is 5M. 12 | * And run client_epoll or client on home computer var wifi. The Bandwidth of ADSL is 10M. 13 | * Both Bandwidth is much bigger than we need (10 times more). 14 | 15 | * The client send 500 bytes data as one packet in every 50 milliseconds. Or 50 bytes for another test. 16 | * The server sendback the data after receiving the packet. 17 | 18 | ## UDT 19 | ### UDT with epoll (SOCK_DGRAM and unblock socket) 20 | [See code](https://github.com/libinzhangyuan/udt_patch_for_epoll) 21 | * a. Bench mark log for 500 bytes in every 50 milliseconds. [here](https://github.com/libinzhangyuan/udt_patch_for_epoll/blob/master/bench_mark/udt_500.log). 22 | * b. Bench mark log for 50 bytes in every 50 milliseconds. [here](https://github.com/libinzhangyuan/udt_patch_for_epoll/blob/master/bench_mark/udt_50.log). 23 | * c. Bench mark log for 500 bytes in every 50 milliseconds using another framework kcp. [here](https://github.com/libinzhangyuan/udt_patch_for_epoll/blob/master/bench_mark/kcp_500.log).
24 | I run b and c at the same time on same computer. So we known the network situation by comparing log from b and c.
25 | 26 | ### The conclusion of this UDT SOCK_DGRAM epoll mode: 27 | * The udt epoll is not good at realtime pvp game currently. 28 | * The latency is perfect at normal situation. 29 | * UDT will fall into a badly situation when there is a network lag. 30 | * The badly situation is more than serval seconds lag. Even serval ten seconds. And the recovery is not expected. 31 | * The udt with epoll has good performance if sending 500 bytes in every 500 milliseconds. So you can use udt with epoll for some other situation. 32 | 33 | ### UDT without epoll (unblock socket) 34 | [See code](https://github.com/libinzhangyuan/reliable_udp_bench_mark/tree/master/udt_bench_mark)
35 | This test call unblock recv and send repeatedly. 36 | 37 | * a. Bench mark log for 500 bytes in every 50 milliseconds SOCK_DGRAM. [here](https://github.com/libinzhangyuan/reliable_udp_bench_mark/blob/master/bench_mark_log/udt_dgram_500.log) 38 | * b. Bench mark log for 500 bytes in every 50 milliseconds SOCK_STREAM. [here](https://github.com/libinzhangyuan/reliable_udp_bench_mark/blob/master/bench_mark_log/udt_stream500.log) 39 | * c. Bench mark log for 500 bytes in every 50 milliseconds using another framework kcp. [here](https://github.com/libinzhangyuan/reliable_udp_bench_mark/blob/master/bench_mark_log/kcp_500.log)
40 | I run b and c at the same time on same computer. So we known the network situation by comparing log from b and c.
41 | 42 | ### The conclusion of UDT without epoll: 43 | * The udt without epoll is same as with epoll. It is not good at realtime pvp game currently. 44 | 45 | ## enet 46 | - Test project is [here](https://github.com/libinzhangyuan/enet_bench_test) 47 | - It change the ENET_PEER_DEFAULT_ROUND_TRIP_TIME from 500 to 50. 48 | * a. enet log for 500 bytes in every 50 milliseconds [here](https://github.com/libinzhangyuan/enet_bench_test/blob/master/bench_mark_log/enet_500.log) 49 | * b. kcp log for 500 bytes in every 50 milliseconds at same time with a [here](https://github.com/libinzhangyuan/enet_bench_test/blob/master/bench_mark_log/kcp_500.log)
50 | - I run a and b at the same time on same computer. So we known the network situation by comparing log from a and b.
51 | - The lag is same as a when do not change ENET_PEER_DEFAULT_ROUND_TRIP_TIME.
52 | 53 | ### The conclusion of enet test 54 | * The enet is better than UDT about realtime pvp game. 55 | * The enet has some lag about 1 seconds more time times. And the recovery of lag situation only some seconds. 56 | * It is worse than kcp. But some game allow 1 second lag. 57 | 58 | ## kcp 59 | * the test project is [here](https://github.com/libinzhangyuan/asio_kcp) - please checkout the tag kcp_bench_mark_test 60 | * the bench mark log of kcp is show in UDT and enet test. 61 | * kcp's lag less than 1 second always. The lag is 1/3 comparing to kcp when network lag happen. 62 | * kcp is better than UDT and enet. The lag is less than 2 seconds when network lag happen. 63 | 64 | 65 | 66 | # Final conclusion. 67 | #### kcp 68 | * The kcp is the first choice for realtime pvp game.
69 | * The lag is less than 1 second when network lag happen. 3 times better than enet when lag happen.
70 | #### enet 71 | * The enet is a good choice if your game allow 2 second lag.
72 | #### UDT 73 | * UDT is a bad idea. It always sink into badly situation of more than serval seconds lag. And the recovery is not expected.
74 | 75 | ### other things may change your choice. 76 | * enet has the problem of lack of doc. And it has lots of functions that you may intrest. 77 | * kcp's doc is chinese.
78 | Good thing is the function detail which is writen in code is english. And you can use asio_kcp which is a good wrap.
79 | The kcp is a simple thing. You will write more code if you want more feature.
80 | * UDT has a perfect doc. 81 | UDT may has more bug than others as I feeling.
82 | -------------------------------------------------------------------------------- /bench_mark_log/kcp_500.log: -------------------------------------------------------------------------------- 1 | ./asio_kcp_client/asio_kcp_client 120.26.200.117 23457 500 2>/dev/null 2 | 61 60 65 55 54 156 155 115 106 66 max: 156 average 10: 89 average total: 89 0KB/s(in) 3 | 19:58.38 58 112 122 72 71 62 51 122 91 50 max: 122 average 10: 81 average total: 81 4 | 19:58.38 60 55 55 56 56 184 185 158 134 114 max: 185 average 10: 105 average total: 105 5 | 19:58.39 105 65 50 51 123 102 82 53 57 58 max: 123 average 10: 74 average total: 74 6 | 19:58.39 58 59 58 59 54 54 53 53 53 48 max: 59 average 10: 54 average total: 54 7 | 19:58.40 49 59 50 61 60 61 56 55 56 67 max: 67 average 10: 57 average total: 57 8 | 19:58.40 57 57 57 115 104 65 53 53 53 55 max: 115 average 10: 66 average total: 66 9 | 19:58.41 55 55 64 130 140 111 100 61 70 56 max: 140 average 10: 84 average total: 84 10 | 19:58.41 55 55 56 55 57 57 62 52 62 52 max: 62 average 10: 56 average total: 56 11 | 19:58.42 52 53 53 64 54 59 48 58 58 59 max: 64 average 10: 55 average total: 55 12 | 19:58.42 65 59 56 58 57 80 176 188 200 242 max: 242 average 10: 118 average total: 118 13 | 19:58.43 191 216 238 435 500 518 496 518 467 485 max: 518 average 10: 406 average total: 406 14 | 19:58.44 477 427 418 452 429 404 363 530 518 529 max: 530 average 10: 454 average total: 454 15 | 19:58.44 553 567 568 518 506 469 418 408 446 403 max: 568 average 10: 485 average total: 485 16 | 19:58.45 393 345 344 420 393 376 735 685 634 584 max: 735 average 10: 490 average total: 490 17 | 19:58.45 548 507 545 527 635 607 564 533 487 439 max: 635 average 10: 539 average total: 539 18 | 19:58.46 416 366 316 267 274 281 261 271 260 231 max: 416 average 10: 294 average total: 294 19 | 19:58.46 210 172 129 109 68 58 52 55 54 53 max: 210 average 10: 96 average total: 96 20 | 19:58.46 53 53 64 53 52 46 57 58 57 57 max: 64 average 10: 55 average total: 55 21 | 19:58.47 155 107 103 63 55 54 56 56 61 50 max: 155 average 10: 76 average total: 76 22 | 19:58.47 51 62 50 52 63 47 57 57 59 119 max: 119 average 10: 61 average total: 61 9.8KB/s(in) 23 | 19:58.48 105 74 55 54 55 57 57 52 52 53 max: 105 average 10: 61 average total: 61 24 | 19:58.48 64 64 54 54 61 60 63 61 70 126 max: 126 average 10: 67 average total: 67 25 | 19:58.49 75 105 90 483 433 382 331 281 263 453 max: 483 average 10: 289 average total: 289 26 | 19:58.50 426 438 499 493 442 407 436 385 441 453 max: 499 average 10: 442 average total: 442 27 | 19:58.50 432 417 366 342 323 293 253 235 529 493 max: 529 average 10: 368 average total: 368 28 | 19:58.51 442 446 416 365 332 307 283 232 287 237 max: 446 average 10: 334 average total: 334 29 | 19:58.51 187 200 278 232 246 195 230 212 182 199 max: 278 average 10: 216 average total: 216 30 | 19:58.52 192 169 326 275 225 174 124 74 55 111 max: 326 average 10: 172 average total: 172 31 | 19:58.52 402 352 374 339 312 281 250 218 188 158 max: 402 average 10: 287 average total: 287 32 | 19:58.52 127 98 53 53 53 53 69 313 263 212 max: 313 average 10: 129 average total: 129 33 | 19:58.53 303 252 459 491 985 934 884 833 783 733 max: 985 average 10: 665 average total: 665 34 | 19:58.54 703 682 653 608 629 582 539 496 445 398 max: 703 average 10: 573 average total: 573 35 | 19:58.54 693 642 592 541 490 440 389 402 381 374 max: 693 average 10: 494 average total: 494 36 | 19:58.55 350 419 367 317 265 215 229 747 696 668 max: 747 average 10: 427 average total: 427 37 | 19:58.56 616 605 564 523 503 462 420 409 379 330 max: 616 average 10: 481 average total: 481 38 | 19:58.56 280 289 259 214 194 156 118 79 162 156 max: 289 average 10: 190 average total: 190 39 | 19:58.56 153 727 677 626 575 543 497 490 439 401 max: 727 average 10: 512 average total: 512 40 | 19:58.57 399 581 548 519 474 538 493 499 610 604 max: 610 average 10: 526 average total: 526 41 | 19:58.57 605 560 675 659 646 610 595 598 556 538 max: 675 average 10: 604 average total: 604 9.4KB/s(in) 42 | 19:58.58 505 454 404 356 316 267 263 248 677 626 max: 677 average 10: 411 average total: 411 43 | 19:58.59 576 525 551 545 495 446 403 367 382 421 max: 576 average 10: 471 average total: 471 44 | 19:58.59 415 434 392 364 333 302 270 241 203 175 max: 434 average 10: 312 average total: 312 45 | 19:58.59 153 111 119 73 65 76 275 251 239 211 max: 275 average 10: 157 average total: 157 46 | 19:59.0 221 218 176 138 154 576 527 477 426 375 max: 576 average 10: 328 average total: 328 47 | 19:59.0 325 321 699 663 613 562 511 461 410 358 max: 699 average 10: 492 average total: 492 48 | 19:59.1 316 277 243 208 183 161 169 432 429 395 max: 432 average 10: 281 average total: 281 49 | 19:59.1 380 338 326 312 266 256 206 193 166 135 max: 380 average 10: 257 average total: 257 50 | 19:59.2 87 81 117 433 427 477 508 494 499 461 max: 508 average 10: 358 average total: 358 51 | 19:59.2 431 444 434 419 379 343 307 440 394 456 max: 456 average 10: 404 average total: 404 52 | 19:59.3 447 444 480 465 459 421 436 410 530 494 max: 530 average 10: 458 average total: 458 53 | 19:59.3 677 661 610 559 508 458 407 356 402 398 max: 677 average 10: 503 average total: 503 54 | 19:59.4 553 503 475 457 604 553 502 451 400 350 max: 604 average 10: 484 average total: 484 55 | 19:59.4 299 248 198 422 404 669 689 638 587 537 max: 689 average 10: 469 average total: 469 56 | 19:59.5 487 436 385 347 304 335 339 345 373 344 max: 487 average 10: 369 average total: 369 57 | 19:59.5 328 287 277 240 239 224 177 156 157 150 max: 328 average 10: 223 average total: 223 58 | 19:59.6 312 630 645 594 544 493 442 419 728 697 max: 728 average 10: 550 average total: 550 59 | 19:59.7 910 859 809 759 708 657 609 624 645 613 max: 910 average 10: 719 average total: 719 60 | 19:59.7 653 683 646 605 645 654 611 567 526 507 max: 683 average 10: 609 average total: 609 61 | 19:59.8 527 521 478 427 390 398 384 453 402 352 max: 527 average 10: 433 average total: 433 62 | 19:59.8 305 338 447 417 781 730 680 630 579 529 max: 781 average 10: 543 average total: 543 9.8KB/s(in) 63 | 19:59.9 478 461 412 364 314 330 312 261 246 234 max: 478 average 10: 341 average total: 341 64 | 19:59.9 270 276 261 419 383 345 299 255 205 172 max: 419 average 10: 288 average total: 288 65 | 19:59.9 152 111 72 71 532 482 431 380 329 283 max: 532 average 10: 284 average total: 284 66 | 19:59.10 257 565 514 514 473 462 423 412 372 331 max: 565 average 10: 432 average total: 432 67 | 19:59.10 312 271 225 184 167 134 267 216 205 172 max: 312 average 10: 215 average total: 215 68 | 19:59.11 152 112 82 61 61 56 55 57 57 137 max: 152 average 10: 83 average total: 83 69 | 19:59.11 106 96 55 51 62 53 51 80 52 69 max: 106 average 10: 67 average total: 67 70 | 19:59.12 61 61 56 59 57 58 58 58 55 54 max: 61 average 10: 57 average total: 57 71 | 19:59.12 66 48 59 59 60 60 60 56 56 55 max: 66 average 10: 57 average total: 57 72 | 19:59.13 55 55 55 56 55 50 61 50 62 61 max: 62 average 10: 56 average total: 56 73 | 19:59.13 61 51 52 61 57 55 57 56 60 118 max: 118 average 10: 62 average total: 62 74 | 19:59.14 109 74 56 55 53 58 54 117 119 76 max: 119 average 10: 77 average total: 77 75 | 19:59.14 59 59 59 60 61 62 61 60 55 71 max: 71 average 10: 60 average total: 60 76 | 19:59.15 56 58 57 121 107 82 61 51 62 61 max: 121 average 10: 71 average total: 71 77 | 19:59.15 51 51 50 51 65 63 66 64 54 54 max: 66 average 10: 56 average total: 56 78 | 19:59.16 54 54 54 56 55 131 112 81 51 50 max: 131 average 10: 69 average total: 69 79 | 19:59.16 61 52 51 52 62 67 58 57 58 59 max: 67 average 10: 57 average total: 57 80 | 19:59.17 59 58 58 55 55 57 55 116 105 76 max: 116 average 10: 69 average total: 69 81 | 19:59.17 56 65 51 50 50 60 51 61 52 61 max: 65 average 10: 55 average total: 55 82 | 19:59.18 123 107 76 57 57 56 57 58 56 57 max: 123 average 10: 70 average total: 70 83 | 19:59.18 54 54 55 63 52 53 53 63 63 64 max: 64 average 10: 57 average total: 57 10.3KB/s(in) 84 | 19:59.19 71 65 61 51 60 118 106 77 57 57 max: 118 average 10: 72 average total: 72 85 | 19:59.19 58 58 53 53 53 53 53 54 63 54 max: 63 average 10: 55 average total: 55 86 | 19:59.20 53 59 60 110 109 110 69 60 115 106 max: 115 average 10: 85 average total: 85 87 | 19:59.20 66 55 57 57 59 57 58 53 53 53 max: 66 average 10: 56 average total: 56 88 | 19:59.21 54 55 54 55 216 212 172 164 122 82 max: 216 average 10: 118 average total: 118 89 | 19:59.21 62 52 58 57 62 60 60 61 62 60 max: 62 average 10: 59 average total: 59 90 | 19:59.22 62 115 105 64 54 54 55 54 55 66 max: 115 average 10: 68 average total: 68 91 | 19:59.22 55 55 54 49 60 59 60 62 61 61 max: 62 average 10: 57 average total: 57 92 | 19:59.23 62 58 57 58 59 60 58 59 106 105 max: 106 average 10: 68 average total: 68 93 | 19:59.23 155 125 107 64 53 54 54 48 59 60 max: 155 average 10: 77 average total: 77 94 | 19:59.24 58 58 59 63 58 63 53 53 54 56 max: 63 average 10: 57 average total: 57 95 | 19:59.24 55 55 59 60 60 128 110 67 105 71 max: 128 average 10: 77 average total: 77 96 | 19:59.25 98 57 57 56 58 58 57 61 63 52 max: 98 average 10: 61 average total: 61 97 | 19:59.25 133 93 52 53 68 57 68 118 129 121 max: 133 average 10: 89 average total: 89 98 | 19:59.26 88 116 106 66 120 79 127 120 75 54 max: 127 average 10: 95 average total: 95 99 | 19:59.26 63 72 62 57 58 60 220 207 171 157 max: 220 average 10: 112 average total: 112 100 | 19:59.27 118 80 67 65 52 54 126 105 91 58 max: 126 average 10: 81 average total: 81 101 | 19:59.27 66 60 61 60 50 66 71 68 70 128 max: 128 average 10: 70 average total: 70 102 | 19:59.28 108 90 59 58 114 127 78 54 68 70 max: 127 average 10: 82 average total: 82 103 | 19:59.28 54 50 49 59 60 74 55 50 67 74 max: 74 average 10: 59 average total: 59 9.8KB/s(in) 104 | 19:59.29 78 55 58 57 59 55 55 55 61 51 max: 78 average 10: 58 average total: 58 105 | 19:59.29 51 53 52 64 67 66 62 57 62 56 max: 67 average 10: 59 average total: 59 106 | 19:59.30 57 58 62 62 54 54 67 67 66 66 max: 67 average 10: 61 average total: 61 107 | 19:59.30 55 49 50 60 60 61 60 62 57 57 max: 62 average 10: 57 average total: 57 108 | 19:59.31 58 80 58 57 58 54 54 54 55 55 max: 80 average 10: 58 average total: 58 109 | 19:59.31 56 56 51 51 51 52 52 52 63 64 max: 64 average 10: 54 average total: 54 110 | 19:59.32 58 58 59 59 59 59 58 58 58 57 max: 59 average 10: 58 average total: 58 111 | 19:59.32 57 54 55 67 65 136 103 91 64 51 max: 136 average 10: 74 average total: 74 112 | 19:59.33 59 125 112 113 72 56 63 56 64 71 max: 125 average 10: 79 average total: 79 113 | 19:59.33 62 124 104 77 64 127 130 85 55 55 max: 130 average 10: 88 average total: 88 114 | 19:59.34 55 60 60 61 61 61 61 50 51 56 max: 61 average 10: 57 average total: 57 115 | 19:59.34 107 117 107 77 117 110 102 70 55 103 max: 117 average 10: 96 average total: 96 116 | 19:59.35 102 62 64 47 57 56 57 58 57 59 max: 102 average 10: 61 average total: 61 117 | 19:59.35 54 54 54 54 54 56 55 52 65 61 max: 65 average 10: 55 average total: 55 118 | 19:59.36 51 63 61 64 67 58 61 60 63 72 max: 72 average 10: 62 average total: 62 119 | 19:59.36 69 54 60 71 55 59 61 134 134 135 max: 135 average 10: 83 average total: 83 120 | 19:59.37 84 64 77 60 66 69 49 130 110 81 max: 130 average 10: 79 average total: 79 121 | 19:59.37 59 60 49 118 108 107 78 59 59 59 max: 118 average 10: 75 average total: 75 122 | 19:59.38 57 60 59 53 57 114 105 75 56 110 max: 114 average 10: 74 average total: 74 123 | 19:59.38 111 110 71 61 51 61 57 58 59 58 max: 111 average 10: 69 average total: 69 9.9KB/s(in) 124 | 19:59.39 58 58 59 60 56 57 54 116 105 75 max: 116 average 10: 69 average total: 69 125 | 19:59.39 54 55 71 63 67 67 62 62 62 52 max: 71 average 10: 61 average total: 61 126 | 19:59.40 57 57 60 121 116 79 68 54 54 56 max: 121 average 10: 72 average total: 72 127 | 19:59.40 55 56 116 106 72 52 53 52 63 64 max: 116 average 10: 68 average total: 68 128 | 19:59.41 54 54 49 121 111 81 61 52 47 57 max: 121 average 10: 68 average total: 68 129 | 19:59.41 57 58 59 58 115 106 65 54 55 56 max: 115 average 10: 68 average total: 68 130 | 19:59.42 56 57 53 54 53 53 62 62 62 57 max: 62 average 10: 56 average total: 56 131 | 19:59.42 58 57 61 62 61 61 58 58 53 54 max: 62 average 10: 58 average total: 58 132 | 19:59.43 55 54 55 55 70 60 62 61 50 61 max: 70 average 10: 58 average total: 58 133 | 19:59.43 61 69 74 56 56 57 57 58 57 58 max: 74 average 10: 60 average total: 60 134 | 19:59.44 54 53 53 59 105 64 56 56 60 49 max: 105 average 10: 60 average total: 60 135 | 19:59.44 50 55 70 62 63 61 57 56 118 88 max: 118 average 10: 68 average total: 68 136 | 19:59.45 59 67 61 65 54 55 54 66 55 55 max: 67 average 10: 59 average total: 59 137 | 19:59.45 52 54 60 55 61 50 61 60 57 57 max: 61 average 10: 56 average total: 56 138 | 19:59.46 58 67 60 59 58 56 60 54 54 65 max: 67 average 10: 59 average total: 59 139 | 19:59.46 64 52 113 112 71 68 131 107 87 58 max: 131 average 10: 86 average total: 86 140 | 19:59.47 58 60 64 54 115 127 105 85 55 66 max: 127 average 10: 78 average total: 78 141 | 19:59.47 62 61 62 61 65 215 171 160 117 77 max: 215 average 10: 105 average total: 105 142 | 19:59.48 61 68 59 68 70 57 53 53 54 55 max: 70 average 10: 59 average total: 59 143 | 19:59.48 54 56 61 194 153 153 163 123 113 98 max: 194 average 10: 116 average total: 116 9.8KB/s(in) 144 | 19:59.49 59 57 58 57 57 59 117 114 63 53 max: 117 average 10: 69 average total: 69 145 | 19:59.49 63 53 64 54 75 63 63 64 51 58 max: 75 average 10: 60 average total: 60 146 | 19:59.50 62 61 63 57 56 57 57 123 105 85 max: 123 average 10: 72 average total: 72 147 | 19:59.51 55 56 57 204 164 165 125 110 70 60 max: 204 average 10: 106 average total: 106 148 | 19:59.51 50 52 50 61 56 57 57 58 59 55 max: 61 average 10: 55 average total: 55 149 | 19:59.52 55 55 56 56 56 56 53 52 52 51 max: 56 average 10: 54 average total: 54 150 | 19:59.52 61 61 62 56 58 58 58 57 58 58 max: 62 average 10: 58 average total: 58 151 | 19:59.53 54 54 115 116 75 59 53 58 59 47 max: 116 average 10: 69 average total: 69 152 | 19:59.53 58 59 59 60 60 55 71 76 56 56 max: 76 average 10: 61 average total: 61 153 | 19:59.54 56 56 56 52 61 53 52 54 54 54 max: 61 average 10: 54 average total: 54 154 | 19:59.54 53 59 59 60 50 62 117 108 67 69 max: 117 average 10: 70 average total: 70 155 | 19:59.55 68 58 59 58 113 104 73 54 56 55 max: 113 average 10: 69 average total: 69 156 | 19:59.55 111 101 71 50 62 114 99 68 59 69 max: 114 average 10: 80 average total: 80 157 | 19:59.56 59 60 61 65 56 66 57 57 57 57 max: 66 average 10: 59 average total: 59 158 | 19:59.56 57 57 54 54 56 53 54 64 54 71 max: 71 average 10: 57 average total: 57 159 | 19:59.57 50 50 63 56 67 65 60 48 59 58 max: 67 average 10: 57 average total: 57 160 | 19:59.57 60 116 106 65 57 56 56 56 56 57 max: 116 average 10: 68 average total: 68 161 | 19:59.58 113 114 113 72 53 52 124 99 58 59 max: 124 average 10: 85 average total: 85 162 | 19:59.58 59 59 60 60 61 61 55 55 56 57 max: 61 average 10: 58 average total: 58 163 | 19:59.59 56 57 58 63 52 53 53 54 56 56 max: 63 average 10: 55 average total: 55 9.9KB/s(in) 164 | 19:59.59 54 53 51 54 61 69 62 58 118 89 max: 118 average 10: 66 average total: 66 165 | 20:0.0 60 61 55 56 55 55 56 56 56 55 max: 61 average 10: 56 average total: 56 166 | 20:0.0 52 53 51 53 53 64 53 48 64 48 max: 64 average 10: 53 average total: 53 167 | 20:0.1 58 109 78 59 59 54 55 54 54 55 max: 109 average 10: 63 average total: 63 168 | 20:0.1 55 55 54 65 55 54 50 59 60 61 max: 65 average 10: 56 average total: 56 169 | 20:0.2 51 61 61 56 55 56 57 56 57 60 max: 61 average 10: 57 average total: 57 170 | 20:0.2 57 53 53 54 53 53 54 70 62 60 max: 70 average 10: 56 average total: 56 171 | 20:0.3 61 60 61 61 67 67 58 67 119 113 max: 119 average 10: 73 average total: 73 172 | 20:0.3 79 61 114 83 56 53 54 54 55 105 max: 114 average 10: 71 average total: 71 173 | 20:0.4 70 51 51 51 62 62 51 52 59 57 max: 70 average 10: 56 average total: 56 174 | 20:0.4 58 57 192 161 119 99 208 204 164 156 max: 208 average 10: 141 average total: 141 175 | 20:0.5 114 104 63 55 54 49 49 60 60 191 max: 191 average 10: 79 average total: 79 176 | 20:0.5 158 147 107 67 57 58 58 64 53 52 max: 158 average 10: 82 average total: 82 177 | 20:0.6 53 54 54 54 54 52 62 63 51 60 max: 63 average 10: 55 average total: 55 178 | 20:0.6 121 111 75 56 55 57 56 60 58 57 max: 121 average 10: 70 average total: 70 179 | 20:0.7 63 62 63 65 52 62 63 59 68 70 max: 70 average 10: 62 average total: 62 180 | 20:0.7 58 60 57 58 54 55 54 56 55 55 max: 60 average 10: 56 average total: 56 181 | 20:0.8 56 55 56 62 61 63 61 50 61 52 max: 63 average 10: 57 average total: 57 182 | 20:0.8 52 57 57 57 58 58 57 57 58 52 max: 58 average 10: 56 average total: 56 183 | 20:0.9 53 53 54 63 64 50 49 50 50 50 max: 64 average 10: 53 average total: 53 9.9KB/s(in) 184 | 20:0.9 61 62 61 66 57 58 58 58 60 59 max: 66 average 10: 60 average total: 60 185 | 20:0.10 53 54 55 55 55 53 57 58 78 59 max: 78 average 10: 57 average total: 57 186 | 20:0.10 59 60 60 56 68 56 59 59 59 118 max: 118 average 10: 65 average total: 65 187 | 20:0.11 103 74 54 53 120 99 80 59 59 60 max: 120 average 10: 76 average total: 76 188 | 20:0.11 61 61 55 56 107 66 57 56 56 102 max: 107 average 10: 67 average total: 67 189 | -------------------------------------------------------------------------------- /bench_mark_log/udt_stream_200_per_20millisecond.log: -------------------------------------------------------------------------------- 1 | ./udt_bench_mark/udt_stream_client/udt_stream_client 22001 120.26.200.117 23456 200 2>./state.log 2 | connect to: 120.26.200.117 23456 3 | Run UDT client loop ... 4 | 163 173 184 185 175 162 167 157 146 139 max: 185 average 10: 165 average total: 165 0KB/s(in) 5 | 18:43.34 131 145 150 140 135 137 134 128 138 143 max: 150 average 10: 138 average total: 151 6 | 18:43.34 132 130 277 256 2080 2057 2033 2013 1990 1968 max: 2080 average 10: 1293 average total: 532 7 | 18:43.36 1947 1923 1900 1879 1858 1837 1816 1792 1770 1746 max: 1947 average 10: 1846 average total: 860 8 | 18:43.36 1726 1704 1679 1659 1726 1705 1722 1739 1763 1779 max: 1779 average 10: 1720 average total: 1032 9 | 18:43.36 1800 1814 1822 1810 1809 1804 1803 1857 1837 1816 max: 1857 average 10: 1817 average total: 1163 10 | 18:43.37 1796 1774 1753 1728 1721 1715 1702 1684 1673 1670 max: 1796 average 10: 1721 average total: 1243 11 | 18:43.37 1651 1641 1634 1627 1615 1599 1594 1574 1564 1547 max: 1651 average 10: 1604 average total: 1288 12 | 18:43.37 1540 1533 1518 1564 1543 1523 1499 1479 1456 1452 max: 1564 average 10: 1510 average total: 1313 13 | 18:43.37 1499 1479 1459 1438 1416 1395 1374 1358 1358 1343 max: 1499 average 10: 1411 average total: 1322 14 | 18:43.37 1322 1316 1322 1302 1285 1276 1265 1254 1242 1221 max: 1322 average 10: 1280 average total: 1319 15 | 18:43.37 1218 1202 1198 1182 1171 1157 1149 1651 1631 1606 max: 1651 average 10: 1316 average total: 1318 16 | 18:43.38 1585 1564 1540 1518 1498 1473 1452 1432 1407 1387 max: 1585 average 10: 1485 average total: 1331 17 | 18:43.38 1365 1345 1324 1303 1280 1260 1236 1259 1256 1244 max: 1365 average 10: 1287 average total: 1328 18 | 18:43.38 1234 1213 1206 1195 1185 1172 1164 1155 1142 1130 max: 1234 average 10: 1179 average total: 1318 19 | 18:43.38 1146 1125 1105 1144 1123 1102 1134 1114 1094 1070 max: 1146 average 10: 1115 average total: 1305 20 | 18:43.38 1050 1029 1009 1003 992 982 966 957 951 943 max: 1050 average 10: 988 average total: 1287 21 | 18:43.38 927 918 920 899 882 881 925 1858 1837 1817 max: 1858 average 10: 1186 average total: 1281 22 | 18:43.39 1795 1773 1751 1731 1711 1690 1669 1645 1624 1603 max: 1795 average 10: 1699 average total: 1303 23 | 18:43.39 1582 1561 1541 1521 1500 1480 1460 1486 1483 1485 max: 1582 average 10: 1509 average total: 1313 24 | 18:43.39 1479 1478 1468 1472 1461 1436 1429 1421 1412 1471 max: 1479 average 10: 1452 average total: 1320 25 | 18:43.40 1450 1428 1405 1385 1381 1369 1361 1354 1350 1346 max: 1450 average 10: 1382 average total: 1323 26 | 18:43.40 1335 1311 1295 1282 1280 1266 1255 1253 1239 1227 max: 1335 average 10: 1274 average total: 1321 27 | 18:43.40 1225 1267 1247 1227 1205 1184 1218 1220 1200 1180 max: 1267 average 10: 1217 average total: 1316 28 | 18:43.40 1158 1137 1117 1101 1083 1066 1054 1047 1038 1088 max: 1158 average 10: 1088 average total: 1307 29 | 18:43.40 1068 1045 1020 995 975 958 948 934 921 910 max: 1068 average 10: 977 average total: 1295 30 | 18:43.40 901 889 878 870 861 853 841 830 821 801 max: 901 average 10: 854 average total: 1278 31 | 18:43.40 792 777 770 823 798 777 756 800 779 756 max: 823 average 10: 782 average total: 1261 32 | 18:43.40 732 711 690 667 646 625 628 618 597 603 max: 732 average 10: 651 average total: 1240 33 | 18:43.40 582 630 610 589 569 546 525 500 480 459 max: 630 average 10: 549 average total: 1217 34 | 18:43.40 453 431 412 404 418 410 394 388 394 376 max: 453 average 10: 408 average total: 1190 35 | 18:43.41 355 335 374 353 329 307 283 261 239 223 max: 374 average 10: 305 average total: 1163 36 | 18:43.41 212 209 253 233 209 189 168 148 141 132 max: 253 average 10: 189 average total: 1133 37 | 18:43.41 128 117 110 90 84 76 72 63 57 51 max: 128 average 10: 84 average total: 1102 38 | 18:43.41 48 47 45 48 47 48 48 48 47 50 max: 50 average 10: 47 average total: 1072 39 | 18:43.41 47 47 46 48 48 59 47 49 52 51 max: 59 average 10: 49 average total: 1044 40 | 18:43.41 61 51 58 56 48 176 152 131 111 87 max: 176 average 10: 93 average total: 1018 41 | 18:43.42 76 65 61 62 159 136 210 185 160 140 max: 210 average 10: 125 average total: 995 42 | 18:43.42 119 107 281 257 235 256 235 212 192 171 max: 281 average 10: 206 average total: 974 43 | 18:43.42 150 129 174 153 128 108 86 66 55 49 max: 174 average 10: 109 average total: 953 44 | 18:43.42 50 123 100 76 55 48 133 113 88 68 max: 133 average 10: 85 average total: 932 45 | 18:43.42 53 51 49 53 47 47 51 54 47 46 max: 54 average 10: 49 average total: 911 46 | 18:43.43 48 47 47 49 55 47 54 48 49 46 max: 55 average 10: 49 average total: 891 47 | 18:43.43 50 48 47 48 49 47 47 49 49 49 max: 50 average 10: 48 average total: 871 48 | 18:43.43 49 113 93 72 49 49 48 47 46 47 max: 113 average 10: 61 average total: 853 49 | 18:43.43 45 49 749 727 704 679 655 631 611 591 max: 749 average 10: 544 average total: 847 8.8KB/s(in) 50 | 18:43.44 571 546 525 505 483 463 449 426 402 381 max: 571 average 10: 475 average total: 839 51 | 18:43.44 388 383 362 350 340 319 307 287 281 260 max: 388 average 10: 327 average total: 828 52 | 18:43.44 301 277 257 237 216 193 172 151 135 120 max: 301 average 10: 205 average total: 815 53 | 18:43.44 108 94 83 62 47 46 47 47 49 54 max: 108 average 10: 63 average total: 800 54 | 18:43.44 127 106 86 62 59 49 50 50 52 149 max: 149 average 10: 79 average total: 786 55 | 18:43.45 129 105 79 131 109 87 66 54 114 94 max: 131 average 10: 96 average total: 773 56 | 18:43.45 70 50 47 48 47 47 50 46 46 49 max: 70 average 10: 50 average total: 759 57 | 18:43.45 49 47 80 60 54 63 47 49 47 48 max: 80 average 10: 54 average total: 746 58 | 18:43.45 113 93 72 51 48 46 48 47 56 49 max: 113 average 10: 62 average total: 734 59 | 18:43.45 59 46 73 74 53 54 50 749 729 708 max: 749 average 10: 259 average total: 725 60 | 18:43.46 686 661 636 616 594 573 550 528 508 486 max: 686 average 10: 583 average total: 723 61 | 18:43.46 466 511 488 466 446 459 448 430 421 419 max: 511 average 10: 455 average total: 718 62 | 18:43.47 400 380 365 377 366 348 328 317 309 284 max: 400 average 10: 347 average total: 712 63 | 18:43.47 272 254 246 320 714 690 665 642 621 599 max: 714 average 10: 502 average total: 708 64 | 18:43.47 578 557 536 515 491 471 450 429 408 384 max: 578 average 10: 481 average total: 705 65 | 18:43.47 360 339 315 290 302 302 305 281 265 258 max: 360 average 10: 301 average total: 698 66 | 18:43.47 265 240 222 198 199 182 184 164 227 204 max: 265 average 10: 208 average total: 690 67 | 18:43.47 183 160 137 115 92 814 793 768 749 725 max: 814 average 10: 453 average total: 687 68 | 18:43.48 701 750 730 708 685 663 638 617 597 573 max: 750 average 10: 666 average total: 686 69 | 18:43.48 553 531 509 488 468 485 480 489 495 493 max: 553 average 10: 499 average total: 683 70 | 18:43.48 495 477 477 478 472 471 458 454 446 425 max: 495 average 10: 465 average total: 680 71 | 18:43.48 411 418 394 381 360 345 351 329 308 301 max: 418 average 10: 359 average total: 675 72 | 18:43.49 287 268 258 237 228 261 238 218 211 187 max: 287 average 10: 239 average total: 669 73 | 18:43.49 165 144 123 102 124 103 82 61 51 49 max: 165 average 10: 100 average total: 661 74 | 18:43.49 57 53 56 50 48 59 51 49 47 59 max: 59 average 10: 52 average total: 652 75 | 18:43.49 51 47 49 53 47 114 93 72 52 48 max: 114 average 10: 62 average total: 644 76 | 18:43.49 46 50 47 47 47 49 58 52 160 139 max: 160 average 10: 69 average total: 636 77 | 18:43.50 118 181 158 136 115 91 68 74 86 93 max: 181 average 10: 112 average total: 629 78 | 18:43.50 177 157 136 114 174 150 129 145 124 104 max: 177 average 10: 141 average total: 623 79 | 18:43.50 83 62 57 58 47 117 92 72 58 46 max: 117 average 10: 69 average total: 615 80 | 18:43.50 47 46 47 115 94 73 52 49 48 54 max: 115 average 10: 62 average total: 608 81 | 18:43.50 48 52 48 53 51 62 63 52 50 126 max: 126 average 10: 60 average total: 601 82 | 18:43.51 103 81 57 50 48 52 48 47 50 48 max: 103 average 10: 58 average total: 594 83 | 18:43.51 47 49 47 47 48 48 49 50 117 93 max: 117 average 10: 59 average total: 588 84 | 18:43.51 69 118 97 77 56 56 48 54 53 48 max: 118 average 10: 67 average total: 581 85 | 18:43.51 49 53 48 119 97 156 132 147 124 104 max: 156 average 10: 102 average total: 575 86 | 18:43.51 648 625 1028 1005 980 956 935 913 892 871 max: 1028 average 10: 885 average total: 579 87 | 18:43.52 850 825 805 783 759 739 717 695 673 651 max: 850 average 10: 749 average total: 581 88 | 18:43.52 704 709 694 699 774 772 751 752 730 708 max: 774 average 10: 729 average total: 583 89 | 18:43.53 704 715 716 826 806 787 802 781 759 737 max: 826 average 10: 763 average total: 585 90 | 18:43.53 726 704 715 719 719 712 717 727 715 718 max: 727 average 10: 717 average total: 587 91 | 18:43.53 726 710 719 714 1459 1485 1465 1444 1423 1400 max: 1485 average 10: 1154 average total: 593 92 | 18:43.54 1380 1359 1337 1313 1292 1272 1251 1228 1206 1186 max: 1380 average 10: 1282 average total: 601 93 | 18:43.54 1166 1189 1198 1177 1208 1193 1277 1254 1229 1209 max: 1277 average 10: 1210 average total: 607 8.6KB/s(in) 94 | 18:43.54 1217 1229 1236 1245 1334 1311 1289 1298 1301 1276 max: 1334 average 10: 1273 average total: 615 95 | 18:43.55 1288 1290 1301 1301 1309 1317 1322 1321 1439 1439 max: 1439 average 10: 1332 average total: 623 96 | 18:43.55 1455 1435 1414 1414 1413 1389 1392 1395 1396 1409 max: 1455 average 10: 1411 average total: 631 97 | 18:43.55 1398 1466 1445 1420 1400 1481 1461 1440 1419 1430 max: 1481 average 10: 1436 average total: 640 98 | 18:43.55 1434 1413 1421 1422 1421 1426 1434 1436 1436 1439 max: 1439 average 10: 1428 average total: 648 99 | 18:43.56 1442 1441 1431 1429 1437 1437 1436 1416 1411 1411 max: 1442 average 10: 1429 average total: 656 100 | 18:43.56 1402 1400 1402 1394 1394 1386 1390 1378 1377 1896 max: 1896 average 10: 1441 average total: 664 101 | 18:43.56 1871 1849 1828 1807 1785 1762 1741 1720 1699 1675 max: 1871 average 10: 1773 average total: 675 102 | 18:43.56 1650 1626 1603 1581 1557 1534 1567 1563 1563 1542 max: 1650 average 10: 1578 average total: 685 103 | 18:43.57 1541 1540 1530 1542 1522 1522 1522 1512 1519 1504 max: 1542 average 10: 1525 average total: 693 104 | 18:43.57 1506 1500 1496 1487 1481 1461 1457 1449 1443 1440 max: 1506 average 10: 1472 average total: 701 105 | 18:43.57 1425 1422 2095 2072 2048 2027 2005 1980 1958 1937 max: 2095 average 10: 1896 average total: 712 106 | 18:43.58 1916 1896 1873 1853 1832 1812 1796 1772 1752 1731 max: 1916 average 10: 1823 average total: 723 107 | 18:43.58 1747 1790 1775 1760 1770 1780 1773 1849 1825 1805 max: 1849 average 10: 1787 average total: 733 108 | 18:43.58 1784 1781 1801 1806 1808 1985 2892 2871 2847 2827 max: 2892 average 10: 2240 average total: 748 109 | 18:43.59 2806 2784 2760 2740 2719 2698 2677 2656 2633 2613 max: 2806 average 10: 2708 average total: 766 110 | 18:43.59 2593 2573 2608 2587 2564 2599 2611 2617 2625 2604 max: 2625 average 10: 2598 average total: 783 111 | 18:43.59 2607 2605 2701 2681 2656 2635 2642 2656 2642 2649 max: 2701 average 10: 2647 average total: 801 112 | 18:44.0 2654 2663 2670 2666 2670 2648 2646 2647 2652 2645 max: 2670 average 10: 2656 average total: 818 113 | 18:44.0 2651 2650 2650 2647 2642 2650 2644 2637 2643 2638 max: 2651 average 10: 2645 average total: 834 114 | 18:44.0 2631 2610 2606 2597 2597 2593 2587 2582 2577 2572 max: 2631 average 10: 2595 average total: 850 115 | 18:44.0 2563 2559 2545 2541 2538 2524 2517 2495 2487 2483 max: 2563 average 10: 2525 average total: 865 116 | 18:44.0 2472 2467 2464 2454 2446 2437 2419 2408 2396 2388 max: 2472 average 10: 2435 average total: 879 117 | 18:44.0 2416 2395 2372 2349 2324 2323 2328 2357 2334 2311 max: 2416 average 10: 2350 average total: 892 118 | 18:44.1 2286 2263 2239 2234 2230 2212 2830 2810 2784 2764 max: 2830 average 10: 2465 average total: 906 119 | 18:44.1 2744 2719 2698 2677 2656 2635 2613 2592 2571 2550 max: 2744 average 10: 2645 average total: 921 120 | 18:44.1 2529 2509 2485 2465 2444 2420 2442 2442 2444 2436 max: 2529 average 10: 2461 average total: 934 121 | 18:44.1 2439 2427 2431 2421 2422 2470 2450 2429 2408 2385 max: 2470 average 10: 2428 average total: 946 122 | 18:44.2 2383 2363 2371 2356 2354 2413 2390 2370 2349 2353 max: 2413 average 10: 2370 average total: 958 123 | 18:44.2 2342 2347 2408 2387 2365 2414 2392 2371 2348 2326 max: 2414 average 10: 2370 average total: 970 124 | 18:44.2 2328 2324 2326 2326 2328 2329 2329 2330 2323 2320 max: 2330 average 10: 2326 average total: 981 125 | 18:44.2 2325 2322 2313 2293 2293 2291 2283 2342 2321 2300 max: 2342 average 10: 2308 average total: 992 126 | 18:44.2 2280 2282 2278 2261 2267 2254 2251 2240 2243 2220 max: 2282 average 10: 2257 average total: 1002 127 | 18:44.2 2208 2196 2196 2285 2276 2265 2245 2225 2208 2187 max: 2285 average 10: 2229 average total: 1012 128 | 18:44.3 2166 2164 2156 2159 2146 2121 2114 2179 2155 2135 max: 2179 average 10: 2149 average total: 1021 129 | 18:44.3 2114 2162 2140 2143 2121 2097 2074 2071 2072 2064 max: 2162 average 10: 2105 average total: 1030 130 | 18:44.3 2065 2040 2024 2022 2083 2063 2043 2021 2021 2019 max: 2083 average 10: 2040 average total: 1038 131 | 18:44.3 2083 2061 2041 2016 2408 2387 2366 2345 2324 2304 max: 2408 average 10: 2233 average total: 1047 132 | 18:44.4 2280 2260 2240 2220 2199 2175 2154 2131 2108 2088 max: 2280 average 10: 2185 average total: 1056 133 | 18:44.4 2067 2046 2136 2137 2117 2096 2098 2111 2116 2112 max: 2137 average 10: 2103 average total: 1064 134 | 18:44.4 2112 2113 2111 2116 2108 2107 2094 2097 2091 2071 max: 2116 average 10: 2102 average total: 1072 135 | 18:44.4 2118 2098 2075 2051 2030 2028 2020 2011 1997 2057 max: 2118 average 10: 2048 average total: 1079 136 | 18:44.4 2035 2015 1992 1970 1975 1951 1937 1929 1927 1911 max: 2035 average 10: 1964 average total: 1086 8.5KB/s(in) 137 | 18:44.4 1903 1906 1893 1883 1878 1878 1866 1864 1852 1851 max: 1906 average 10: 1877 average total: 1092 138 | 18:44.4 1834 1809 1805 1793 1783 1774 1758 1747 1737 1779 max: 1834 average 10: 1781 average total: 1097 139 | 18:44.5 1755 1734 1742 1722 1700 1677 1657 1633 1610 1586 max: 1755 average 10: 1681 average total: 1101 140 | 18:44.5 1575 1560 1554 1542 1521 1515 1498 1490 1487 1464 max: 1575 average 10: 1520 average total: 1105 141 | 18:44.5 1452 1438 1480 1460 1438 1439 1418 1398 1376 1356 max: 1480 average 10: 1425 average total: 1107 142 | 18:44.5 1341 1386 1365 1344 1324 1303 1746 1725 1704 1682 max: 1746 average 10: 1492 average total: 1110 143 | 18:44.5 1661 1638 1617 1597 1576 1556 1532 1510 1489 1469 max: 1661 average 10: 1564 average total: 1113 144 | 18:44.5 1447 1425 1400 1377 1354 1330 1306 1340 1330 1315 max: 1447 average 10: 1362 average total: 1115 145 | 18:44.5 1304 1294 1284 1283 1276 1263 1254 1246 1235 1228 max: 1304 average 10: 1266 average total: 1116 146 | 18:44.6 1218 1196 1187 1174 1166 1160 1149 1135 1124 1117 max: 1218 average 10: 1162 average total: 1116 147 | 18:44.6 1106 1094 1083 1072 1051 1038 1096 1518 1498 1475 max: 1518 average 10: 1203 average total: 1117 148 | 18:44.6 1450 1429 1409 1388 1364 1344 1323 1303 1283 1260 max: 1450 average 10: 1355 average total: 1118 149 | 18:44.6 1237 1215 1194 1170 1150 1128 1107 1128 1121 1111 max: 1237 average 10: 1156 average total: 1118 150 | 18:44.6 1098 1088 1072 1062 1049 1041 1030 1012 1013 992 max: 1098 average 10: 1045 average total: 1118 151 | 18:44.6 971 961 940 932 926 906 884 877 864 846 max: 971 average 10: 910 average total: 1117 152 | 18:44.6 832 818 811 800 783 762 754 735 775 754 max: 832 average 10: 782 average total: 1114 153 | 18:44.7 734 713 693 672 650 629 619 599 590 572 max: 734 average 10: 647 average total: 1111 154 | 18:44.7 628 608 588 567 546 525 501 480 459 439 max: 628 average 10: 534 average total: 1107 155 | 18:44.7 421 412 391 462 456 437 417 396 372 351 max: 462 average 10: 411 average total: 1103 156 | 18:44.7 331 311 347 346 324 302 282 262 241 218 max: 347 average 10: 296 average total: 1098 157 | 18:44.7 195 183 179 160 138 132 109 97 85 74 max: 195 average 10: 135 average total: 1091 158 | 18:44.7 67 52 116 96 75 53 51 49 68 49 max: 116 average 10: 67 average total: 1085 159 | 18:44.7 49 47 118 93 73 146 125 105 84 63 max: 146 average 10: 90 average total: 1078 160 | 18:44.7 51 123 102 81 61 119 95 70 49 126 max: 126 average 10: 87 average total: 1072 161 | 18:44.8 104 79 71 85 61 118 96 76 55 57 max: 118 average 10: 80 average total: 1066 162 | 18:44.8 120 97 76 56 64 128 107 86 65 69 max: 128 average 10: 86 average total: 1060 163 | 18:44.8 72 72 79 91 115 117 97 101 80 67 max: 117 average 10: 89 average total: 1053 164 | 18:44.8 49 51 53 51 49 117 96 143 128 105 max: 143 average 10: 84 average total: 1047 165 | 18:44.9 81 79 65 48 46 54 50 121 100 79 max: 121 average 10: 72 average total: 1041 166 | 18:44.9 55 714 694 671 647 626 605 580 558 534 max: 714 average 10: 568 average total: 1039 167 | 18:44.9 513 492 471 449 429 409 386 366 346 488 max: 513 average 10: 434 average total: 1035 168 | 18:44.10 475 454 433 410 393 370 374 384 368 1105 max: 1105 average 10: 476 average total: 1031 169 | 18:44.10 1085 1063 1039 1013 993 972 951 929 905 885 max: 1085 average 10: 983 average total: 1031 170 | 18:44.10 864 843 908 887 865 845 930 914 954 1049 max: 1049 average 10: 905 average total: 1030 171 | 18:44.11 1027 1006 984 963 1070 1044 1024 1069 1048 1090 max: 1090 average 10: 1032 average total: 1030 172 | 18:44.11 1065 1044 1019 1031 1042 1079 1062 1236 1215 1195 max: 1236 average 10: 1098 average total: 1031 173 | 18:44.11 1237 1214 1193 1169 1148 1183 1202 1238 1224 1259 max: 1259 average 10: 1206 average total: 1032 174 | 18:44.12 1253 1392 1372 1454 1434 1412 1390 1370 1386 1364 max: 1454 average 10: 1382 average total: 1034 175 | 18:44.12 1383 1393 1483 1473 1470 1484 1514 1725 1715 1728 max: 1728 average 10: 1536 average total: 1037 176 | 18:44.13 1707 1687 1663 1642 2516 2494 2471 2449 2427 2402 max: 2516 average 10: 2145 average total: 1043 177 | 18:44.13 2382 2362 2339 2317 2626 2605 2584 2563 2540 2519 max: 2626 average 10: 2483 average total: 1052 178 | 18:44.14 2496 2474 2454 3118 3098 3075 3055 3029 3008 2988 max: 3118 average 10: 2879 average total: 1062 8.2KB/s(in) 179 | 18:44.14 2963 2942 2921 2898 2878 2856 3359 3339 3314 3293 max: 3359 average 10: 3076 average total: 1073 180 | 18:44.15 3268 3248 3226 3205 3311 3289 3267 3360 3369 3362 max: 3369 average 10: 3290 average total: 1086 181 | 18:44.15 3382 3399 3405 3385 3372 3360 3360 3463 3442 3421 max: 3463 average 10: 3398 average total: 1099 182 | 18:44.16 3397 3372 3350 3391 3367 3347 3364 3343 3319 3297 max: 3397 average 10: 3354 average total: 1112 183 | 18:44.16 3275 3255 3235 3278 3258 3237 3217 3194 3172 3164 max: 3278 average 10: 3228 average total: 1123 184 | 18:44.16 3157 3136 3125 3127 3113 3091 3103 3083 3094 3074 max: 3157 average 10: 3110 average total: 1134 185 | 18:44.16 3168 3148 3128 3108 3086 3066 3114 3112 3091 3069 max: 3168 average 10: 3109 average total: 1145 186 | 18:44.16 3048 3028 3006 2986 2963 2939 2914 2893 2872 2848 max: 3048 average 10: 2949 average total: 1155 187 | 18:44.16 2828 2971 2950 2927 2907 2885 2861 2838 2817 2797 max: 2971 average 10: 2878 average total: 1164 188 | 18:44.16 2775 2753 2729 2708 2688 2668 2646 2622 2746 2726 max: 2775 average 10: 2706 average total: 1173 189 | 18:44.16 2721 2697 2675 2712 2717 2696 2674 2651 2630 2606 max: 2721 average 10: 2677 average total: 1181 190 | 18:44.16 2620 2599 2586 2562 2540 2520 2495 2475 2454 2434 max: 2620 average 10: 2528 average total: 1188 191 | 18:44.17 2409 2383 2359 2440 2420 2399 2378 2358 2407 2385 max: 2440 average 10: 2393 average total: 1194 192 | 18:44.17 2362 2925 2905 2884 2864 2843 2819 2799 2779 2758 max: 2925 average 10: 2793 average total: 1203 193 | 18:44.17 2737 2716 2694 2672 2650 2628 2605 2709 2688 2667 max: 2737 average 10: 2676 average total: 1211 194 | 18:44.17 2644 2623 2603 2580 2555 2644 2773 2748 2724 3698 max: 3698 average 10: 2759 average total: 1219 195 | 18:44.19 3676 3655 3632 3607 3582 3557 3536 3516 3623 3602 max: 3676 average 10: 3598 average total: 1231 196 | 18:44.19 3581 3556 3531 3506 3482 3458 3437 3416 3393 3372 max: 3581 average 10: 3473 average total: 1243 197 | 18:44.19 3350 3500 3480 4318 4293 4271 4247 4225 4200 4176 max: 4318 average 10: 4006 average total: 1257 198 | 18:44.20 4152 4131 4109 4088 4068 4048 4026 4002 3982 3957 max: 4152 average 10: 4056 average total: 1271 199 | 18:44.20 3933 3912 3891 3870 3849 3828 3808 3945 3957 3962 max: 3962 average 10: 3895 average total: 1285 200 | 18:44.20 4153 4133 4109 4088 4137 4146 4125 4136 4145 4123 max: 4153 average 10: 4129 average total: 1299 201 | 18:44.20 4099 4078 4057 4199 4201 4177 4154 4132 4151 4130 max: 4201 average 10: 4137 average total: 1313 202 | 18:44.21 4109 4143 4121 4100 4079 4055 4038 4060 4066 4075 max: 4143 average 10: 4084 average total: 1327 203 | 18:44.21 4080 4076 4073 4260 4238 4214 4194 4234 4214 4190 max: 4260 average 10: 4177 average total: 1342 204 | 18:44.21 4169 4144 4119 4094 4072 4085 4098 4101 4097 4106 max: 4169 average 10: 4108 average total: 1355 205 | 18:44.21 4115 4121 4135 4110 4093 4092 4264 4241 4220 4256 max: 4264 average 10: 4164 average total: 1369 206 | 18:44.22 4258 4236 4211 4191 4171 4148 4127 4143 4145 4122 max: 4258 average 10: 4175 average total: 1383 207 | 18:44.22 4146 4129 4127 4132 4137 4161 4168 4164 4159 4163 max: 4168 average 10: 4148 average total: 1397 208 | 18:44.22 4159 4160 4168 4179 4169 4328 4338 4317 4297 4273 max: 4338 average 10: 4238 average total: 1411 209 | 18:44.22 4253 4232 4207 4184 4164 4144 4233 4210 5942 5920 max: 5942 average 10: 4548 average total: 1426 210 | 18:44.24 5898 5877 5855 5833 5811 5787 5763 5737 5712 5691 max: 5898 average 10: 5796 average total: 1447 211 | 18:44.24 5671 5646 5625 5602 5579 5559 5538 5517 5497 5476 max: 5671 average 10: 5571 average total: 1467 212 | 18:44.24 5494 5544 5524 5499 5477 5456 5436 5435 5421 5410 max: 5544 average 10: 5469 average total: 1486 213 | 18:44.24 5405 5400 5392 5372 5357 5407 5386 5364 5343 5322 max: 5407 average 10: 5374 average total: 1504 6.9KB/s(in) 214 | 18:44.24 5320 5313 5359 5335 5311 5286 5339 5316 5292 5289 max: 5359 average 10: 5316 average total: 1522 215 | 18:44.25 5267 5315 5294 5272 5252 5229 5229 5230 5224 5223 max: 5315 average 10: 5253 average total: 1540 216 | 18:44.25 5225 5217 5214 5203 5204 5182 5182 5177 5165 5164 max: 5225 average 10: 5193 average total: 1557 217 | 18:44.25 5152 5154 5139 5132 5133 5116 5108 5110 5091 5080 max: 5154 average 10: 5121 average total: 1574 218 | 18:44.25 5075 5054 5046 5039 5028 5023 5014 5006 4998 4983 max: 5075 average 10: 5026 average total: 1590 219 | 18:44.25 4982 4958 4951 4946 4999 4975 4951 4927 4935 4914 max: 4999 average 10: 4953 average total: 1605 220 | 18:44.25 4891 4866 4865 4866 4850 4849 4837 4900 4880 4855 max: 4900 average 10: 4865 average total: 1620 221 | 18:44.26 4831 4806 4809 4789 4776 4769 4766 4759 4751 4747 max: 4831 average 10: 4780 average total: 1635 222 | 18:44.26 4729 4737 4724 4724 4731 4712 4706 4773 4751 4731 max: 4773 average 10: 4731 average total: 1649 223 | 18:44.26 4706 4686 4665 4640 4676 4655 4630 4610 4588 4585 max: 4706 average 10: 4644 average total: 1663 224 | 18:44.26 4593 4581 4582 4570 4613 4593 4572 4552 4580 4635 max: 4635 average 10: 4587 average total: 1676 225 | 18:44.26 4613 5293 5268 5243 5220 5199 5179 5159 5134 5110 max: 5293 average 10: 5141 average total: 1692 226 | 18:44.27 5085 5064 5043 5022 5000 4979 4954 4932 4908 4939 max: 5085 average 10: 4992 average total: 1706 227 | 18:44.27 4940 4945 4943 4946 4951 5012 4990 4970 4950 4955 max: 5012 average 10: 4960 average total: 1721 228 | 18:44.27 4963 4971 4962 4964 5037 5017 4994 4973 4984 4984 max: 5037 average 10: 4984 average total: 1735 229 | 18:44.27 4985 4986 4989 4966 4963 4967 4967 4972 4975 4975 max: 4989 average 10: 4974 average total: 1750 230 | 18:44.28 4972 4976 4972 4968 4968 4974 5058 5056 5034 5014 max: 5058 average 10: 4999 average total: 1764 231 | 18:44.28 4991 4970 4991 4975 4968 4970 4967 4963 5044 5023 max: 5044 average 10: 4986 average total: 1778 232 | 18:44.28 5003 4982 4956 4955 4954 4933 4991 4968 5020 5028 max: 5028 average 10: 4979 average total: 1792 233 | 18:44.28 5003 4980 5028 5006 4984 4982 4989 4997 4994 5099 max: 5099 average 10: 5006 average total: 1806 234 | 18:44.29 5077 5057 5035 5014 4995 5021 5001 5000 4999 5003 max: 5077 average 10: 5020 average total: 1820 235 | 18:44.29 5008 5006 5006 5007 5006 5079 5058 5038 5017 4995 max: 5079 average 10: 5022 average total: 1834 236 | 18:44.29 4974 4972 4961 4952 4956 4943 4934 4925 4920 4909 max: 4974 average 10: 4944 average total: 1847 237 | 18:44.29 4900 4903 4888 4868 4855 4846 4896 4876 4856 4881 max: 4903 average 10: 4876 average total: 1860 238 | 18:44.29 4859 4838 4870 4849 4829 4806 4802 4787 4772 4749 max: 4870 average 10: 4816 average total: 1873 239 | 18:44.29 4753 4801 4781 4758 4734 4786 4763 4743 4723 4703 max: 4801 average 10: 4754 average total: 1885 240 | 18:44.30 4701 4692 4692 4692 4688 4664 4653 4650 4645 4648 max: 4701 average 10: 4672 average total: 1897 241 | 18:44.30 4702 4682 4659 4639 4639 4653 4630 4621 4631 4609 max: 4702 average 10: 4646 average total: 1908 242 | 18:44.30 4602 4581 4577 4568 4570 4558 4552 4551 4543 4534 max: 4602 average 10: 4563 average total: 1919 243 | 18:44.30 4535 4522 4520 4507 4486 4476 4463 4442 4437 4417 max: 4535 average 10: 4480 average total: 1930 244 | 18:44.30 4410 4394 4377 4420 4398 4377 4356 4336 4316 4295 max: 4420 average 10: 4367 average total: 1940 245 | 18:44.30 4275 4250 4229 4205 4190 4182 4162 4148 4127 4117 max: 4275 average 10: 4188 average total: 1949 246 | 18:44.30 4097 4078 4071 4054 4035 4015 4003 3993 3986 3965 max: 4097 average 10: 4029 average total: 1958 247 | 18:44.30 4018 3996 3975 3955 3931 3911 3890 3866 3844 3827 max: 4018 average 10: 3921 average total: 1966 248 | 18:44.30 3820 3799 3799 3777 3756 3785 3764 3744 3748 3724 max: 3820 average 10: 3771 average total: 1973 249 | 18:44.31 3699 3675 3654 3634 3610 3590 3584 3561 3566 3546 max: 3699 average 10: 3611 average total: 1980 250 | 18:44.31 3526 3504 3497 3481 3472 3463 3438 3432 3414 3405 max: 3526 average 10: 3463 average total: 1986 251 | 18:44.31 3387 3379 3373 3354 3348 3329 3321 3300 3289 3271 max: 3387 average 10: 3335 average total: 1991 252 | 18:44.31 3258 3243 3235 3212 3199 3195 3173 3158 3147 3189 max: 3258 average 10: 3200 average total: 1996 253 | 18:44.31 3165 3144 3119 3099 3077 3099 3074 3051 3030 3008 max: 3165 average 10: 3086 average total: 2001 254 | 18:44.31 2988 2980 2971 2970 2947 2939 2915 2905 2907 2884 max: 2988 average 10: 2940 average total: 2004 255 | 18:44.31 2861 2851 2844 2823 2816 2864 2840 2818 2793 2769 max: 2864 average 10: 2827 average total: 2008 256 | 18:44.31 2746 2799 2777 2755 2730 2709 2688 2664 2641 2694 max: 2799 average 10: 2720 average total: 2010 257 | 18:44.31 2673 2665 2640 2616 2595 2590 2577 2576 2566 2564 max: 2673 average 10: 2606 average total: 2013 258 | 18:44.31 2602 2582 2562 2542 2520 2521 2513 2501 2507 2554 max: 2602 average 10: 2540 average total: 2015 259 | 18:44.32 2533 2513 2489 2492 2483 2468 2467 2442 2434 2433 max: 2533 average 10: 2475 average total: 2017 260 | 18:44.32 2422 2424 2417 2407 2412 2396 2448 2428 2406 2386 max: 2448 average 10: 2414 average total: 2018 261 | 18:44.32 2364 2437 2416 2395 2374 2350 2338 2337 2336 2398 max: 2437 average 10: 2374 average total: 2020 262 | 18:44.32 2378 2359 2338 2346 2337 2338 2337 2330 2328 2304 max: 2378 average 10: 2339 average total: 2021 263 | 18:44.32 2298 2306 2307 2296 2290 2282 2339 2315 2324 2298 max: 2339 average 10: 2305 average total: 2022 264 | 18:44.32 2275 2253 2232 2286 2266 2241 2221 2197 2177 2152 max: 2286 average 10: 2230 average total: 2023 265 | 18:44.32 2138 2133 2708 2688 2665 2641 2619 2598 2575 2555 max: 2708 average 10: 2532 average total: 2025 266 | 18:44.33 2530 2507 2487 2467 2446 2422 2402 2378 2355 2334 max: 2530 average 10: 2432 average total: 2026 267 | 18:44.33 2313 2333 2326 2325 2311 2304 2305 2285 2282 2271 max: 2333 average 10: 2305 average total: 2027 268 | 18:44.33 2263 2253 2239 2228 2295 2284 2264 2243 2223 2199 max: 2295 average 10: 2249 average total: 2028 269 | 18:44.33 2179 2178 2169 2148 2139 2123 2113 2110 2093 2085 max: 2179 average 10: 2133 average total: 2029 270 | 18:44.33 2079 2073 2050 2042 2109 2089 2066 2043 2024 2003 max: 2109 average 10: 2057 average total: 2029 271 | 18:44.34 1981 1963 1951 1939 1930 1918 1906 1897 1889 1874 max: 1981 average 10: 1924 average total: 2028 272 | 18:44.34 1863 1852 1840 1833 1821 1800 1790 1780 1793 1773 max: 1863 average 10: 1814 average total: 2027 273 | 18:44.34 1753 1737 1720 1734 1713 1693 1672 1660 1645 1635 max: 1753 average 10: 1696 average total: 2026 274 | 18:44.34 1621 1600 1590 1569 1559 1543 1534 1514 1500 1491 max: 1621 average 10: 1552 average total: 2024 275 | 18:44.34 1470 1455 1433 1426 1405 1386 1369 1347 1348 1328 max: 1470 average 10: 1396 average total: 2022 276 | 18:44.34 1308 1334 1313 1293 1272 1273 1252 1232 1211 1190 max: 1334 average 10: 1267 average total: 2019 277 | 18:44.34 1170 1150 1130 1109 1128 1113 1091 1066 1044 1020 max: 1170 average 10: 1102 average total: 2016 278 | 18:44.34 997 1013 993 973 951 929 907 883 863 839 max: 1013 average 10: 934 average total: 2012 279 | 18:44.34 816 800 781 828 808 788 765 769 747 724 max: 828 average 10: 782 average total: 2008 280 | 18:44.34 700 680 659 638 618 597 582 620 612 591 max: 700 average 10: 629 average total: 2003 281 | 18:44.34 567 542 535 514 493 518 495 474 454 434 max: 567 average 10: 502 average total: 1997 282 | -------------------------------------------------------------------------------- /bench_mark_log/udt_stream_500.log: -------------------------------------------------------------------------------- 1 | ./udt_bench_mark/udt_stream_client/udt_stream_client 22001 120.26.200.117 23456 500 2>./state.log 2 | connect to: 120.26.200.117 23456 3 | Run UDT client loop ... 4 | 235 183 190 182 153 130 192 183 192 949 max: 949 average 10: 258 average total: 258 0KB/s(in) 5 | 19:58.44 900 846 979 928 1157 1329 1705 1655 2617 2562 max: 2617 average 10: 1467 average total: 863 6 | 19:58.46 2507 2453 2399 2475 2643 2783 2890 2893 2906 2916 max: 2916 average 10: 2686 average total: 1471 7 | 19:58.47 2925 2930 2928 2934 2931 2926 2932 2877 2854 2845 max: 2934 average 10: 2908 average total: 1830 8 | 19:58.47 2832 2826 2773 2751 2697 2644 2630 2578 2523 2469 max: 2832 average 10: 2672 average total: 1998 9 | 19:58.48 2452 2431 2415 2393 2373 2319 2295 2271 2249 2226 max: 2452 average 10: 2342 average total: 2056 10 | 19:58.48 2200 2175 2149 2125 2093 2066 2015 1988 1960 1908 max: 2200 average 10: 2067 average total: 2057 11 | 19:58.48 1875 1847 1795 1762 1708 1657 1626 1574 1523 1494 max: 1875 average 10: 1686 average total: 2011 12 | 19:58.48 1458 1424 1392 1360 1330 1277 1238 1206 1173 1122 max: 1458 average 10: 1298 average total: 1932 13 | 19:58.48 1087 1055 1019 983 950 898 862 825 790 752 max: 1087 average 10: 922 average total: 1831 14 | 19:58.49 714 676 622 584 544 508 457 417 369 338 max: 714 average 10: 522 average total: 1712 15 | 19:58.49 291 255 201 160 123 90 57 50 60 90 max: 291 average 10: 137 average total: 1580 16 | 19:58.49 76 102 203 150 99 1263 1247 1194 1142 1088 max: 1263 average 10: 656 average total: 1509 17 | 19:58.50 1037 1027 973 920 924 873 818 830 776 721 max: 1037 average 10: 889 average total: 1465 18 | 19:58.51 690 636 584 542 743 689 638 586 535 513 max: 743 average 10: 615 average total: 1408 19 | 19:58.51 459 408 354 303 253 1023 972 922 870 819 max: 1023 average 10: 638 average total: 1360 20 | 19:58.52 767 716 662 610 558 507 454 401 347 295 max: 767 average 10: 531 average total: 1311 21 | 19:58.52 326 306 253 385 361 344 319 292 264 209 max: 385 average 10: 305 average total: 1256 22 | 19:58.52 210 172 122 222 167 114 150 97 72 50 max: 222 average 10: 137 average total: 1197 23 | 19:58.53 47 226 171 4515 4463 4409 4358 4307 4257 4206 max: 4515 average 10: 3095 average total: 1292 7.1KB/s(in) 24 | 19:58.57 4154 4103 4049 3995 3941 3889 3835 3781 3726 3672 max: 4154 average 10: 3914 average total: 1416 25 | 19:58.57 3685 3637 3584 3534 3479 3425 3373 3319 3267 3387 max: 3685 average 10: 3469 average total: 1510 26 | 19:58.57 3335 3281 3251 3200 3148 4133 4079 4028 3977 3922 max: 4133 average 10: 3635 average total: 1602 27 | 19:58.59 3867 3813 3762 3712 3657 3606 3554 3500 3447 3394 max: 3867 average 10: 3631 average total: 1687 28 | 19:58.59 3342 3289 3237 3187 3137 3084 3030 2976 3680 3628 max: 3680 average 10: 3259 average total: 1750 29 | 19:58.59 3577 3524 3472 3421 3367 3316 3274 3220 3168 3130 max: 3577 average 10: 3346 average total: 1811 30 | 19:58.59 3079 3026 2994 2940 2888 2834 2793 2780 4049 3995 max: 4049 average 10: 3137 average total: 1860 31 | 19:59.1 4082 4032 3977 3925 3872 3818 3764 3777 3723 3670 max: 4082 average 10: 3864 average total: 1932 32 | 19:59.1 3616 3737 3743 4065 4062 4012 3960 3909 3898 4025 max: 4065 average 10: 3902 average total: 2000 33 | 19:59.2 4271 4219 4169 4275 4221 4166 4114 4099 4101 5301 max: 5301 average 10: 4293 average total: 2076 34 | 19:59.4 5246 5195 5143 5089 5050 4997 4946 4892 4838 4784 max: 5246 average 10: 5018 average total: 2171 35 | 19:59.4 4750 4698 4646 4593 4539 4485 4574 4603 4619 4846 max: 4846 average 10: 4635 average total: 2248 36 | 19:59.4 4792 4741 4686 4778 4724 4670 4618 4566 4550 4556 max: 4792 average 10: 4668 average total: 2321 37 | 19:59.4 6736 6682 6916 6863 6811 6756 6705 6653 6599 6546 max: 6916 average 10: 6726 average total: 2451 38 | 19:59.7 6491 6437 6387 6331 6516 6462 6408 6356 6301 6249 max: 6516 average 10: 6393 average total: 2563 39 | 19:59.7 6301 6308 6550 6496 6441 6386 6331 6305 6279 6435 max: 6550 average 10: 6383 average total: 2670 7.4KB/s(in) 40 | 19:59.8 6384 6332 6559 6650 6597 7380 7326 7271 7220 7165 max: 7380 average 10: 6888 average total: 2784 41 | 19:59.9 7113 7059 7008 6955 6919 6866 6811 6759 6704 6748 max: 7113 average 10: 6894 average total: 2892 42 | 19:59.9 6696 6645 6591 6537 6483 6500 6537 6601 6597 6544 max: 6696 average 10: 6573 average total: 2986 43 | 19:59.10 9084 9033 8982 8931 8877 8824 8770 8719 8668 8615 max: 9084 average 10: 8850 average total: 3133 44 | 19:59.12 8560 8506 8456 8403 8348 8294 8239 8187 8134 8082 max: 8560 average 10: 8320 average total: 3259 45 | 19:59.12 8027 7974 7924 7872 7821 7770 7715 7662 7666 7634 max: 8027 average 10: 7806 average total: 3367 46 | 19:59.12 7599 7547 7511 7477 7442 7407 7372 7335 7280 7245 max: 7599 average 10: 7421 average total: 3462 47 | 19:59.12 7214 7189 7152 7116 7080 7058 7003 6964 6911 6858 max: 7214 average 10: 7054 average total: 3543 48 | 19:59.13 6810 6757 6730 6679 6637 6582 6529 6486 6432 6381 max: 6810 average 10: 6602 average total: 3611 49 | 19:59.13 6340 6307 6270 6215 6160 6124 6088 6048 6009 5972 max: 6340 average 10: 6153 average total: 3667 50 | 19:59.13 5936 5883 5841 5806 5752 5710 5672 5617 5579 5527 max: 5936 average 10: 5732 average total: 3711 51 | 19:59.13 5485 5442 5401 5362 5309 5268 5228 5188 5148 5111 max: 5485 average 10: 5294 average total: 3744 52 | 19:59.13 5070 5025 4987 4946 4907 4864 4822 4782 4741 4688 max: 5070 average 10: 4883 average total: 3767 53 | 19:59.13 4645 4591 4548 4497 4444 4392 4339 4296 4258 4205 max: 4645 average 10: 4421 average total: 3780 54 | 19:59.13 4163 4108 4067 4016 3962 3921 3871 3820 3769 3715 max: 4163 average 10: 3941 average total: 3783 55 | 19:59.13 3661 3622 3569 3515 3474 3421 3369 3331 3279 3224 max: 3661 average 10: 3446 average total: 3777 56 | 19:59.13 3174 3123 3082 3037 2989 2945 2894 2855 2807 2766 max: 3174 average 10: 2967 average total: 3761 57 | 19:59.13 2722 2677 2635 2581 2537 2494 2452 2421 2367 2316 max: 2722 average 10: 2520 average total: 3738 58 | 19:59.13 2263 2208 2162 2120 2075 2042 1991 1937 1883 1828 max: 2263 average 10: 2050 average total: 3708 59 | 19:59.13 1774 1722 1676 1635 1588 1545 1498 1455 1411 1366 max: 1774 average 10: 1567 average total: 3669 60 | 19:59.13 1331 1277 1226 1174 1123 1079 1036 995 953 903 max: 1331 average 10: 1109 average total: 3624 61 | 19:59.13 856 815 769 723 680 638 595 553 503 460 max: 856 average 10: 659 average total: 3573 62 | 19:59.14 418 374 330 288 246 202 153 109 66 48 max: 418 average 10: 223 average total: 3516 63 | 19:59.14 471 418 367 315 262 215 160 109 98 58 max: 471 average 10: 247 average total: 3462 64 | 19:59.14 49 47 50 54 52 52 49 49 47 48 max: 54 average 10: 49 average total: 3406 65 | 19:59.15 48 50 48 49 146 94 52 49 48 49 max: 146 average 10: 63 average total: 3352 66 | 19:59.15 47 48 48 47 50 61 51 49 49 47 max: 61 average 10: 49 average total: 3300 67 | 19:59.16 47 49 48 48 48 48 48 48 49 46 max: 49 average 10: 47 average total: 3249 68 | 19:59.16 48 47 48 49 48 48 50 50 51 202 max: 202 average 10: 64 average total: 3200 69 | 19:59.17 175 124 71 48 48 55 52 52 49 150 max: 175 average 10: 82 average total: 3153 70 | 19:59.17 98 53 48 47 49 48 48 49 48 52 max: 98 average 10: 54 average total: 3106 71 | 19:59.18 49 52 51 53 50 50 50 49 46 48 max: 53 average 10: 49 average total: 3061 15.4KB/s(in) 72 | 19:59.18 48 49 56 49 49 48 49 47 51 197 max: 197 average 10: 64 average total: 3018 73 | 19:59.19 165 111 61 48 46 49 49 53 48 47 max: 165 average 10: 67 average total: 2976 74 | 19:59.19 47 48 49 48 52 49 47 50 55 49 max: 55 average 10: 49 average total: 2935 75 | 19:59.20 47 145 92 51 50 48 49 48 49 147 max: 147 average 10: 72 average total: 2895 76 | 19:59.20 94 53 48 47 47 49 49 48 48 49 max: 94 average 10: 53 average total: 2856 77 | 19:59.21 48 48 47 49 48 49 49 49 49 49 max: 49 average 10: 48 average total: 2818 78 | 19:59.21 59 55 48 48 49 144 94 66 55 49 max: 144 average 10: 66 average total: 2781 79 | 19:59.22 48 50 149 94 52 50 51 49 48 48 max: 149 average 10: 63 average total: 2746 80 | 19:59.22 50 49 49 48 48 47 48 50 57 52 max: 57 average 10: 49 average total: 2711 81 | 19:59.23 49 48 48 48 49 48 48 48 49 49 max: 49 average 10: 48 average total: 2676 82 | 19:59.23 47 48 149 94 56 49 48 49 47 48 max: 149 average 10: 63 average total: 2643 83 | 19:59.24 48 48 48 47 49 49 48 49 49 61 max: 61 average 10: 49 average total: 2611 84 | 19:59.25 58 51 49 86 48 69 49 53 732 688 max: 732 average 10: 188 average total: 2581 85 | 19:59.26 636 586 534 483 432 381 331 276 225 173 max: 636 average 10: 405 average total: 2554 86 | 19:59.26 123 2398 2345 2295 2240 2187 2133 2083 2033 1978 max: 2398 average 10: 1981 average total: 2548 87 | 19:59.28 1928 1874 1824 1771 1718 1664 1612 1561 1555 1518 max: 1928 average 10: 1702 average total: 2537 88 | 19:59.28 1478 1438 1406 1355 1314 1267 1244 1193 1142 1094 max: 1478 average 10: 1293 average total: 2523 89 | 19:59.28 1051 1032 979 928 877 828 781 763 710 660 max: 1051 average 10: 860 average total: 2503 90 | 19:59.28 1033 979 925 875 820 767 713 662 611 560 max: 1033 average 10: 794 average total: 2484 9.1KB/s(in) 91 | 19:59.29 508 470 419 369 317 262 209 156 102 171 max: 508 average 10: 298 average total: 2459 92 | 19:59.29 122 68 67 147 96 61 47 48 49 50 max: 147 average 10: 75 average total: 2432 93 | 19:59.29 47 47 48 48 49 50 50 49 47 50 max: 50 average 10: 48 average total: 2406 94 | 19:59.30 48 51 47 48 48 49 52 166 115 63 max: 166 average 10: 68 average total: 2380 95 | 19:59.30 50 50 146 94 63 51 50 48 48 50 max: 146 average 10: 65 average total: 2355 96 | 19:59.31 55 57 70 148 94 62 49 50 48 48 max: 148 average 10: 68 average total: 2330 97 | 19:59.31 47 48 47 48 48 475 423 370 316 263 max: 475 average 10: 208 average total: 2308 98 | 19:59.32 208 157 105 98 67 49 48 49 49 50 max: 208 average 10: 88 average total: 2284 99 | 19:59.32 49 49 48 60 53 48 47 57 51 50 max: 60 average 10: 51 average total: 2261 100 | 19:59.33 54 49 52 50 49 48 48 51 56 62 max: 62 average 10: 51 average total: 2238 101 | 19:59.33 61 58 49 49 50 47 48 422 367 411 max: 422 average 10: 156 average total: 2217 102 | 19:59.34 361 311 259 209 159 107 54 49 49 49 max: 361 average 10: 160 average total: 2196 103 | 19:59.34 48 49 49 49 48 49 49 54 54 54 max: 54 average 10: 50 average total: 2175 104 | 19:59.35 48 48 48 48 47 48 49 49 49 49 max: 49 average 10: 48 average total: 2154 105 | 19:59.35 49 49 48 48 48 49 48 50 47 146 max: 146 average 10: 58 average total: 2133 106 | 19:59.36 95 51 48 49 52 153 102 155 103 57 max: 155 average 10: 86 average total: 2113 107 | 19:59.36 153 99 75 57 54 51 66 68 983 932 max: 983 average 10: 253 average total: 2095 108 | 19:59.38 882 828 778 723 669 678 628 576 570 519 max: 882 average 10: 685 average total: 2082 109 | 19:59.38 469 417 365 311 308 276 241 208 164 132 max: 469 average 10: 289 average total: 2065 110 | 19:59.38 94 143 94 66 48 47 48 49 48 50 max: 143 average 10: 68 average total: 2046 111 | 19:59.39 50 49 49 50 55 63 52 51 151 98 max: 151 average 10: 66 average total: 2028 10KB/s(in) 112 | 19:59.39 62 47 49 54 49 48 46 52 48 48 max: 62 average 10: 50 average total: 2010 113 | 19:59.40 49 49 48 50 49 48 49 48 51 48 max: 51 average 10: 48 average total: 1992 114 | 19:59.40 51 57 50 47 48 50 50 55 50 47 max: 57 average 10: 50 average total: 1975 115 | 19:59.41 47 51 48 49 48 47 48 50 49 50 max: 51 average 10: 48 average total: 1957 116 | 19:59.41 50 48 46 49 49 48 48 53 49 49 max: 53 average 10: 48 average total: 1940 117 | 19:59.42 48 50 48 49 47 47 49 50 47 49 max: 50 average 10: 48 average total: 1924 118 | 19:59.42 47 49 49 47 49 49 50 48 47 48 max: 50 average 10: 48 average total: 1908 119 | 19:59.43 54 48 48 49 147 93 50 48 49 47 max: 147 average 10: 63 average total: 1892 120 | 19:59.43 49 49 49 49 48 57 49 146 93 148 max: 148 average 10: 73 average total: 1876 121 | 19:59.44 95 52 54 48 49 55 54 65 147 93 max: 147 average 10: 71 average total: 1861 122 | 19:59.44 52 49 208 178 125 74 49 57 47 48 max: 208 average 10: 88 average total: 1846 123 | 19:59.45 50 50 48 75 84 63 54 53 169 115 max: 169 average 10: 76 average total: 1831 124 | 19:59.45 63 54 49 49 47 49 49 49 48 46 max: 63 average 10: 50 average total: 1816 125 | 19:59.46 48 49 48 148 94 64 49 48 50 47 max: 148 average 10: 64 average total: 1802 126 | 19:59.46 52 48 47 48 49 50 51 49 199 159 max: 199 average 10: 75 average total: 1788 127 | 19:59.47 108 66 48 48 48 47 48 50 201 170 max: 201 average 10: 83 average total: 1774 128 | 19:59.48 118 85 52 52 49 49 51 51 69 67 max: 118 average 10: 64 average total: 1761 129 | 19:59.48 49 51 50 55 49 63 50 55 48 48 max: 63 average 10: 51 average total: 1747 130 | 19:59.48 49 50 225 173 121 81 145 94 67 48 max: 225 average 10: 105 average total: 1734 131 | 19:59.49 165 112 59 57 51 53 49 48 49 53 max: 165 average 10: 69 average total: 1721 9.6KB/s(in) 132 | 19:59.49 50 54 59 57 49 74 59 48 47 47 max: 74 average 10: 54 average total: 1708 133 | 19:59.50 47 48 47 49 49 145 93 150 96 63 max: 150 average 10: 78 average total: 1696 134 | 19:59.51 49 51 46 46 46 49 48 49 147 96 max: 147 average 10: 62 average total: 1683 135 | 19:59.51 63 49 47 49 54 49 48 51 66 48 max: 66 average 10: 52 average total: 1671 136 | 19:59.52 48 48 170 116 145 94 64 49 147 93 max: 170 average 10: 97 average total: 1659 137 | 19:59.52 60 51 51 50 51 48 50 49 148 94 max: 148 average 10: 65 average total: 1647 138 | 19:59.53 67 48 49 47 52 48 49 48 50 49 max: 67 average 10: 50 average total: 1635 139 | 19:59.53 48 47 50 48 51 59 53 50 56 50 max: 59 average 10: 51 average total: 1624 140 | 19:59.54 49 48 48 48 52 48 48 48 49 51 max: 52 average 10: 48 average total: 1612 141 | 19:59.54 55 48 157 103 68 47 49 47 49 48 max: 157 average 10: 67 average total: 1601 142 | 19:59.55 49 148 94 146 95 63 48 47 47 48 max: 148 average 10: 78 average total: 1590 143 | 19:59.55 147 94 65 48 48 48 47 48 48 48 max: 147 average 10: 64 average total: 1579 144 | 19:59.56 52 49 47 48 50 151 96 64 49 146 max: 151 average 10: 75 average total: 1568 145 | 19:59.56 93 60 51 49 49 48 49 47 143 93 max: 143 average 10: 68 average total: 1558 146 | 19:59.57 62 49 49 47 49 49 49 149 95 69 max: 149 average 10: 66 average total: 1547 147 | 19:59.57 49 48 59 49 150 96 65 49 151 97 max: 151 average 10: 81 average total: 1537 148 | 19:59.58 64 148 96 64 49 48 48 49 48 48 max: 148 average 10: 66 average total: 1527 149 | 19:59.58 49 47 49 55 154 99 66 52 52 52 max: 154 average 10: 67 average total: 1517 150 | 19:59.59 53 50 46 154 99 68 49 48 47 49 max: 154 average 10: 66 average total: 1507 151 | 19:59.59 48 55 49 47 49 48 49 48 53 58 max: 58 average 10: 50 average total: 1497 9.6KB/s(in) 152 | 20:0.0 54 49 49 48 48 48 48 48 47 47 max: 54 average 10: 48 average total: 1488 153 | 20:0.0 47 48 49 49 49 49 48 47 48 47 max: 49 average 10: 48 average total: 1478 154 | 20:0.1 49 51 48 49 47 49 49 48 147 94 max: 147 average 10: 63 average total: 1469 155 | 20:0.1 67 48 47 149 94 65 49 48 50 47 max: 149 average 10: 66 average total: 1459 156 | 20:0.2 48 49 48 49 52 48 47 49 48 50 max: 52 average 10: 48 average total: 1450 157 | 20:0.2 48 48 48 47 48 49 48 48 49 47 max: 49 average 10: 48 average total: 1441 158 | 20:0.3 49 58 52 49 51 50 52 51 52 50 max: 58 average 10: 51 average total: 1432 159 | 20:0.3 49 49 48 48 49 48 46 47 49 48 max: 49 average 10: 48 average total: 1423 160 | 20:0.4 48 63 57 148 95 2405 2351 2301 2250 2198 max: 2405 average 10: 1191 average total: 1422 161 | 20:0.7 2148 2097 2044 1994 1942 1892 1839 1789 1735 1683 max: 2148 average 10: 1916 average total: 1425 162 | 20:0.7 1631 1581 1567 1522 1482 1450 1403 1359 1311 1271 max: 1631 average 10: 1457 average total: 1425 163 | 20:0.7 1230 1191 1149 1095 1056 1013 981 940 898 854 max: 1230 average 10: 1040 average total: 1423 164 | 20:0.7 816 767 781 730 678 624 572 520 485 434 max: 816 average 10: 640 average total: 1418 165 | 20:0.7 386 346 306 265 225 185 150 106 63 49 max: 386 average 10: 208 average total: 1410 166 | 20:0.7 47 49 48 46 49 47 47 49 47 48 max: 49 average 10: 47 average total: 1402 167 | 20:0.8 49 49 47 51 48 51 48 47 47 48 max: 51 average 10: 48 average total: 1394 168 | 20:0.8 51 47 50 48 48 48 47 48 49 48 max: 51 average 10: 48 average total: 1386 169 | 20:0.9 48 51 47 48 48 147 94 53 48 145 max: 147 average 10: 72 average total: 1378 170 | 20:0.9 93 50 48 48 48 50 48 49 47 49 max: 93 average 10: 53 average total: 1370 171 | 20:0.10 48 49 47 49 48 49 47 48 49 49 max: 49 average 10: 48 average total: 1362 9.6KB/s(in) 172 | 20:0.10 48 47 51 52 148 95 55 48 48 48 max: 148 average 10: 64 average total: 1354 173 | 20:0.11 49 48 49 48 50 47 48 48 48 47 max: 50 average 10: 48 average total: 1346 174 | -------------------------------------------------------------------------------- /install_pack/udt.sdk.4.11.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libinzhangyuan/reliable_udp_bench_mark/fcbf2c510558a61874ebed2d8249ac7632d91b1b/install_pack/udt.sdk.4.11.tar.gz -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ### A bench mark test for udp reliable protocal framework.
2 | 3 | The bench mark is for realtime pvp game. For example, the multiplayer first person shooting game.
4 | The requirement of realtime pvp game is packet is small and frequently.
5 | It wants a minimal delay. And the worst delay should be not so worse.
6 | The test client send 500 bytes in every 50 milliseconds. And the server send it back after receiving immediately.
7 | 8 | 9 | #### Three frameworks were tested, 10 | * [UDT](https://sourceforge.net/projects/udt/) - UDP-based Data Transfer Protocol 11 | * [kcp](https://github.com/skywind3000/kcp) - A Fast and Reliable ARQ Protocol 12 | * [enet](http://enet.bespin.org/index.html) - Reliable UDP networking library 13 | 14 | You can see the whole bench mark test result in [bench_mark.md](https://github.com/libinzhangyuan/reliable_udp_bench_mark/blob/master/bench_mark.md). 15 | -------------------------------------------------------------------------------- /udt_bench_mark/allmake.sh: -------------------------------------------------------------------------------- 1 | OLD_PWD="$( pwd )" 2 | 3 | #OS="LINUX" 4 | OS="OSX" 5 | 6 | ARCH="IA32" 7 | 8 | echo "" && echo "" && echo "" && echo "" && echo "" 9 | echo `date` 10 | echo "============================================================" 11 | echo " Compiling =====" 12 | echo "=========================================================" 13 | 14 | echo "" && echo "" && echo "[-------------------------------]" && echo " udt4" && echo "[-------------------------------]" && \ 15 | cd ./udt4/ && make -e os=$OS arch=$ARCH && \ 16 | echo "" && echo "" && echo "[-------------------------------]" && echo " udt_stream_server" && echo "[-------------------------------]" && \ 17 | cd ../udt_stream_server/ && make -e os=$OS arch=$ARCH && \ 18 | echo "" && echo "" && echo "[-------------------------------]" && echo " udt_stream_client" && echo "[-------------------------------]" && \ 19 | cd ../udt_stream_client/ && make -e os=$OS arch=$ARCH && \ 20 | echo "" && echo "" && echo "[-------------------------------]" && echo " udt_dgram_server" && echo "[-------------------------------]" && \ 21 | cd ../udt_dgram_server/ && make -e os=$OS arch=$ARCH && \ 22 | echo "" && echo "" && echo "[-------------------------------]" && echo " udt_dgram_client" && echo "[-------------------------------]" && \ 23 | cd ../udt_dgram_client/ && make -e os=$OS arch=$ARCH && \ 24 | echo "" 25 | 26 | # restore old path. 27 | cd $OLD_PWD 28 | -------------------------------------------------------------------------------- /udt_bench_mark/clean.sh: -------------------------------------------------------------------------------- 1 | OLD_PWD="$( pwd )" 2 | 3 | cd ./udt_dgram_server/ && make clean && \ 4 | cd ../udt_dgram_client/ && make clean && \ 5 | cd ../udt_stream_client/ && make clean && \ 6 | cd ../udt_stream_server/ && make clean && \ 7 | echo "" 8 | 9 | # restore old path. 10 | cd $OLD_PWD 11 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_client/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Generic Makefile for C/C++ Program 3 | # 4 | # License: GPL (General Public License) 5 | # Author: whyglinux 6 | # Date: 2006/03/04 (version 0.1) 7 | # 2007/03/24 (version 0.2) 8 | # 2007/04/09 (version 0.3) 9 | # 2007/06/26 (version 0.4) 10 | # 2008/04/05 (version 0.5) 11 | # 12 | # Description: 13 | # ------------ 14 | # This is an easily customizable makefile template. The purpose is to 15 | # provide an instant building environment for C/C++ programs. 16 | # 17 | # It searches all the C/C++ source files in the specified directories, 18 | # makes dependencies, compiles and links to form an executable. 19 | # 20 | # Besides its default ability to build C/C++ programs which use only 21 | # standard C/C++ libraries, you can customize the Makefile to build 22 | # those using other libraries. Once done, without any changes you can 23 | # then build programs using the same or less libraries, even if source 24 | # files are renamed, added or removed. Therefore, it is particularly 25 | # convenient to use it to build codes for experimental or study use. 26 | # 27 | # GNU make is expected to use the Makefile. Other versions of makes 28 | # may or may not work. 29 | # 30 | # Usage: 31 | # ------ 32 | # 1. Copy the Makefile to your program directory. 33 | # 2. Customize in the "Customizable Section" only if necessary: 34 | # * to use non-standard C/C++ libraries, set pre-processor or compiler 35 | # options to and linker ones to 36 | # (See Makefile.gtk+-2.0 for an example) 37 | # * to search sources in more directories, set to 38 | # * to specify your favorite program name, set to 39 | # 3. Type make to start building your program. 40 | # 41 | # Make Target: 42 | # ------------ 43 | # The Makefile provides the following targets to make: 44 | # $ make compile and link 45 | # $ make NODEP=yes compile and link without generating dependencies 46 | # $ make objs compile only (no linking) 47 | # $ make tags create tags for Emacs editor 48 | # $ make ctags create ctags for VI editor 49 | # $ make clean clean objects and the executable file 50 | # $ make distclean clean objects, the executable and dependencies 51 | # $ make help get the usage of the makefile 52 | # 53 | #=========================================================================== 54 | 55 | ## Customizable Section: adapt those variables to suit your program. 56 | ##========================================================================== 57 | 58 | OS_NAME="`uname -s`" 59 | LC_OS_NAME = $(shell echo $(OS_NAME) | tr '[A-Z]' '[a-z]') 60 | # MAC=darwin 61 | # CENTOS=linux 62 | 63 | # The pre-processor and compiler options. 64 | MY_CFLAGS = 65 | 66 | # The linker options. 67 | #MY_LIBS = $(BOOST_LIB_PATH)/libboost_system-mt.a $(BOOST_LIB_PATH)/libboost_filesystem-mt.a $(BOOST_LIB_PATH)/libboost_thread-mt.a $(PB_LIB_PATH)/libprotobuf.a ../essential/essential.a ../udt4/src/libudt.a 68 | MY_LIBS = ../udt4/src/libudt.a 69 | 70 | 71 | # The pre-processor options used by the cpp (man cpp for more). 72 | CPPFLAGS = -Wall -I ../udt4/src -g3 73 | 74 | # The options used in linking as well as in any direct use of ld. 75 | ifeq ($(LC_OS_NAME), darwin) 76 | LDFLAGS = -L/opt/local/lib -pthread 77 | else 78 | LDFLAGS = -L/opt/local/lib -pthread -lrt 79 | endif 80 | 81 | 82 | # The directories in which source files reside. 83 | # If not specified, only the current directory will be serached. 84 | SRCDIRS = ./ 85 | 86 | # The executable file name. 87 | # If not specified, current directory name or `a.out' will be used. 88 | PROGRAM = udt_dgram_client 89 | 90 | ## Implicit Section: change the following only when necessary. 91 | ##========================================================================== 92 | 93 | # The source file types (headers excluded). 94 | # .c indicates C source files, and others C++ ones. 95 | SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp 96 | 97 | # The header file types. 98 | HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp 99 | 100 | # The pre-processor and compiler options. 101 | # Users can override those variables from the command line. 102 | CFLAGS = 103 | CXXFLAGS= -std=c++11 104 | 105 | # The C program compiler. 106 | CC = gcc 107 | 108 | # The C++ program compiler. 109 | CXX = g++ 110 | 111 | # Un-comment the following line to compile C programs as C++ ones. 112 | #CC = $(CXX) 113 | 114 | # The command used to delete file. 115 | #RM = rm -f 116 | 117 | ETAGS = etags 118 | ETAGSFLAGS = 119 | 120 | CTAGS = ctags 121 | CTAGSFLAGS = 122 | 123 | ## Stable Section: usually no need to be changed. But you can add more. 124 | ##========================================================================== 125 | SHELL = /bin/sh 126 | EMPTY = 127 | SPACE = $(EMPTY) $(EMPTY) 128 | ifeq ($(PROGRAM),) 129 | q 130 | q 131 | q 132 | CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR))) 133 | PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES)) 134 | ifeq ($(PROGRAM),) 135 | PROGRAM = a.out 136 | endif 137 | endif 138 | ifeq ($(SRCDIRS),) 139 | SRCDIRS = . 140 | endif 141 | SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS)))) 142 | HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS)))) 143 | SRC_CXX = $(filter-out %.c,$(SOURCES)) 144 | OBJS = $(addsuffix .o, $(basename $(SOURCES))) 145 | 146 | ## Define some useful variables. 147 | DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \ 148 | echo "-MM -MP"; else echo "-M"; fi ) 149 | DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) 150 | COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c 151 | COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c 152 | LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) 153 | LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) 154 | 155 | .PHONY: all objs tags ctags clean distclean help show 156 | 157 | # Delete the default suffixes 158 | .SUFFIXES: 159 | 160 | all: $(PROGRAM) 161 | 162 | 163 | # Rules for generating object files (.o). 164 | #---------------------------------------- 165 | objs:$(OBJS) 166 | 167 | %.o:%.c 168 | $(COMPILE.c) $< -o $@ 169 | 170 | %.o:%.C 171 | $(COMPILE.cxx) $< -o $@ 172 | 173 | %.o:%.cc 174 | $(COMPILE.cxx) $< -o $@ 175 | 176 | %.o:%.cpp 177 | $(COMPILE.cxx) $< -o $@ 178 | 179 | %.o:%.CPP 180 | $(COMPILE.cxx) $< -o $@ 181 | 182 | %.o:%.c++ 183 | $(COMPILE.cxx) $< -o $@ 184 | 185 | %.o:%.cp 186 | $(COMPILE.cxx) $< -o $@ 187 | 188 | %.o:%.cxx 189 | $(COMPILE.cxx) $< -o $@ 190 | 191 | # Rules for generating the tags. 192 | #------------------------------------- 193 | tags: $(HEADERS) $(SOURCES) 194 | $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES) 195 | 196 | ctags: $(HEADERS) $(SOURCES) 197 | $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES) 198 | 199 | # Rules for generating the executable. 200 | #------------------------------------- 201 | $(PROGRAM):$(OBJS) 202 | ifeq ($(SRC_CXX),) # C program 203 | $(LINK.c) $(OBJS) $(MY_LIBS) -o $@ 204 | @echo Type ./$@ to execute the program. 205 | else # C++ program 206 | $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@ 207 | @echo Type ./$@ to execute the program. 208 | endif 209 | 210 | ifndef NODEP 211 | ifneq ($(DEPS),) 212 | sinclude $(DEPS) 213 | endif 214 | endif 215 | 216 | clean: 217 | $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe 218 | 219 | distclean: clean 220 | $(RM) $(DEPS) TAGS 221 | 222 | # Show help. 223 | help: 224 | @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5' 225 | @echo 'Copyright (C) 2007, 2008 whyglinux ' 226 | @echo 227 | @echo 'Usage: make [TARGET]' 228 | @echo 'TARGETS:' 229 | @echo ' all (=make) compile and link.' 230 | @echo ' NODEP=yes make without generating dependencies.' 231 | @echo ' objs compile only (no linking).' 232 | @echo ' tags create tags for Emacs editor.' 233 | @echo ' ctags create ctags for VI editor.' 234 | @echo ' clean clean objects and the executable file.' 235 | @echo ' distclean clean objects, the executable and dependencies.' 236 | @echo ' show show variables (for debug use only).' 237 | @echo ' help print this message.' 238 | @echo 239 | @echo 'Report bugs to .' 240 | 241 | # Show variables (for debug use only.) 242 | show: 243 | @echo 'PROGRAM :' $(PROGRAM) 244 | @echo 'SRCDIRS :' $(SRCDIRS) 245 | @echo 'HEADERS :' $(HEADERS) 246 | @echo 'SOURCES :' $(SOURCES) 247 | @echo 'SRC_CXX :' $(SRC_CXX) 248 | @echo 'OBJS :' $(OBJS) 249 | @echo 'DEPS :' $(DEPS) 250 | @echo 'DEPEND :' $(DEPEND) 251 | @echo 'COMPILE.c :' $(COMPILE.c) 252 | @echo 'COMPILE.cxx :' $(COMPILE.cxx) 253 | @echo 'link.c :' $(LINK.c) 254 | @echo 'link.cxx :' $(LINK.cxx) 255 | 256 | ## End of the Makefile ## Suggestions are welcome ## All rights reserved ## 257 | ############################################################## 258 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_client/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "test_util.h" 13 | #include "udt_client.h" 14 | 15 | std::vector recv_package_interval_; 16 | std::vector recv_package_interval10_; 17 | 18 | 19 | #define CLOCK_INTERVAL_STR "_" 20 | msg_ptr_t make_test_str(size_t test_str_size) 21 | { 22 | std::ostringstream ostr; 23 | ostr << iclock64(); 24 | std::string msg_str = ostr.str(); 25 | msg_str += test_str(CLOCK_INTERVAL_STR, test_str_size - msg_str.size()); 26 | return msg_ptr_t(new std::string(msg_str)); 27 | } 28 | 29 | uint64_t get_time_from_msg(const std::string& msg) 30 | { 31 | std::size_t pos = msg.find(CLOCK_INTERVAL_STR); 32 | if (pos == std::string::npos) 33 | { 34 | std::cout << "wrong msg: " << msg << std::endl; 35 | return 0; 36 | } 37 | const std::string& time_str = msg.substr(0, pos); 38 | return std::atoll(time_str.c_str()); 39 | } 40 | 41 | std::string get_cur_time_str() 42 | { 43 | time_t tmpcal_ptr = {0}; 44 | struct tm *tmp_ptr = NULL; 45 | tmpcal_ptr = time(NULL); 46 | tmp_ptr = localtime(&tmpcal_ptr); 47 | std::ostringstream osstrm; 48 | osstrm << tmp_ptr->tm_hour << ":" << tmp_ptr->tm_min << "." << tmp_ptr->tm_sec; 49 | return osstrm.str(); 50 | } 51 | 52 | void recv_func(const std::shared_ptr& str) 53 | { 54 | //std::cout << "recv: " << *str << std::endl; 55 | uint64_t send_time = get_time_from_msg(*str); 56 | uint64_t cur_time = iclock64(); 57 | 58 | static uint64_t static_last_refresh_time = 0; 59 | static size_t static_recved_bytes = 0; 60 | static_recved_bytes += str->size(); 61 | 62 | { 63 | static size_t static_good_recv_count = 0; 64 | 65 | static_good_recv_count++; 66 | 67 | uint64_t interval = cur_time - send_time; 68 | recv_package_interval_.push_back(interval); 69 | recv_package_interval10_.push_back(interval); 70 | std::cout << interval << "\t"; 71 | 72 | if (static_good_recv_count % 10 == 0) 73 | { 74 | int average10 = 0; 75 | for (int x : recv_package_interval10_) 76 | average10 += x; 77 | average10 = (average10 / 10); 78 | 79 | int average_total = 0; 80 | for (int x: recv_package_interval_) 81 | average_total += x; 82 | average_total = average_total / recv_package_interval_.size(); 83 | 84 | std::cout << "max: " << *std::max_element( recv_package_interval10_.begin(), recv_package_interval10_.end() ) << 85 | " average 10: " << average10 << 86 | " average total: " << average_total; 87 | if (cur_time - static_last_refresh_time > 10 * 1000) 88 | { 89 | std::cout << " " << static_cast(static_recved_bytes * 10 / (cur_time - static_last_refresh_time)) / 10 << "KB/s(in)"; 90 | static_last_refresh_time = cur_time; 91 | static_recved_bytes = 0; 92 | } 93 | std::cout << std::endl; 94 | std::cout << get_cur_time_str() << " "; 95 | recv_package_interval10_.clear(); 96 | } 97 | std::cout.flush(); 98 | } 99 | } 100 | 101 | int main(int argc, char* argv[]) 102 | { 103 | try 104 | { 105 | // Check command line arguments. 106 | if (argc != 4 && argc != 5) 107 | { 108 | std::cerr << "Usage: battle_client_udt \n"; 109 | std::cerr << " For IPv4, try:\n"; 110 | std::cerr << " client_udt 12345 120.123,2.123 80 1460\n"; 111 | return 1; 112 | } 113 | } 114 | catch (std::exception& e) 115 | { 116 | std::cerr << "exception: " << e.what() << "\n"; 117 | } 118 | 119 | //ignore SIGPIPE 120 | sigset_t ps; 121 | sigemptyset(&ps); 122 | sigaddset(&ps, SIGPIPE); 123 | pthread_sigmask(SIG_BLOCK, &ps, NULL); 124 | 125 | size_t test_str_size = 1460; 126 | if (argc == 5) 127 | test_str_size = std::atoi(argv[4]); 128 | 129 | auto client = std::make_shared(std::atoi(argv[1]), argv[2], std::atoi(argv[3]), recv_func); 130 | int start_ret = client->Start(); 131 | if (start_ret == 0) 132 | return 0; 133 | 134 | while (true) 135 | { 136 | msg_ptr_t msg = make_test_str(test_str_size); 137 | client->SendMsg(msg); 138 | 139 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 140 | size_t queue_size = client->SendMsgQueueSize(); 141 | while (queue_size > 2) 142 | { 143 | std::cerr << "B"; 144 | std::cerr.flush(); 145 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 146 | queue_size = client->SendMsgQueueSize(); 147 | } 148 | } 149 | 150 | return 1; 151 | } 152 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_client/test_util.cpp: -------------------------------------------------------------------------------- 1 | #include "test_util.h" 2 | #include 3 | 4 | std::string test_str(const std::string& str_prefix, const size_t str_len) 5 | { 6 | std::ostringstream ostr; 7 | ostr << str_prefix << ':'; 8 | std::string str = ostr.str(); 9 | 10 | // when len <= prefixLen 11 | // test_str(adfadf, 3) == adf 12 | if (str.size() >= str_len) 13 | { 14 | str.resize(str_len); 15 | return str; 16 | } 17 | 18 | // when len < 20 19 | // test_str(adf, 13) == adfa:67890123 20 | if (str_len < 20) 21 | { 22 | for (size_t i = str.size() + 1; i <= str_len; ++i) 23 | str.push_back(char(((i % 10) + 0x30))); 24 | return str; 25 | } 26 | 27 | // when len >= 20 28 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 29 | { 30 | // asdf:===== 31 | str.resize(10, '='); 32 | 33 | // (20_56789)(30_56789) 34 | while (str.size() + 10 <= str_len) 35 | { 36 | const size_t new_len = str.size() + 10; 37 | std::ostringstream tmp_ostrm; 38 | tmp_ostrm << str << "(" << new_len << '_'; 39 | str = tmp_ostrm.str(); 40 | for (size_t i = str.size() + 1; i < new_len; ++i) 41 | str.push_back(char(((i % 10) + 0x30))); 42 | str += ')'; 43 | } 44 | 45 | // 12345 46 | if (str.size() < str_len) 47 | { 48 | for (size_t i = str.size() + 1; i <= str_len; ++i) 49 | { 50 | char c = ((i % 10) + 0x30); 51 | str.push_back(c); 52 | } 53 | } 54 | return str; 55 | } 56 | 57 | return str; 58 | } 59 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_client/test_util.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DD_TEST_UTIL_H__ 3 | #define _DD_TEST_UTIL_H__ 4 | #include 5 | 6 | #include 7 | 8 | // when len <= prefixLen 9 | // test_str(adfadf, 3) == adf 10 | // when len < 20 11 | // test_str(adf, 13) == adfa:67890123 12 | // when len >= 20 13 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 14 | std::string test_str(const std::string& str_prefix, const size_t str_len); 15 | 16 | /* get system time */ 17 | static inline void itimeofday(long *sec, long *usec) 18 | { 19 | struct timeval time; 20 | gettimeofday(&time, NULL); 21 | if (sec) *sec = time.tv_sec; 22 | if (usec) *usec = time.tv_usec; 23 | } 24 | 25 | /* get clock in millisecond 64 */ 26 | static inline uint64_t iclock64(void) 27 | { 28 | long s, u; 29 | uint64_t value; 30 | itimeofday(&s, &u); 31 | value = ((uint64_t)s) * 1000 + (u / 1000); 32 | return value; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_client/threadsafe_queue.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | template 7 | class threadsafe_queue 8 | { 9 | private: 10 | mutable std::mutex mut; 11 | std::queue data_queue; 12 | std::condition_variable data_cond; 13 | public: 14 | threadsafe_queue(){} 15 | threadsafe_queue(threadsafe_queue const& other) 16 | { 17 | std::lock_guard lk(other.mut); 18 | data_queue=other.data_queue; 19 | } 20 | size_t size() 21 | { 22 | std::lock_guard lk(mut); 23 | return data_queue.size(); 24 | } 25 | void push(T new_value) 26 | { 27 | std::lock_guard lk(mut); 28 | data_queue.push(new_value); 29 | data_cond.notify_one(); 30 | } 31 | void wait_and_pop(T& value) 32 | { 33 | std::unique_lock lk(mut); 34 | data_cond.wait(lk,[this]{return !data_queue.empty();}); 35 | value=data_queue.front(); 36 | data_queue.pop(); 37 | } 38 | std::shared_ptr wait_and_pop() 39 | { 40 | std::unique_lock lk(mut); 41 | data_cond.wait(lk,[this]{return !data_queue.empty();}); 42 | std::shared_ptr res(std::make_shared(data_queue.front())); 43 | data_queue.pop(); 44 | return res; 45 | } 46 | bool try_pop(T& value) 47 | { 48 | std::lock_guard lk(mut); 49 | if(data_queue.empty()) 50 | return false; 51 | value=data_queue.front(); 52 | data_queue.pop(); 53 | return true; 54 | } 55 | std::shared_ptr try_pop() 56 | { 57 | std::lock_guard lk(mut); 58 | if(data_queue.empty()) 59 | return std::shared_ptr(); 60 | std::shared_ptr res(std::make_shared(data_queue.front())); 61 | data_queue.pop(); 62 | return res; 63 | } 64 | std::queue&& grab_all2(void) 65 | { 66 | std::queue ret; 67 | 68 | { 69 | std::lock_guard lk(mut); 70 | std::swap(ret, data_queue); 71 | } 72 | 73 | return std::move(ret); 74 | } 75 | std::queue grab_all(void) 76 | { 77 | std::queue ret; 78 | 79 | { 80 | std::lock_guard lk(mut); 81 | std::swap(ret, data_queue); 82 | } 83 | 84 | return ret; 85 | } 86 | bool empty() const 87 | { 88 | std::lock_guard lk(mut); 89 | return data_queue.empty(); 90 | } 91 | }; 92 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_client/udt_client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "udt_client.h" 10 | #include "test_util.h" 11 | 12 | 13 | const int g_IP_Version = AF_INET; 14 | //const int g_Socket_Type = SOCK_STREAM; 15 | const int g_Socket_Type = SOCK_DGRAM; 16 | 17 | 18 | 19 | UDTClient::UDTClient(int local_port, const std::string& ip_connect_to, int port_connect_to, recv_callback_func_t recv_func) : 20 | recv_callback_func_(recv_func), 21 | local_port_(local_port), 22 | ip_connect_to_(ip_connect_to), 23 | port_connect_to_(port_connect_to), 24 | sock_(UDT::INVALID_SOCK), 25 | udtbuf_recved_len_(0), 26 | udt_running_(0), 27 | udt_eid_(-1) 28 | { 29 | } 30 | 31 | int UDTClient::Start(void) 32 | { 33 | udt_running_ = 0; 34 | 35 | // create, bind 36 | // 37 | CreateSocket(); 38 | 39 | // connect to the server, implict bind 40 | if (0 == Connect()) 41 | { 42 | return 0; 43 | } 44 | 45 | // sleep 5 sencods for connect success. 46 | std::this_thread::sleep_for(std::chrono::seconds(5)); 47 | 48 | udt_thread_ = std::thread(std::bind(&UDTClient::Run, shared_from_this())); 49 | return 1; 50 | } 51 | 52 | void UDTClient::SendMsg(msg_ptr_t msg) 53 | { 54 | send_msg_queue_.push(msg); 55 | } 56 | 57 | size_t UDTClient::SendMsgQueueSize(void) 58 | { 59 | return send_msg_queue_.size(); 60 | } 61 | 62 | std::deque UDTClient::RecvMsg(void) // todo: using move symatic 63 | { 64 | return std::deque(); 65 | } 66 | 67 | // return -1 means error. otherwise return 0 68 | int UDTClient::CreateSocket(void) 69 | { 70 | //sock_ = UDT::socket(AF_INET, SOCK_STREAM, 0); 71 | sock_ = UDT::socket(AF_INET, SOCK_DGRAM, 0); 72 | if (UDT::INVALID_SOCK == sock_) 73 | { 74 | std::cout << "UDT socket: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage(); 75 | return -1; 76 | } 77 | 78 | // setopt 79 | { 80 | bool block = false; 81 | UDT::setsockopt(sock_, 0, UDT_SNDSYN, &block, sizeof(bool)); 82 | UDT::setsockopt(sock_, 0, UDT_RCVSYN, &block, sizeof(bool)); 83 | 84 | //UDT::setsockopt(sock_, 0, UDT_MSS, new int(1500), sizeof(int)); 85 | 86 | //int snd_buf = 16000;// 8192; 87 | //int rcv_buf = 16000;//8192; 88 | //int snd_buf = 7300;// 1460 * 5 89 | int snd_buf = 93440;// 1460 * 5 90 | int rcv_buf = 93440; 91 | UDT::setsockopt(sock_, 0, UDT_SNDBUF, &snd_buf, sizeof(int)); 92 | UDT::setsockopt(sock_, 0, UDT_RCVBUF, &rcv_buf, sizeof(int)); 93 | 94 | 95 | //int fc = 4096; 96 | //UDT::setsockopt(sock_, 0, UDT_FC, &fc, sizeof(int)); 97 | 98 | bool reuse = true; 99 | UDT::setsockopt(sock_, 0, UDT_REUSEADDR, &reuse, sizeof(bool)); 100 | 101 | bool rendezvous = false; 102 | UDT::setsockopt(sock_, 0, UDT_RENDEZVOUS, &rendezvous, sizeof(bool)); 103 | } 104 | 105 | // bind 106 | sockaddr_in my_addr; 107 | my_addr.sin_family = AF_INET; 108 | my_addr.sin_port = htons(local_port_); 109 | my_addr.sin_addr.s_addr = INADDR_ANY; 110 | std::memset(&(my_addr.sin_zero), '\0', 8); 111 | if (UDT::ERROR == UDT::bind(sock_, (sockaddr*)&my_addr, sizeof(my_addr))) 112 | { 113 | std::cout << "UDT bind: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 114 | return -1; 115 | } 116 | 117 | // success 118 | return 0; 119 | } 120 | 121 | void UDTClient::TryGrabMsg(void) 122 | { 123 | send_msg_buff_ = send_msg_queue_.grab_all(); 124 | } 125 | 126 | void UDTClient::TrySendMsg(void) 127 | { 128 | while (!send_msg_buff_.empty()) 129 | { 130 | msg_ptr_t msg = send_msg_buff_.front(); 131 | 132 | const int send_ret = DoSendOneMsg(*msg); 133 | switch (send_ret) 134 | { 135 | case 0: 136 | return; // try send_at_next_loop 137 | case -1: 138 | return; // udt_running_ = 0; 139 | case 1: 140 | send_msg_buff_.pop(); 141 | continue; 142 | default: 143 | udt_running_ = 0; 144 | return; 145 | } 146 | } 147 | } 148 | 149 | // return 0 means send buf full. Need send at next loop. 150 | // return 1 means send ok. Can send other package. 151 | // return -1 means badly error. Need stop. 152 | int UDTClient::DoSendOneMsg(const std::string& msg) 153 | { 154 | //std::cout << "UDT client DoSendMsg: " << msg << std::endl; 155 | 156 | int send_ret = UDT::sendmsg(sock_, msg.c_str(), msg.size(), -1, true); 157 | if (UDT::ERROR == send_ret) 158 | { 159 | CUDTException& lasterror = UDT::getlasterror(); 160 | const int error_code = lasterror.getErrorCode(); 161 | if (error_code == CUDTException::EASYNCSND) 162 | { 163 | std::cerr << "N"; std::cerr.flush(); 164 | return 0; 165 | } 166 | 167 | std::cout << "UDT sendmsg: " << error_code << ' ' << lasterror.getErrorMessage() << std::endl; 168 | udt_running_ = 0; 169 | return -1; 170 | } 171 | if (static_cast(send_ret) != msg.size()) 172 | { 173 | std::cout << "UDT sendmsg: not all msg send!" << std::endl; 174 | udt_running_ = 0; 175 | return -1; 176 | } 177 | return 1; 178 | } 179 | 180 | void UDTClient::DoRecvMsg(bool& bHaveMsgStill) 181 | { 182 | udtbuf_recved_len_ = 0; 183 | bHaveMsgStill = true; 184 | 185 | int recv_ret = 0; 186 | if (UDT::ERROR == (recv_ret = UDT::recvmsg(sock_, udtbuf_, sizeof(udtbuf_)))) { 187 | CUDTException& lasterror = UDT::getlasterror(); 188 | const int error_code = lasterror.getErrorCode(); 189 | 190 | if (error_code == CUDTException::EASYNCRCV) // no data available for read. 191 | { 192 | bHaveMsgStill = false; 193 | return; 194 | } 195 | 196 | std::cout << "UDT recv: " << error_code << " " << lasterror.getErrorMessage() << std::endl; 197 | if (CUDTException::EINVPARAM == error_code || CUDTException::ECONNLOST == error_code || CUDTException::EINVSOCK == error_code) { 198 | udt_running_ = 0; 199 | } 200 | bHaveMsgStill = false; 201 | return; 202 | } 203 | 204 | if (recv_ret > 0) 205 | { 206 | //DEBUG_MSG("UDT Thread Enter.\n"); 207 | udtbuf_recved_len_ = recv_ret; 208 | if (recv_callback_func_) 209 | { 210 | std::shared_ptr recved_str(new std::string(udtbuf_, udtbuf_recved_len_)); 211 | recv_callback_func_(recved_str); 212 | } 213 | //DEBUG_MSG(" - UDT Thread Exit.\n"); 214 | bHaveMsgStill = true; 215 | return; 216 | } 217 | 218 | std::cout << "UDT recv msg with zero len" << std::endl; 219 | return; 220 | } 221 | 222 | int UDTClient::Connect(void) 223 | { 224 | sockaddr_in serv_addr; 225 | serv_addr.sin_family = AF_INET; 226 | serv_addr.sin_port = htons(port_connect_to_); 227 | inet_pton(AF_INET, ip_connect_to_.c_str(), &serv_addr.sin_addr); 228 | std::memset(&(serv_addr.sin_zero), '\0', 8); 229 | std::cout << "connect to: " << ip_connect_to_ << " " << port_connect_to_ << std::endl; 230 | if (UDT::ERROR == UDT::connect(sock_, (sockaddr*)&serv_addr, sizeof(serv_addr))) 231 | { 232 | std::cout << "UDT connect: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 233 | return 0; 234 | } 235 | 236 | return 1; 237 | } 238 | 239 | void UDTClient::TryRecvMsg(void) 240 | { 241 | bool bHaveMsgStill = false; 242 | do 243 | { 244 | bHaveMsgStill = false; 245 | DoRecvMsg(bHaveMsgStill); 246 | } while (bHaveMsgStill); 247 | } 248 | 249 | int UDTClient::Run(void) 250 | { 251 | udt_running_ = 1; 252 | 253 | std::cout << "Run UDT client loop ...\n"; 254 | udt_running_ = 1; 255 | 256 | while (udt_running_) { 257 | if (send_msg_buff_.empty()) 258 | TryGrabMsg(); 259 | 260 | // send msg first. 261 | TrySendMsg(); 262 | 263 | // recv msg 264 | TryRecvMsg(); 265 | 266 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 267 | } 268 | 269 | 270 | std::cout << "Close client ..."; 271 | int close_state = UDT::close(sock_); 272 | if (close_state != 0) 273 | std::cout << "UDT close: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 274 | 275 | std::cout << "ok\n"; 276 | 277 | pthread_detach(pthread_self()); 278 | 279 | return 1; 280 | } 281 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_client/udt_client.h: -------------------------------------------------------------------------------- 1 | #ifndef __UDT_CLIENT_H_ 2 | #define __UDT_CLIENT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "threadsafe_queue.hpp" 12 | 13 | 14 | typedef int UDTSOCKET; 15 | typedef std::function&)> recv_callback_func_t; 16 | typedef std::shared_ptr msg_ptr_t; 17 | 18 | // the UDTClient will create another thread for UDT sending and recving. 19 | class UDTClient : public std::enable_shared_from_this 20 | { 21 | public: 22 | // when recv_func valid, 23 | // recv_callback_func will be called by another thread when a package recved. recv_callback_func should be thread safe. 24 | // when recv_func invalid, 25 | // packages recved will stored in queue. You should call TryRecvMsg frequently (10 milliseconds for example) to get the recved msg. 26 | UDTClient(int local_port, const std::string& ip_connect_to, int port_connect_to, recv_callback_func_t recv_func = nullptr); 27 | int Start(void); 28 | 29 | void SendMsg(msg_ptr_t msg); 30 | size_t SendMsgQueueSize(void); 31 | std::deque RecvMsg(void); // todo: using move symatic 32 | 33 | private: 34 | void TryGrabMsg(void); 35 | 36 | void TrySendMsg(void); 37 | 38 | // return 0 means send buf full. Need send at next loop. 39 | // return 1 means send ok. Can send other package. 40 | // return -1 means badly error. Need stop. 41 | int DoSendOneMsg(const std::string& msg); 42 | 43 | void TryRecvMsg(void); 44 | void DoRecvMsg(bool& bHaveMsgStill); 45 | int Run(void); 46 | int CreateSocket(void); 47 | int Connect(void); 48 | 49 | private: 50 | recv_callback_func_t recv_callback_func_; 51 | threadsafe_queue< msg_ptr_t > send_msg_queue_; 52 | std::queue send_msg_buff_; 53 | 54 | int local_port_; 55 | std::string ip_connect_to_; 56 | int port_connect_to_; 57 | 58 | std::thread udt_thread_; 59 | UDTSOCKET sock_; 60 | char udtbuf_[1024 * 100]; 61 | size_t udtbuf_recved_len_; 62 | int udt_running_; 63 | int udt_eid_; 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_server/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Generic Makefile for C/C++ Program 3 | # 4 | # License: GPL (General Public License) 5 | # Author: whyglinux 6 | # Date: 2006/03/04 (version 0.1) 7 | # 2007/03/24 (version 0.2) 8 | # 2007/04/09 (version 0.3) 9 | # 2007/06/26 (version 0.4) 10 | # 2008/04/05 (version 0.5) 11 | # 12 | # Description: 13 | # ------------ 14 | # This is an easily customizable makefile template. The purpose is to 15 | # provide an instant building environment for C/C++ programs. 16 | # 17 | # It searches all the C/C++ source files in the specified directories, 18 | # makes dependencies, compiles and links to form an executable. 19 | # 20 | # Besides its default ability to build C/C++ programs which use only 21 | # standard C/C++ libraries, you can customize the Makefile to build 22 | # those using other libraries. Once done, without any changes you can 23 | # then build programs using the same or less libraries, even if source 24 | # files are renamed, added or removed. Therefore, it is particularly 25 | # convenient to use it to build codes for experimental or study use. 26 | # 27 | # GNU make is expected to use the Makefile. Other versions of makes 28 | # may or may not work. 29 | # 30 | # Usage: 31 | # ------ 32 | # 1. Copy the Makefile to your program directory. 33 | # 2. Customize in the "Customizable Section" only if necessary: 34 | # * to use non-standard C/C++ libraries, set pre-processor or compiler 35 | # options to and linker ones to 36 | # (See Makefile.gtk+-2.0 for an example) 37 | # * to search sources in more directories, set to 38 | # * to specify your favorite program name, set to 39 | # 3. Type make to start building your program. 40 | # 41 | # Make Target: 42 | # ------------ 43 | # The Makefile provides the following targets to make: 44 | # $ make compile and link 45 | # $ make NODEP=yes compile and link without generating dependencies 46 | # $ make objs compile only (no linking) 47 | # $ make tags create tags for Emacs editor 48 | # $ make ctags create ctags for VI editor 49 | # $ make clean clean objects and the executable file 50 | # $ make distclean clean objects, the executable and dependencies 51 | # $ make help get the usage of the makefile 52 | # 53 | #=========================================================================== 54 | 55 | ## Customizable Section: adapt those variables to suit your program. 56 | ##========================================================================== 57 | 58 | OS_NAME="`uname -s`" 59 | LC_OS_NAME = $(shell echo $(OS_NAME) | tr '[A-Z]' '[a-z]') 60 | # MAC=darwin 61 | # CENTOS=linux 62 | 63 | # The pre-processor and compiler options. 64 | MY_CFLAGS = 65 | 66 | # The linker options. 67 | #MY_LIBS = $(BOOST_LIB_PATH)/libboost_system-mt.a $(BOOST_LIB_PATH)/libboost_filesystem-mt.a $(BOOST_LIB_PATH)/libboost_thread-mt.a $(PB_LIB_PATH)/libprotobuf.a ../essential/essential.a ../udt4/src/libudt.a 68 | MY_LIBS = ../udt4/src/libudt.a 69 | 70 | 71 | # The pre-processor options used by the cpp (man cpp for more). 72 | CPPFLAGS = -Wall -I ../udt4/src -g3 73 | 74 | # The options used in linking as well as in any direct use of ld. 75 | ifeq ($(LC_OS_NAME), darwin) 76 | LDFLAGS = -L/opt/local/lib -pthread 77 | else 78 | LDFLAGS = -L/opt/local/lib -pthread -lrt 79 | endif 80 | 81 | 82 | # The directories in which source files reside. 83 | # If not specified, only the current directory will be serached. 84 | SRCDIRS = ./ 85 | 86 | # The executable file name. 87 | # If not specified, current directory name or `a.out' will be used. 88 | PROGRAM = udt_dgram_server 89 | 90 | ## Implicit Section: change the following only when necessary. 91 | ##========================================================================== 92 | 93 | # The source file types (headers excluded). 94 | # .c indicates C source files, and others C++ ones. 95 | SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp 96 | 97 | # The header file types. 98 | HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp 99 | 100 | # The pre-processor and compiler options. 101 | # Users can override those variables from the command line. 102 | CFLAGS = 103 | CXXFLAGS= -std=c++11 104 | 105 | # The C program compiler. 106 | CC = gcc 107 | 108 | # The C++ program compiler. 109 | CXX = g++ 110 | 111 | # Un-comment the following line to compile C programs as C++ ones. 112 | #CC = $(CXX) 113 | 114 | # The command used to delete file. 115 | #RM = rm -f 116 | 117 | ETAGS = etags 118 | ETAGSFLAGS = 119 | 120 | CTAGS = ctags 121 | CTAGSFLAGS = 122 | 123 | ## Stable Section: usually no need to be changed. But you can add more. 124 | ##========================================================================== 125 | SHELL = /bin/sh 126 | EMPTY = 127 | SPACE = $(EMPTY) $(EMPTY) 128 | ifeq ($(PROGRAM),) 129 | q 130 | q 131 | q 132 | CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR))) 133 | PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES)) 134 | ifeq ($(PROGRAM),) 135 | PROGRAM = a.out 136 | endif 137 | endif 138 | ifeq ($(SRCDIRS),) 139 | SRCDIRS = . 140 | endif 141 | SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS)))) 142 | HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS)))) 143 | SRC_CXX = $(filter-out %.c,$(SOURCES)) 144 | OBJS = $(addsuffix .o, $(basename $(SOURCES))) 145 | 146 | ## Define some useful variables. 147 | DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \ 148 | echo "-MM -MP"; else echo "-M"; fi ) 149 | DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) 150 | COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c 151 | COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c 152 | LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) 153 | LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) 154 | 155 | .PHONY: all objs tags ctags clean distclean help show 156 | 157 | # Delete the default suffixes 158 | .SUFFIXES: 159 | 160 | all: $(PROGRAM) 161 | 162 | 163 | # Rules for generating object files (.o). 164 | #---------------------------------------- 165 | objs:$(OBJS) 166 | 167 | %.o:%.c 168 | $(COMPILE.c) $< -o $@ 169 | 170 | %.o:%.C 171 | $(COMPILE.cxx) $< -o $@ 172 | 173 | %.o:%.cc 174 | $(COMPILE.cxx) $< -o $@ 175 | 176 | %.o:%.cpp 177 | $(COMPILE.cxx) $< -o $@ 178 | 179 | %.o:%.CPP 180 | $(COMPILE.cxx) $< -o $@ 181 | 182 | %.o:%.c++ 183 | $(COMPILE.cxx) $< -o $@ 184 | 185 | %.o:%.cp 186 | $(COMPILE.cxx) $< -o $@ 187 | 188 | %.o:%.cxx 189 | $(COMPILE.cxx) $< -o $@ 190 | 191 | # Rules for generating the tags. 192 | #------------------------------------- 193 | tags: $(HEADERS) $(SOURCES) 194 | $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES) 195 | 196 | ctags: $(HEADERS) $(SOURCES) 197 | $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES) 198 | 199 | # Rules for generating the executable. 200 | #------------------------------------- 201 | $(PROGRAM):$(OBJS) 202 | ifeq ($(SRC_CXX),) # C program 203 | $(LINK.c) $(OBJS) $(MY_LIBS) -o $@ 204 | @echo Type ./$@ to execute the program. 205 | else # C++ program 206 | $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@ 207 | @echo Type ./$@ to execute the program. 208 | endif 209 | 210 | ifndef NODEP 211 | ifneq ($(DEPS),) 212 | sinclude $(DEPS) 213 | endif 214 | endif 215 | 216 | clean: 217 | $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe 218 | 219 | distclean: clean 220 | $(RM) $(DEPS) TAGS 221 | 222 | # Show help. 223 | help: 224 | @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5' 225 | @echo 'Copyright (C) 2007, 2008 whyglinux ' 226 | @echo 227 | @echo 'Usage: make [TARGET]' 228 | @echo 'TARGETS:' 229 | @echo ' all (=make) compile and link.' 230 | @echo ' NODEP=yes make without generating dependencies.' 231 | @echo ' objs compile only (no linking).' 232 | @echo ' tags create tags for Emacs editor.' 233 | @echo ' ctags create ctags for VI editor.' 234 | @echo ' clean clean objects and the executable file.' 235 | @echo ' distclean clean objects, the executable and dependencies.' 236 | @echo ' show show variables (for debug use only).' 237 | @echo ' help print this message.' 238 | @echo 239 | @echo 'Report bugs to .' 240 | 241 | # Show variables (for debug use only.) 242 | show: 243 | @echo 'PROGRAM :' $(PROGRAM) 244 | @echo 'SRCDIRS :' $(SRCDIRS) 245 | @echo 'HEADERS :' $(HEADERS) 246 | @echo 'SOURCES :' $(SOURCES) 247 | @echo 'SRC_CXX :' $(SRC_CXX) 248 | @echo 'OBJS :' $(OBJS) 249 | @echo 'DEPS :' $(DEPS) 250 | @echo 'DEPEND :' $(DEPEND) 251 | @echo 'COMPILE.c :' $(COMPILE.c) 252 | @echo 'COMPILE.cxx :' $(COMPILE.cxx) 253 | @echo 'link.c :' $(LINK.c) 254 | @echo 'link.cxx :' $(LINK.cxx) 255 | 256 | ## End of the Makefile ## Suggestions are welcome ## All rights reserved ## 257 | ############################################################## 258 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_server/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "udt_server.h" 10 | 11 | int main(int argc, char* argv[]) 12 | { 13 | try 14 | { 15 | // Check command line arguments. 16 | if (argc != 3) 17 | { 18 | std::cerr << "Usage: server_udt
\n"; 19 | std::cerr << " For IPv4, try:\n"; 20 | std::cerr << " battle_server 0.0.0.0 80\n"; 21 | std::cerr << " For IPv6, try:\n"; 22 | std::cerr << " battle_server 0::0 80\n"; 23 | return 1; 24 | } 25 | } 26 | catch (std::exception& e) 27 | { 28 | std::cerr << "exception: " << e.what() << "\n"; 29 | } 30 | 31 | std::cout << "run battle_server_udt on " << argv[1] << ':' << argv[2] << std::endl; 32 | 33 | //ignore SIGPIPE 34 | sigset_t ps; 35 | sigemptyset(&ps); 36 | sigaddset(&ps, SIGPIPE); 37 | pthread_sigmask(SIG_BLOCK, &ps, NULL); 38 | 39 | auto server = std::make_shared(); 40 | server->Run(std::atoi(argv[2])); 41 | return 1; 42 | } 43 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_server/test_util.cpp: -------------------------------------------------------------------------------- 1 | #include "test_util.h" 2 | #include 3 | 4 | std::string test_str(const std::string& str_prefix, const size_t str_len) 5 | { 6 | std::ostringstream ostr; 7 | ostr << str_prefix << ':'; 8 | std::string str = ostr.str(); 9 | 10 | // when len <= prefixLen 11 | // test_str(adfadf, 3) == adf 12 | if (str.size() >= str_len) 13 | { 14 | str.resize(str_len); 15 | return str; 16 | } 17 | 18 | // when len < 20 19 | // test_str(adf, 13) == adfa:67890123 20 | if (str_len < 20) 21 | { 22 | for (size_t i = str.size() + 1; i <= str_len; ++i) 23 | str.push_back(char(((i % 10) + 0x30))); 24 | return str; 25 | } 26 | 27 | // when len >= 20 28 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 29 | { 30 | // asdf:===== 31 | str.resize(10, '='); 32 | 33 | // (20_56789)(30_56789) 34 | while (str.size() + 10 <= str_len) 35 | { 36 | const size_t new_len = str.size() + 10; 37 | std::ostringstream tmp_ostrm; 38 | tmp_ostrm << str << "(" << new_len << '_'; 39 | str = tmp_ostrm.str(); 40 | for (size_t i = str.size() + 1; i < new_len; ++i) 41 | str.push_back(char(((i % 10) + 0x30))); 42 | str += ')'; 43 | } 44 | 45 | // 12345 46 | if (str.size() < str_len) 47 | { 48 | for (size_t i = str.size() + 1; i <= str_len; ++i) 49 | { 50 | char c = ((i % 10) + 0x30); 51 | str.push_back(c); 52 | } 53 | } 54 | return str; 55 | } 56 | 57 | return str; 58 | } 59 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_server/test_util.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DD_TEST_UTIL_H__ 3 | #define _DD_TEST_UTIL_H__ 4 | #include 5 | 6 | // when len <= prefixLen 7 | // test_str(adfadf, 3) == adf 8 | // when len < 20 9 | // test_str(adf, 13) == adfa:67890123 10 | // when len >= 20 11 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 12 | std::string test_str(const std::string& str_prefix, const size_t str_len); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_server/udt_server.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "test_util.h" 12 | #include "udt_server.h" 13 | 14 | const int g_IP_Version = AF_INET; 15 | //const int g_Socket_Type = SOCK_STREAM; 16 | const int g_Socket_Type = SOCK_DGRAM; 17 | 18 | /* get system time */ 19 | static inline void itimeofday(long *sec, long *usec) 20 | { 21 | struct timeval time; 22 | gettimeofday(&time, NULL); 23 | if (sec) *sec = time.tv_sec; 24 | if (usec) *usec = time.tv_usec; 25 | } 26 | 27 | /* get clock in millisecond 64 */ 28 | static inline uint64_t iclock64(void) 29 | { 30 | long s, u; 31 | uint64_t value; 32 | itimeofday(&s, &u); 33 | value = ((uint64_t)s) * 1000 + (u / 1000); 34 | return value; 35 | } 36 | 37 | 38 | std::string get_cur_time_str() 39 | { 40 | time_t tmpcal_ptr = {0}; 41 | struct tm *tmp_ptr = NULL; 42 | tmpcal_ptr = time(NULL); 43 | tmp_ptr = localtime(&tmpcal_ptr); 44 | std::ostringstream osstrm; 45 | osstrm << tmp_ptr->tm_hour << ":" << tmp_ptr->tm_min << "." << tmp_ptr->tm_sec; 46 | return osstrm.str(); 47 | } 48 | 49 | 50 | 51 | UDTServer::UDTServer(void) : 52 | listen_sock_(UDT::INVALID_SOCK), 53 | udt_running_(0) 54 | { 55 | } 56 | 57 | // return -1 means error. otherwise return 0 58 | int UDTServer::CreateListenSocket(int listen_port) 59 | { 60 | //listen_sock_ = UDT::socket(AF_INET, SOCK_STREAM, 0); 61 | listen_sock_ = UDT::socket(AF_INET, SOCK_DGRAM, 0); 62 | if (UDT::INVALID_SOCK == listen_sock_) 63 | { 64 | std::cout << "UDT socket: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage(); 65 | return -1; 66 | } 67 | 68 | // setopt 69 | { 70 | bool block = false; 71 | UDT::setsockopt(listen_sock_, 0, UDT_SNDSYN, &block, sizeof(bool)); 72 | UDT::setsockopt(listen_sock_, 0, UDT_RCVSYN, &block, sizeof(bool)); 73 | 74 | //UDT::setsockopt(listen_sock_, 0, UDT_MSS, new int(1500), sizeof(int)); // default is 1500 75 | 76 | int snd_buf = 93440;// 1460 * 64 = 93440 77 | int rcv_buf = 93440; 78 | UDT::setsockopt(listen_sock_, 0, UDT_SNDBUF, &snd_buf, sizeof(int)); // default is 10MB 79 | UDT::setsockopt(listen_sock_, 0, UDT_RCVBUF, &rcv_buf, sizeof(int)); // default is 10MB 80 | 81 | 82 | //int fc = 4096; 83 | //UDT::setsockopt(listen_sock_, 0, UDT_FC, &fc, sizeof(int)); 84 | 85 | bool reuse = true; 86 | UDT::setsockopt(listen_sock_, 0, UDT_REUSEADDR, &reuse, sizeof(bool)); 87 | 88 | bool rendezvous = false; 89 | UDT::setsockopt(listen_sock_, 0, UDT_RENDEZVOUS, &rendezvous, sizeof(bool)); 90 | } 91 | 92 | // bind 93 | sockaddr_in my_addr; 94 | my_addr.sin_family = AF_INET; 95 | my_addr.sin_port = htons(listen_port); 96 | my_addr.sin_addr.s_addr = INADDR_ANY; 97 | std::memset(&(my_addr.sin_zero), '\0', 8); 98 | if (UDT::ERROR == UDT::bind(listen_sock_, (sockaddr*)&my_addr, sizeof(my_addr))) 99 | { 100 | std::cout << "UDT bind: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 101 | return -1; 102 | } 103 | 104 | // listen 105 | // 106 | if (UDT::ERROR == UDT::listen(listen_sock_, 20)) 107 | { 108 | std::cout << "UDT listen: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 109 | return -1; 110 | } 111 | 112 | // success 113 | return 0; 114 | } 115 | 116 | void UDTServer::Run(int listen_port) 117 | { 118 | udt_running_ = 0; 119 | 120 | // create, bind and listen 121 | // 122 | CreateListenSocket(listen_port); 123 | 124 | udt_running_ = 1; 125 | 126 | while (udt_running_) 127 | { 128 | struct sockaddr addr; 129 | int addrlen = sizeof(sockaddr); 130 | 131 | const UDTSOCKET accept_ret = UDT::accept(listen_sock_, &addr, &addrlen); 132 | if (accept_ret == UDT::INVALID_SOCK) 133 | { 134 | CUDTException& lasterror = UDT::getlasterror(); 135 | const int error_code = lasterror.getErrorCode(); 136 | 137 | if (error_code == CUDTException::EASYNCRCV) 138 | { 139 | { 140 | std::cout << "."; 141 | static time_t static_last_time = 0; 142 | const time_t cur_time = std::time(NULL); 143 | if (cur_time != static_last_time) 144 | { 145 | static_last_time = cur_time; 146 | std::cout << std::endl << get_cur_time_str() << " "; 147 | } 148 | std::cout.flush(); 149 | } 150 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 151 | continue; 152 | } 153 | 154 | std::cout << "UDT accept: " << error_code << " " << lasterror.getErrorMessage() << std::endl; 155 | udt_running_ = 0; 156 | break; 157 | } 158 | 159 | { 160 | const UDTSOCKET new_sock = accept_ret; 161 | std::thread connection_thread(std::bind(&UDTServer::WorkThread, shared_from_this(), new_sock)); 162 | connection_thread.detach(); 163 | } 164 | } 165 | 166 | 167 | 168 | 169 | std::cout << "Close server ..."; 170 | int close_state = UDT::close(listen_sock_); 171 | if (close_state != 0) 172 | std::cout << "UDT close:" << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 173 | 174 | std::cout << "ok\n"; 175 | } 176 | 177 | void UDTServer::WorkThread(const UDTSOCKET& sock) 178 | { 179 | std::queue msg_queue_need_send; 180 | while (true) 181 | { 182 | // recv msg 183 | TryRecvMsg(sock, msg_queue_need_send); 184 | 185 | // send msg. 186 | if (msg_queue_need_send.size() > 0) 187 | TrySendMsg(sock, msg_queue_need_send); 188 | 189 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 190 | } 191 | 192 | 193 | } 194 | 195 | void UDTServer::TryRecvMsg(const UDTSOCKET& sock, std::queue& msg_queue_need_send) 196 | { 197 | bool bHaveMsgStill = false; 198 | do 199 | { 200 | bHaveMsgStill = false; 201 | const std::string recved_msg = DoRecvMsg(sock, bHaveMsgStill); 202 | if (recved_msg.size() > 0) 203 | msg_queue_need_send.push(recved_msg); 204 | } while (bHaveMsgStill); 205 | } 206 | 207 | void UDTServer::TrySendMsg(const UDTSOCKET& sock, std::queue& msg_queue_need_send) 208 | { 209 | while (!msg_queue_need_send.empty()) 210 | { 211 | std::string msg = msg_queue_need_send.front(); 212 | 213 | const int send_ret = DoSendOneMsg(sock, msg); 214 | switch (send_ret) 215 | { 216 | case 0: 217 | return; // try send_at_next_loop 218 | case -1: 219 | return; // udt_running_ = 0; 220 | case 1: 221 | msg_queue_need_send.pop(); 222 | continue; 223 | default: 224 | udt_running_ = 0; 225 | return; 226 | } 227 | } 228 | } 229 | 230 | // return 0 means send buf full. Need send at next loop. 231 | // return 1 means send ok. Can send other package. 232 | // return -1 means badly error. Need stop. 233 | int UDTServer::DoSendOneMsg(const UDTSOCKET& sock, const std::string& msg) 234 | { 235 | //std::cout << "UDT client DoSendMsg: " << msg << std::endl; 236 | 237 | int send_ret = UDT::sendmsg(sock, msg.c_str(), msg.size(), -1, true); 238 | if (UDT::ERROR == send_ret) 239 | { 240 | CUDTException& lasterror = UDT::getlasterror(); 241 | const int error_code = lasterror.getErrorCode(); 242 | if (error_code == CUDTException::EASYNCSND) 243 | { 244 | std::cerr << "N"; std::cerr.flush(); 245 | return 0; 246 | } 247 | 248 | std::cout << "UDT sendmsg: " << error_code << ' ' << lasterror.getErrorMessage() << std::endl; 249 | udt_running_ = 0; 250 | return -1; 251 | } 252 | if (static_cast(send_ret) != msg.size()) 253 | { 254 | std::cout << "UDT sendmsg: not all msg send!" << std::endl; 255 | udt_running_ = 0; 256 | return -1; 257 | } 258 | return 1; 259 | } 260 | 261 | std::string UDTServer::DoRecvMsg(const UDTSOCKET& sock, bool& bHaveMsgStill) 262 | { 263 | bHaveMsgStill = true; 264 | 265 | int recv_ret = 0; 266 | char recv_buf[1024 * 100]; 267 | 268 | if (UDT::ERROR == (recv_ret = UDT::recvmsg(sock, recv_buf, sizeof(recv_buf)))) { 269 | CUDTException& lasterror = UDT::getlasterror(); 270 | const int error_code = lasterror.getErrorCode(); 271 | 272 | if (error_code == CUDTException::EASYNCRCV) // no data available for read. 273 | { 274 | bHaveMsgStill = false; 275 | return ""; 276 | } 277 | 278 | std::cout << "UDT recv: " << error_code << " " << lasterror.getErrorMessage() << std::endl; 279 | if (CUDTException::EINVPARAM == error_code || CUDTException::ECONNLOST == error_code || CUDTException::EINVSOCK == error_code) { 280 | bHaveMsgStill = false; 281 | } 282 | return ""; 283 | } 284 | 285 | if (recv_ret > 0) 286 | { 287 | std::string recved_str(recv_buf, recv_ret); 288 | bHaveMsgStill = true; 289 | return recved_str; 290 | } 291 | 292 | std::cout << "UDT recv msg with zero len" << std::endl; 293 | bHaveMsgStill = false; 294 | return ""; 295 | } 296 | 297 | 298 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_dgram_server/udt_server.h: -------------------------------------------------------------------------------- 1 | #ifndef __UDT_SERVER_H_ 2 | #define __UDT_SERVER_H_ 3 | 4 | #include 5 | #include 6 | 7 | typedef int UDTSOCKET; 8 | 9 | class UDTServer : public std::enable_shared_from_this 10 | { 11 | public: 12 | UDTServer(void); 13 | void Run(int listen_port); 14 | 15 | private: 16 | int CreateListenSocket(int port); 17 | void WorkThread(const UDTSOCKET& sock); 18 | 19 | void TryRecvMsg(const UDTSOCKET& sock, std::queue& msg_queue_need_send); 20 | void TrySendMsg(const UDTSOCKET& sock, std::queue& msg_queue_need_send); 21 | std::string DoRecvMsg(const UDTSOCKET& sock, bool& bHaveMsgStill); 22 | int DoSendOneMsg(const UDTSOCKET& sock, const std::string& msg); 23 | 24 | private: 25 | UDTSOCKET listen_sock_; 26 | int udt_running_; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_readme.md: -------------------------------------------------------------------------------- 1 | ### UDT - UDP-based Data Transfer Protocol 2 | [official webside](https://sourceforge.net/projects/udt/) 3 | 4 | 5 | #### Building udt_bench_mark: 6 | * making gcc version >= 4.8 7 | * download UDT 4.11 from [udt on sourceforge](http://nchc.dl.sourceforge.net/project/udt/udt/4.11/udt.sdk.4.11.tar.gz) 8 | - or just use the pack in install_pack folder. 9 | * unpack udt.sdk.4.11.tar.gz and copy udt4 folder into udt_bench_mark. 10 | * modify the OS and ARCH in allmake.sh. 11 | * $ . allmake.sh 12 | 13 | #### project introduce 14 | * udt_dgram_server - a server using unblock SOCK_DGRAM socket by checking read/write frequently. 15 | * udt_dgram_client - a client using unblock SOCK_DGRAM socket by checking read/write frequently. 16 | 17 | * udt_stream_server - a server using unblock SOCK_STREAM socket by checking read/write frequently. 18 | * udt_stream_client - a client using unblock SOCK_STREAM socket by checking read/write frequently. 19 | 20 | 21 | #### Run test: 22 | ###### SOCK_DGRAM: 23 | * $ udt_bench_mark/udt_dgram_server/udt_dgram_server 127.0.0.1 12345 24 | * $ udt_bench_mark/udt_dgram_client/udt_dgram_client 22222 127.0.0.1 12345 1400 2>>./state.log 25 | 26 | ###### SOCK_STREAM: 27 | * $ udt_bench_mark/udt_stream_server/udt_stream_server 127.0.0.1 12345 28 | * $ udt_bench_mark/udt_stream_client/udt_stream_client 22222 127.0.0.1 12345 1400 2>>./state.log 29 | 30 | #### Other notes: 31 | ##### 1. the meaning of state.log 32 | * . - epoll_wait timeout return. means no socket prepare. 33 | * N - send: socket is non-blocking (UDT_SNDSYN = false) but no buffer space is available. 34 | * R - remove write event to socket 35 | * A - add write event to socket 36 | * B - epoll busy. sleep for stop add more msg to send buf. 37 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_client/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Generic Makefile for C/C++ Program 3 | # 4 | # License: GPL (General Public License) 5 | # Author: whyglinux 6 | # Date: 2006/03/04 (version 0.1) 7 | # 2007/03/24 (version 0.2) 8 | # 2007/04/09 (version 0.3) 9 | # 2007/06/26 (version 0.4) 10 | # 2008/04/05 (version 0.5) 11 | # 12 | # Description: 13 | # ------------ 14 | # This is an easily customizable makefile template. The purpose is to 15 | # provide an instant building environment for C/C++ programs. 16 | # 17 | # It searches all the C/C++ source files in the specified directories, 18 | # makes dependencies, compiles and links to form an executable. 19 | # 20 | # Besides its default ability to build C/C++ programs which use only 21 | # standard C/C++ libraries, you can customize the Makefile to build 22 | # those using other libraries. Once done, without any changes you can 23 | # then build programs using the same or less libraries, even if source 24 | # files are renamed, added or removed. Therefore, it is particularly 25 | # convenient to use it to build codes for experimental or study use. 26 | # 27 | # GNU make is expected to use the Makefile. Other versions of makes 28 | # may or may not work. 29 | # 30 | # Usage: 31 | # ------ 32 | # 1. Copy the Makefile to your program directory. 33 | # 2. Customize in the "Customizable Section" only if necessary: 34 | # * to use non-standard C/C++ libraries, set pre-processor or compiler 35 | # options to and linker ones to 36 | # (See Makefile.gtk+-2.0 for an example) 37 | # * to search sources in more directories, set to 38 | # * to specify your favorite program name, set to 39 | # 3. Type make to start building your program. 40 | # 41 | # Make Target: 42 | # ------------ 43 | # The Makefile provides the following targets to make: 44 | # $ make compile and link 45 | # $ make NODEP=yes compile and link without generating dependencies 46 | # $ make objs compile only (no linking) 47 | # $ make tags create tags for Emacs editor 48 | # $ make ctags create ctags for VI editor 49 | # $ make clean clean objects and the executable file 50 | # $ make distclean clean objects, the executable and dependencies 51 | # $ make help get the usage of the makefile 52 | # 53 | #=========================================================================== 54 | 55 | ## Customizable Section: adapt those variables to suit your program. 56 | ##========================================================================== 57 | 58 | OS_NAME="`uname -s`" 59 | LC_OS_NAME = $(shell echo $(OS_NAME) | tr '[A-Z]' '[a-z]') 60 | # MAC=darwin 61 | # CENTOS=linux 62 | 63 | # The pre-processor and compiler options. 64 | MY_CFLAGS = 65 | 66 | # The linker options. 67 | #MY_LIBS = $(BOOST_LIB_PATH)/libboost_system-mt.a $(BOOST_LIB_PATH)/libboost_filesystem-mt.a $(BOOST_LIB_PATH)/libboost_thread-mt.a $(PB_LIB_PATH)/libprotobuf.a ../essential/essential.a ../udt4/src/libudt.a 68 | MY_LIBS = ../udt4/src/libudt.a 69 | 70 | 71 | # The pre-processor options used by the cpp (man cpp for more). 72 | CPPFLAGS = -Wall -I ../udt4/src -g3 73 | 74 | # The options used in linking as well as in any direct use of ld. 75 | ifeq ($(LC_OS_NAME), darwin) 76 | LDFLAGS = -L/opt/local/lib -pthread 77 | else 78 | LDFLAGS = -L/opt/local/lib -pthread -lrt 79 | endif 80 | 81 | 82 | # The directories in which source files reside. 83 | # If not specified, only the current directory will be serached. 84 | SRCDIRS = ./ 85 | 86 | # The executable file name. 87 | # If not specified, current directory name or `a.out' will be used. 88 | PROGRAM = udt_stream_client 89 | 90 | ## Implicit Section: change the following only when necessary. 91 | ##========================================================================== 92 | 93 | # The source file types (headers excluded). 94 | # .c indicates C source files, and others C++ ones. 95 | SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp 96 | 97 | # The header file types. 98 | HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp 99 | 100 | # The pre-processor and compiler options. 101 | # Users can override those variables from the command line. 102 | CFLAGS = 103 | CXXFLAGS= -std=c++11 104 | 105 | # The C program compiler. 106 | CC = gcc 107 | 108 | # The C++ program compiler. 109 | CXX = g++ 110 | 111 | # Un-comment the following line to compile C programs as C++ ones. 112 | #CC = $(CXX) 113 | 114 | # The command used to delete file. 115 | #RM = rm -f 116 | 117 | ETAGS = etags 118 | ETAGSFLAGS = 119 | 120 | CTAGS = ctags 121 | CTAGSFLAGS = 122 | 123 | ## Stable Section: usually no need to be changed. But you can add more. 124 | ##========================================================================== 125 | SHELL = /bin/sh 126 | EMPTY = 127 | SPACE = $(EMPTY) $(EMPTY) 128 | ifeq ($(PROGRAM),) 129 | q 130 | q 131 | q 132 | CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR))) 133 | PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES)) 134 | ifeq ($(PROGRAM),) 135 | PROGRAM = a.out 136 | endif 137 | endif 138 | ifeq ($(SRCDIRS),) 139 | SRCDIRS = . 140 | endif 141 | SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS)))) 142 | HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS)))) 143 | SRC_CXX = $(filter-out %.c,$(SOURCES)) 144 | OBJS = $(addsuffix .o, $(basename $(SOURCES))) 145 | 146 | ## Define some useful variables. 147 | DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \ 148 | echo "-MM -MP"; else echo "-M"; fi ) 149 | DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) 150 | COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c 151 | COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c 152 | LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) 153 | LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) 154 | 155 | .PHONY: all objs tags ctags clean distclean help show 156 | 157 | # Delete the default suffixes 158 | .SUFFIXES: 159 | 160 | all: $(PROGRAM) 161 | 162 | 163 | # Rules for generating object files (.o). 164 | #---------------------------------------- 165 | objs:$(OBJS) 166 | 167 | %.o:%.c 168 | $(COMPILE.c) $< -o $@ 169 | 170 | %.o:%.C 171 | $(COMPILE.cxx) $< -o $@ 172 | 173 | %.o:%.cc 174 | $(COMPILE.cxx) $< -o $@ 175 | 176 | %.o:%.cpp 177 | $(COMPILE.cxx) $< -o $@ 178 | 179 | %.o:%.CPP 180 | $(COMPILE.cxx) $< -o $@ 181 | 182 | %.o:%.c++ 183 | $(COMPILE.cxx) $< -o $@ 184 | 185 | %.o:%.cp 186 | $(COMPILE.cxx) $< -o $@ 187 | 188 | %.o:%.cxx 189 | $(COMPILE.cxx) $< -o $@ 190 | 191 | # Rules for generating the tags. 192 | #------------------------------------- 193 | tags: $(HEADERS) $(SOURCES) 194 | $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES) 195 | 196 | ctags: $(HEADERS) $(SOURCES) 197 | $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES) 198 | 199 | # Rules for generating the executable. 200 | #------------------------------------- 201 | $(PROGRAM):$(OBJS) 202 | ifeq ($(SRC_CXX),) # C program 203 | $(LINK.c) $(OBJS) $(MY_LIBS) -o $@ 204 | @echo Type ./$@ to execute the program. 205 | else # C++ program 206 | $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@ 207 | @echo Type ./$@ to execute the program. 208 | endif 209 | 210 | ifndef NODEP 211 | ifneq ($(DEPS),) 212 | sinclude $(DEPS) 213 | endif 214 | endif 215 | 216 | clean: 217 | $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe 218 | 219 | distclean: clean 220 | $(RM) $(DEPS) TAGS 221 | 222 | # Show help. 223 | help: 224 | @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5' 225 | @echo 'Copyright (C) 2007, 2008 whyglinux ' 226 | @echo 227 | @echo 'Usage: make [TARGET]' 228 | @echo 'TARGETS:' 229 | @echo ' all (=make) compile and link.' 230 | @echo ' NODEP=yes make without generating dependencies.' 231 | @echo ' objs compile only (no linking).' 232 | @echo ' tags create tags for Emacs editor.' 233 | @echo ' ctags create ctags for VI editor.' 234 | @echo ' clean clean objects and the executable file.' 235 | @echo ' distclean clean objects, the executable and dependencies.' 236 | @echo ' show show variables (for debug use only).' 237 | @echo ' help print this message.' 238 | @echo 239 | @echo 'Report bugs to .' 240 | 241 | # Show variables (for debug use only.) 242 | show: 243 | @echo 'PROGRAM :' $(PROGRAM) 244 | @echo 'SRCDIRS :' $(SRCDIRS) 245 | @echo 'HEADERS :' $(HEADERS) 246 | @echo 'SOURCES :' $(SOURCES) 247 | @echo 'SRC_CXX :' $(SRC_CXX) 248 | @echo 'OBJS :' $(OBJS) 249 | @echo 'DEPS :' $(DEPS) 250 | @echo 'DEPEND :' $(DEPEND) 251 | @echo 'COMPILE.c :' $(COMPILE.c) 252 | @echo 'COMPILE.cxx :' $(COMPILE.cxx) 253 | @echo 'link.c :' $(LINK.c) 254 | @echo 'link.cxx :' $(LINK.cxx) 255 | 256 | ## End of the Makefile ## Suggestions are welcome ## All rights reserved ## 257 | ############################################################## 258 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_client/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "test_util.h" 13 | #include "udt_client.h" 14 | 15 | std::vector recv_package_interval_; 16 | std::vector recv_package_interval10_; 17 | 18 | static size_t test_str_size = 1460; 19 | 20 | #define CLOCK_INTERVAL_STR "_" 21 | msg_ptr_t make_test_str(size_t test_str_size) 22 | { 23 | std::ostringstream ostr; 24 | ostr << iclock64(); 25 | std::string msg_str = ostr.str(); 26 | msg_str += test_str(CLOCK_INTERVAL_STR, test_str_size - msg_str.size()); 27 | return msg_ptr_t(new std::string(msg_str)); 28 | } 29 | 30 | uint64_t get_time_from_msg(const std::string& msg) 31 | { 32 | std::size_t pos = msg.find(CLOCK_INTERVAL_STR); 33 | if (pos == std::string::npos) 34 | { 35 | std::cout << "wrong msg: " << msg << std::endl; 36 | return 0; 37 | } 38 | const std::string& time_str = msg.substr(0, pos); 39 | return std::atoll(time_str.c_str()); 40 | } 41 | 42 | std::string get_cur_time_str() 43 | { 44 | time_t tmpcal_ptr = {0}; 45 | struct tm *tmp_ptr = NULL; 46 | tmpcal_ptr = time(NULL); 47 | tmp_ptr = localtime(&tmpcal_ptr); 48 | std::ostringstream osstrm; 49 | osstrm << tmp_ptr->tm_hour << ":" << tmp_ptr->tm_min << "." << tmp_ptr->tm_sec; 50 | return osstrm.str(); 51 | } 52 | 53 | void handle_one_msg(const std::string& msg, const std::string& total_recved_str) 54 | { 55 | uint64_t send_time = get_time_from_msg(msg); 56 | uint64_t cur_time = iclock64(); 57 | 58 | static uint64_t static_last_refresh_time = 0; 59 | static size_t static_recved_bytes = 0; 60 | static_recved_bytes += msg.size(); 61 | 62 | { 63 | static size_t static_good_recv_count = 0; 64 | 65 | static_good_recv_count++; 66 | 67 | uint64_t interval = cur_time - send_time; 68 | recv_package_interval_.push_back(interval); 69 | recv_package_interval10_.push_back(interval); 70 | //std::cout << interval << ":" total_recved_str.size() << "\t"; 71 | std::cout << interval << "\t"; 72 | 73 | if (static_good_recv_count % 10 == 0) 74 | { 75 | int average10 = 0; 76 | for (int x : recv_package_interval10_) 77 | average10 += x; 78 | average10 = (average10 / 10); 79 | 80 | int average_total = 0; 81 | for (int x: recv_package_interval_) 82 | average_total += x; 83 | average_total = average_total / recv_package_interval_.size(); 84 | 85 | std::cout << "max: " << *std::max_element( recv_package_interval10_.begin(), recv_package_interval10_.end() ) << 86 | " average 10: " << average10 << 87 | " average total: " << average_total; 88 | if (cur_time - static_last_refresh_time > 10 * 1000) 89 | { 90 | std::cout << " " << static_cast(static_recved_bytes * 10 / (cur_time - static_last_refresh_time)) / 10 << "KB/s(in)"; 91 | static_last_refresh_time = cur_time; 92 | static_recved_bytes = 0; 93 | } 94 | std::cout << std::endl; 95 | std::cout << get_cur_time_str() << " "; 96 | recv_package_interval10_.clear(); 97 | } 98 | std::cout.flush(); 99 | } 100 | } 101 | 102 | void recv_func(const std::shared_ptr& str) 103 | { 104 | static std::string recved_str; 105 | recved_str += *str; 106 | while (recved_str.size() >= test_str_size) 107 | { 108 | size_t len_for_check = recved_str.size(); 109 | const std::string& msg = recved_str.substr(0, test_str_size); 110 | recved_str.erase(0, test_str_size); 111 | if (len_for_check - recved_str.size() != test_str_size) 112 | std::cout << "split msg error" << std::endl; 113 | handle_one_msg(msg, recved_str); 114 | } 115 | } 116 | 117 | int main(int argc, char* argv[]) 118 | { 119 | try 120 | { 121 | // Check command line arguments. 122 | if (argc != 4 && argc != 5) 123 | { 124 | std::cerr << "Usage: battle_client_udt \n"; 125 | std::cerr << " For IPv4, try:\n"; 126 | std::cerr << " client_udt 12345 120.123,2.123 80 1460\n"; 127 | return 1; 128 | } 129 | } 130 | catch (std::exception& e) 131 | { 132 | std::cerr << "exception: " << e.what() << "\n"; 133 | } 134 | 135 | //ignore SIGPIPE 136 | sigset_t ps; 137 | sigemptyset(&ps); 138 | sigaddset(&ps, SIGPIPE); 139 | pthread_sigmask(SIG_BLOCK, &ps, NULL); 140 | 141 | if (argc == 5) 142 | test_str_size = std::atoi(argv[4]); 143 | 144 | auto client = std::make_shared(std::atoi(argv[1]), argv[2], std::atoi(argv[3]), recv_func); 145 | int start_ret = client->Start(); 146 | if (start_ret == 0) 147 | return 0; 148 | 149 | while (true) 150 | { 151 | msg_ptr_t msg = make_test_str(test_str_size); 152 | client->SendMsg(msg); 153 | 154 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 155 | size_t buf_size = client->SendMsgBufSize(); 156 | while (buf_size > 500 * 50) 157 | { 158 | std::cerr << "B"; 159 | std::cerr.flush(); 160 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 161 | buf_size = client->SendMsgBufSize(); 162 | } 163 | } 164 | 165 | return 1; 166 | } 167 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_client/test_util.cpp: -------------------------------------------------------------------------------- 1 | #include "test_util.h" 2 | #include 3 | 4 | std::string test_str(const std::string& str_prefix, const size_t str_len) 5 | { 6 | std::ostringstream ostr; 7 | ostr << str_prefix << ':'; 8 | std::string str = ostr.str(); 9 | 10 | // when len <= prefixLen 11 | // test_str(adfadf, 3) == adf 12 | if (str.size() >= str_len) 13 | { 14 | str.resize(str_len); 15 | return str; 16 | } 17 | 18 | // when len < 20 19 | // test_str(adf, 13) == adfa:67890123 20 | if (str_len < 20) 21 | { 22 | for (size_t i = str.size() + 1; i <= str_len; ++i) 23 | str.push_back(char(((i % 10) + 0x30))); 24 | return str; 25 | } 26 | 27 | // when len >= 20 28 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 29 | { 30 | // asdf:===== 31 | str.resize(10, '='); 32 | 33 | // (20_56789)(30_56789) 34 | while (str.size() + 10 <= str_len) 35 | { 36 | const size_t new_len = str.size() + 10; 37 | std::ostringstream tmp_ostrm; 38 | tmp_ostrm << str << "(" << new_len << '_'; 39 | str = tmp_ostrm.str(); 40 | for (size_t i = str.size() + 1; i < new_len; ++i) 41 | str.push_back(char(((i % 10) + 0x30))); 42 | str += ')'; 43 | } 44 | 45 | // 12345 46 | if (str.size() < str_len) 47 | { 48 | for (size_t i = str.size() + 1; i <= str_len; ++i) 49 | { 50 | char c = ((i % 10) + 0x30); 51 | str.push_back(c); 52 | } 53 | } 54 | return str; 55 | } 56 | 57 | return str; 58 | } 59 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_client/test_util.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DD_TEST_UTIL_H__ 3 | #define _DD_TEST_UTIL_H__ 4 | #include 5 | 6 | #include 7 | 8 | // when len <= prefixLen 9 | // test_str(adfadf, 3) == adf 10 | // when len < 20 11 | // test_str(adf, 13) == adfa:67890123 12 | // when len >= 20 13 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 14 | std::string test_str(const std::string& str_prefix, const size_t str_len); 15 | 16 | /* get system time */ 17 | static inline void itimeofday(long *sec, long *usec) 18 | { 19 | struct timeval time; 20 | gettimeofday(&time, NULL); 21 | if (sec) *sec = time.tv_sec; 22 | if (usec) *usec = time.tv_usec; 23 | } 24 | 25 | /* get clock in millisecond 64 */ 26 | static inline uint64_t iclock64(void) 27 | { 28 | long s, u; 29 | uint64_t value; 30 | itimeofday(&s, &u); 31 | value = ((uint64_t)s) * 1000 + (u / 1000); 32 | return value; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_client/threadsafe_queue.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | template 7 | class threadsafe_queue 8 | { 9 | private: 10 | mutable std::mutex mut; 11 | std::queue data_queue; 12 | std::condition_variable data_cond; 13 | public: 14 | threadsafe_queue(){} 15 | threadsafe_queue(threadsafe_queue const& other) 16 | { 17 | std::lock_guard lk(other.mut); 18 | data_queue=other.data_queue; 19 | } 20 | size_t size() 21 | { 22 | std::lock_guard lk(mut); 23 | return data_queue.size(); 24 | } 25 | void push(T new_value) 26 | { 27 | std::lock_guard lk(mut); 28 | data_queue.push(new_value); 29 | data_cond.notify_one(); 30 | } 31 | void wait_and_pop(T& value) 32 | { 33 | std::unique_lock lk(mut); 34 | data_cond.wait(lk,[this]{return !data_queue.empty();}); 35 | value=data_queue.front(); 36 | data_queue.pop(); 37 | } 38 | std::shared_ptr wait_and_pop() 39 | { 40 | std::unique_lock lk(mut); 41 | data_cond.wait(lk,[this]{return !data_queue.empty();}); 42 | std::shared_ptr res(std::make_shared(data_queue.front())); 43 | data_queue.pop(); 44 | return res; 45 | } 46 | bool try_pop(T& value) 47 | { 48 | std::lock_guard lk(mut); 49 | if(data_queue.empty()) 50 | return false; 51 | value=data_queue.front(); 52 | data_queue.pop(); 53 | return true; 54 | } 55 | std::shared_ptr try_pop() 56 | { 57 | std::lock_guard lk(mut); 58 | if(data_queue.empty()) 59 | return std::shared_ptr(); 60 | std::shared_ptr res(std::make_shared(data_queue.front())); 61 | data_queue.pop(); 62 | return res; 63 | } 64 | std::queue&& grab_all2(void) 65 | { 66 | std::queue ret; 67 | 68 | { 69 | std::lock_guard lk(mut); 70 | std::swap(ret, data_queue); 71 | } 72 | 73 | return std::move(ret); 74 | } 75 | std::queue grab_all(void) 76 | { 77 | std::queue ret; 78 | 79 | { 80 | std::lock_guard lk(mut); 81 | std::swap(ret, data_queue); 82 | } 83 | 84 | return ret; 85 | } 86 | bool empty() const 87 | { 88 | std::lock_guard lk(mut); 89 | return data_queue.empty(); 90 | } 91 | }; 92 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_client/udt_client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "udt_client.h" 10 | #include "test_util.h" 11 | 12 | 13 | const int g_IP_Version = AF_INET; 14 | 15 | 16 | UDTClient::UDTClient(int local_port, const std::string& ip_connect_to, int port_connect_to, recv_callback_func_t recv_func) : 17 | recv_callback_func_(recv_func), 18 | local_port_(local_port), 19 | ip_connect_to_(ip_connect_to), 20 | port_connect_to_(port_connect_to), 21 | sock_(UDT::INVALID_SOCK), 22 | udtbuf_recved_len_(0), 23 | udt_running_(0), 24 | udt_eid_(-1) 25 | { 26 | } 27 | 28 | int UDTClient::Start(void) 29 | { 30 | udt_running_ = 0; 31 | 32 | // create, bind 33 | // 34 | CreateSocket(); 35 | 36 | // connect to the server, implict bind 37 | if (0 == Connect()) 38 | { 39 | return 0; 40 | } 41 | 42 | // sleep 5 sencods for connect success. 43 | std::this_thread::sleep_for(std::chrono::seconds(5)); 44 | 45 | udt_thread_ = std::thread(std::bind(&UDTClient::Run, shared_from_this())); 46 | return 1; 47 | } 48 | 49 | void UDTClient::SendMsg(msg_ptr_t msg) 50 | { 51 | send_msg_buf_ += *msg; 52 | } 53 | 54 | size_t UDTClient::SendMsgBufSize(void) 55 | { 56 | return send_msg_buf_.size(); 57 | } 58 | 59 | std::deque UDTClient::RecvMsg(void) // todo: using move symatic 60 | { 61 | return std::deque(); 62 | } 63 | 64 | // return -1 means error. otherwise return 0 65 | int UDTClient::CreateSocket(void) 66 | { 67 | sock_ = UDT::socket(AF_INET, SOCK_STREAM, 0); 68 | //sock_ = UDT::socket(AF_INET, SOCK_DGRAM, 0); 69 | if (UDT::INVALID_SOCK == sock_) 70 | { 71 | std::cout << "UDT socket: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage(); 72 | return -1; 73 | } 74 | 75 | // setopt 76 | { 77 | bool block = false; 78 | UDT::setsockopt(sock_, 0, UDT_SNDSYN, &block, sizeof(bool)); 79 | UDT::setsockopt(sock_, 0, UDT_RCVSYN, &block, sizeof(bool)); 80 | 81 | //UDT::setsockopt(sock_, 0, UDT_MSS, new int(1500), sizeof(int)); 82 | 83 | //int snd_buf = 16000;// 8192; 84 | //int rcv_buf = 16000;//8192; 85 | //int snd_buf = 7300;// 1460 * 5 86 | int snd_buf = 934400;// 1460 * 5 87 | int rcv_buf = 934400; 88 | UDT::setsockopt(sock_, 0, UDT_SNDBUF, &snd_buf, sizeof(int)); 89 | UDT::setsockopt(sock_, 0, UDT_RCVBUF, &rcv_buf, sizeof(int)); 90 | 91 | 92 | //int fc = 4096; 93 | //UDT::setsockopt(sock_, 0, UDT_FC, &fc, sizeof(int)); 94 | 95 | bool reuse = true; 96 | UDT::setsockopt(sock_, 0, UDT_REUSEADDR, &reuse, sizeof(bool)); 97 | 98 | bool rendezvous = false; 99 | UDT::setsockopt(sock_, 0, UDT_RENDEZVOUS, &rendezvous, sizeof(bool)); 100 | } 101 | 102 | // bind 103 | sockaddr_in my_addr; 104 | my_addr.sin_family = AF_INET; 105 | my_addr.sin_port = htons(local_port_); 106 | my_addr.sin_addr.s_addr = INADDR_ANY; 107 | std::memset(&(my_addr.sin_zero), '\0', 8); 108 | if (UDT::ERROR == UDT::bind(sock_, (sockaddr*)&my_addr, sizeof(my_addr))) 109 | { 110 | std::cout << "UDT bind: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 111 | return -1; 112 | } 113 | 114 | // success 115 | return 0; 116 | } 117 | 118 | void UDTClient::TrySendMsg(void) 119 | { 120 | if (send_msg_buf_.empty()) 121 | return; 122 | 123 | int send_len = DoSendMsg(send_msg_buf_); 124 | if (send_len > 0) 125 | send_msg_buf_.erase(0, send_len); 126 | } 127 | 128 | // return the actual send len 129 | int UDTClient::DoSendMsg(const std::string& msg) 130 | { 131 | int send_ret = UDT::send(sock_, msg.c_str(), msg.size(), 0); 132 | if (UDT::ERROR == send_ret) 133 | { 134 | CUDTException& lasterror = UDT::getlasterror(); 135 | const int error_code = lasterror.getErrorCode(); 136 | if (error_code == CUDTException::EASYNCSND) 137 | { 138 | std::cerr << "N"; std::cerr.flush(); 139 | return 0; 140 | } 141 | 142 | std::cout << "UDT sendmsg: " << error_code << ' ' << lasterror.getErrorMessage() << std::endl; 143 | udt_running_ = 0; 144 | return 0; 145 | } 146 | return send_ret; 147 | } 148 | 149 | void UDTClient::DoRecvMsg(void) 150 | { 151 | udtbuf_recved_len_ = 0; 152 | 153 | int recv_ret = 0; 154 | if (UDT::ERROR == (recv_ret = UDT::recv(sock_, udtbuf_, sizeof(udtbuf_), 0))) { 155 | CUDTException& lasterror = UDT::getlasterror(); 156 | const int error_code = lasterror.getErrorCode(); 157 | 158 | if (error_code == CUDTException::EASYNCRCV) // no data available for read. 159 | { 160 | return; 161 | } 162 | 163 | std::cout << "UDT recv: " << error_code << " " << lasterror.getErrorMessage() << std::endl; 164 | if (CUDTException::EINVPARAM == error_code || CUDTException::ECONNLOST == error_code || CUDTException::EINVSOCK == error_code) { 165 | udt_running_ = 0; 166 | } 167 | return; 168 | } 169 | 170 | if (recv_ret > 0) 171 | { 172 | udtbuf_recved_len_ = recv_ret; 173 | if (recv_callback_func_) 174 | { 175 | std::shared_ptr recved_str(new std::string(udtbuf_, udtbuf_recved_len_)); 176 | recv_callback_func_(recved_str); 177 | } 178 | return; 179 | } 180 | 181 | std::cout << "UDT recv zero len" << std::endl; 182 | return; 183 | } 184 | 185 | int UDTClient::Connect(void) 186 | { 187 | sockaddr_in serv_addr; 188 | serv_addr.sin_family = AF_INET; 189 | serv_addr.sin_port = htons(port_connect_to_); 190 | inet_pton(AF_INET, ip_connect_to_.c_str(), &serv_addr.sin_addr); 191 | std::memset(&(serv_addr.sin_zero), '\0', 8); 192 | std::cout << "connect to: " << ip_connect_to_ << " " << port_connect_to_ << std::endl; 193 | if (UDT::ERROR == UDT::connect(sock_, (sockaddr*)&serv_addr, sizeof(serv_addr))) 194 | { 195 | std::cout << "UDT connect: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 196 | return 0; 197 | } 198 | 199 | return 1; 200 | } 201 | 202 | void UDTClient::TryRecvMsg(void) 203 | { 204 | DoRecvMsg(); 205 | } 206 | 207 | int UDTClient::Run(void) 208 | { 209 | udt_running_ = 1; 210 | 211 | std::cout << "Run UDT client loop ...\n"; 212 | udt_running_ = 1; 213 | 214 | while (udt_running_) { 215 | TrySendMsg(); 216 | TryRecvMsg(); 217 | 218 | TrySendMsg(); 219 | TryRecvMsg(); 220 | 221 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 222 | } 223 | 224 | 225 | std::cout << "Close client ..."; 226 | int close_state = UDT::close(sock_); 227 | if (close_state != 0) 228 | std::cout << "UDT close: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 229 | 230 | std::cout << "ok\n"; 231 | 232 | pthread_detach(pthread_self()); 233 | 234 | return 1; 235 | } 236 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_client/udt_client.h: -------------------------------------------------------------------------------- 1 | #ifndef __UDT_CLIENT_H_ 2 | #define __UDT_CLIENT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "threadsafe_queue.hpp" 12 | 13 | 14 | typedef int UDTSOCKET; 15 | typedef std::function&)> recv_callback_func_t; 16 | typedef std::shared_ptr msg_ptr_t; 17 | 18 | // the UDTClient will create another thread for UDT sending and recving. 19 | class UDTClient : public std::enable_shared_from_this 20 | { 21 | public: 22 | // when recv_func valid, 23 | // recv_callback_func will be called by another thread when a package recved. recv_callback_func should be thread safe. 24 | // when recv_func invalid, 25 | // packages recved will stored in queue. You should call TryRecvMsg frequently (10 milliseconds for example) to get the recved msg. 26 | UDTClient(int local_port, const std::string& ip_connect_to, int port_connect_to, recv_callback_func_t recv_func = nullptr); 27 | int Start(void); 28 | 29 | void SendMsg(msg_ptr_t msg); 30 | size_t SendMsgBufSize(void); 31 | std::deque RecvMsg(void); // todo: using move symatic 32 | 33 | private: 34 | void TrySendMsg(void); 35 | 36 | // return the actual send len 37 | int DoSendMsg(const std::string& msg); 38 | 39 | void TryRecvMsg(void); 40 | void DoRecvMsg(void); 41 | int Run(void); 42 | int CreateSocket(void); 43 | int Connect(void); 44 | 45 | private: 46 | recv_callback_func_t recv_callback_func_; 47 | std::string send_msg_buf_; 48 | 49 | int local_port_; 50 | std::string ip_connect_to_; 51 | int port_connect_to_; 52 | 53 | std::thread udt_thread_; 54 | UDTSOCKET sock_; 55 | char udtbuf_[1024 * 100]; 56 | size_t udtbuf_recved_len_; 57 | int udt_running_; 58 | int udt_eid_; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_server/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Generic Makefile for C/C++ Program 3 | # 4 | # License: GPL (General Public License) 5 | # Author: whyglinux 6 | # Date: 2006/03/04 (version 0.1) 7 | # 2007/03/24 (version 0.2) 8 | # 2007/04/09 (version 0.3) 9 | # 2007/06/26 (version 0.4) 10 | # 2008/04/05 (version 0.5) 11 | # 12 | # Description: 13 | # ------------ 14 | # This is an easily customizable makefile template. The purpose is to 15 | # provide an instant building environment for C/C++ programs. 16 | # 17 | # It searches all the C/C++ source files in the specified directories, 18 | # makes dependencies, compiles and links to form an executable. 19 | # 20 | # Besides its default ability to build C/C++ programs which use only 21 | # standard C/C++ libraries, you can customize the Makefile to build 22 | # those using other libraries. Once done, without any changes you can 23 | # then build programs using the same or less libraries, even if source 24 | # files are renamed, added or removed. Therefore, it is particularly 25 | # convenient to use it to build codes for experimental or study use. 26 | # 27 | # GNU make is expected to use the Makefile. Other versions of makes 28 | # may or may not work. 29 | # 30 | # Usage: 31 | # ------ 32 | # 1. Copy the Makefile to your program directory. 33 | # 2. Customize in the "Customizable Section" only if necessary: 34 | # * to use non-standard C/C++ libraries, set pre-processor or compiler 35 | # options to and linker ones to 36 | # (See Makefile.gtk+-2.0 for an example) 37 | # * to search sources in more directories, set to 38 | # * to specify your favorite program name, set to 39 | # 3. Type make to start building your program. 40 | # 41 | # Make Target: 42 | # ------------ 43 | # The Makefile provides the following targets to make: 44 | # $ make compile and link 45 | # $ make NODEP=yes compile and link without generating dependencies 46 | # $ make objs compile only (no linking) 47 | # $ make tags create tags for Emacs editor 48 | # $ make ctags create ctags for VI editor 49 | # $ make clean clean objects and the executable file 50 | # $ make distclean clean objects, the executable and dependencies 51 | # $ make help get the usage of the makefile 52 | # 53 | #=========================================================================== 54 | 55 | ## Customizable Section: adapt those variables to suit your program. 56 | ##========================================================================== 57 | 58 | OS_NAME="`uname -s`" 59 | LC_OS_NAME = $(shell echo $(OS_NAME) | tr '[A-Z]' '[a-z]') 60 | # MAC=darwin 61 | # CENTOS=linux 62 | 63 | # The pre-processor and compiler options. 64 | MY_CFLAGS = 65 | 66 | # The linker options. 67 | #MY_LIBS = $(BOOST_LIB_PATH)/libboost_system-mt.a $(BOOST_LIB_PATH)/libboost_filesystem-mt.a $(BOOST_LIB_PATH)/libboost_thread-mt.a $(PB_LIB_PATH)/libprotobuf.a ../essential/essential.a ../udt4/src/libudt.a 68 | MY_LIBS = ../udt4/src/libudt.a 69 | 70 | 71 | # The pre-processor options used by the cpp (man cpp for more). 72 | CPPFLAGS = -Wall -I ../udt4/src -g3 73 | 74 | # The options used in linking as well as in any direct use of ld. 75 | ifeq ($(LC_OS_NAME), darwin) 76 | LDFLAGS = -L/opt/local/lib -pthread 77 | else 78 | LDFLAGS = -L/opt/local/lib -pthread -lrt 79 | endif 80 | 81 | 82 | # The directories in which source files reside. 83 | # If not specified, only the current directory will be serached. 84 | SRCDIRS = ./ 85 | 86 | # The executable file name. 87 | # If not specified, current directory name or `a.out' will be used. 88 | PROGRAM = udt_stream_server 89 | 90 | ## Implicit Section: change the following only when necessary. 91 | ##========================================================================== 92 | 93 | # The source file types (headers excluded). 94 | # .c indicates C source files, and others C++ ones. 95 | SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp 96 | 97 | # The header file types. 98 | HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp 99 | 100 | # The pre-processor and compiler options. 101 | # Users can override those variables from the command line. 102 | CFLAGS = 103 | CXXFLAGS= -std=c++11 104 | 105 | # The C program compiler. 106 | CC = gcc 107 | 108 | # The C++ program compiler. 109 | CXX = g++ 110 | 111 | # Un-comment the following line to compile C programs as C++ ones. 112 | #CC = $(CXX) 113 | 114 | # The command used to delete file. 115 | #RM = rm -f 116 | 117 | ETAGS = etags 118 | ETAGSFLAGS = 119 | 120 | CTAGS = ctags 121 | CTAGSFLAGS = 122 | 123 | ## Stable Section: usually no need to be changed. But you can add more. 124 | ##========================================================================== 125 | SHELL = /bin/sh 126 | EMPTY = 127 | SPACE = $(EMPTY) $(EMPTY) 128 | ifeq ($(PROGRAM),) 129 | q 130 | q 131 | q 132 | CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR))) 133 | PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES)) 134 | ifeq ($(PROGRAM),) 135 | PROGRAM = a.out 136 | endif 137 | endif 138 | ifeq ($(SRCDIRS),) 139 | SRCDIRS = . 140 | endif 141 | SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS)))) 142 | HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS)))) 143 | SRC_CXX = $(filter-out %.c,$(SOURCES)) 144 | OBJS = $(addsuffix .o, $(basename $(SOURCES))) 145 | 146 | ## Define some useful variables. 147 | DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \ 148 | echo "-MM -MP"; else echo "-M"; fi ) 149 | DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) 150 | COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c 151 | COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c 152 | LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) 153 | LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) 154 | 155 | .PHONY: all objs tags ctags clean distclean help show 156 | 157 | # Delete the default suffixes 158 | .SUFFIXES: 159 | 160 | all: $(PROGRAM) 161 | 162 | 163 | # Rules for generating object files (.o). 164 | #---------------------------------------- 165 | objs:$(OBJS) 166 | 167 | %.o:%.c 168 | $(COMPILE.c) $< -o $@ 169 | 170 | %.o:%.C 171 | $(COMPILE.cxx) $< -o $@ 172 | 173 | %.o:%.cc 174 | $(COMPILE.cxx) $< -o $@ 175 | 176 | %.o:%.cpp 177 | $(COMPILE.cxx) $< -o $@ 178 | 179 | %.o:%.CPP 180 | $(COMPILE.cxx) $< -o $@ 181 | 182 | %.o:%.c++ 183 | $(COMPILE.cxx) $< -o $@ 184 | 185 | %.o:%.cp 186 | $(COMPILE.cxx) $< -o $@ 187 | 188 | %.o:%.cxx 189 | $(COMPILE.cxx) $< -o $@ 190 | 191 | # Rules for generating the tags. 192 | #------------------------------------- 193 | tags: $(HEADERS) $(SOURCES) 194 | $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES) 195 | 196 | ctags: $(HEADERS) $(SOURCES) 197 | $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES) 198 | 199 | # Rules for generating the executable. 200 | #------------------------------------- 201 | $(PROGRAM):$(OBJS) 202 | ifeq ($(SRC_CXX),) # C program 203 | $(LINK.c) $(OBJS) $(MY_LIBS) -o $@ 204 | @echo Type ./$@ to execute the program. 205 | else # C++ program 206 | $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@ 207 | @echo Type ./$@ to execute the program. 208 | endif 209 | 210 | ifndef NODEP 211 | ifneq ($(DEPS),) 212 | sinclude $(DEPS) 213 | endif 214 | endif 215 | 216 | clean: 217 | $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe 218 | 219 | distclean: clean 220 | $(RM) $(DEPS) TAGS 221 | 222 | # Show help. 223 | help: 224 | @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5' 225 | @echo 'Copyright (C) 2007, 2008 whyglinux ' 226 | @echo 227 | @echo 'Usage: make [TARGET]' 228 | @echo 'TARGETS:' 229 | @echo ' all (=make) compile and link.' 230 | @echo ' NODEP=yes make without generating dependencies.' 231 | @echo ' objs compile only (no linking).' 232 | @echo ' tags create tags for Emacs editor.' 233 | @echo ' ctags create ctags for VI editor.' 234 | @echo ' clean clean objects and the executable file.' 235 | @echo ' distclean clean objects, the executable and dependencies.' 236 | @echo ' show show variables (for debug use only).' 237 | @echo ' help print this message.' 238 | @echo 239 | @echo 'Report bugs to .' 240 | 241 | # Show variables (for debug use only.) 242 | show: 243 | @echo 'PROGRAM :' $(PROGRAM) 244 | @echo 'SRCDIRS :' $(SRCDIRS) 245 | @echo 'HEADERS :' $(HEADERS) 246 | @echo 'SOURCES :' $(SOURCES) 247 | @echo 'SRC_CXX :' $(SRC_CXX) 248 | @echo 'OBJS :' $(OBJS) 249 | @echo 'DEPS :' $(DEPS) 250 | @echo 'DEPEND :' $(DEPEND) 251 | @echo 'COMPILE.c :' $(COMPILE.c) 252 | @echo 'COMPILE.cxx :' $(COMPILE.cxx) 253 | @echo 'link.c :' $(LINK.c) 254 | @echo 'link.cxx :' $(LINK.cxx) 255 | 256 | ## End of the Makefile ## Suggestions are welcome ## All rights reserved ## 257 | ############################################################## 258 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_server/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "udt_server.h" 10 | 11 | int main(int argc, char* argv[]) 12 | { 13 | try 14 | { 15 | // Check command line arguments. 16 | if (argc != 3) 17 | { 18 | std::cerr << "Usage: server_udt
\n"; 19 | std::cerr << " For IPv4, try:\n"; 20 | std::cerr << " battle_server 0.0.0.0 80\n"; 21 | std::cerr << " For IPv6, try:\n"; 22 | std::cerr << " battle_server 0::0 80\n"; 23 | return 1; 24 | } 25 | } 26 | catch (std::exception& e) 27 | { 28 | std::cerr << "exception: " << e.what() << "\n"; 29 | } 30 | 31 | std::cout << "run battle_server_udt on " << argv[1] << ':' << argv[2] << std::endl; 32 | 33 | //ignore SIGPIPE 34 | sigset_t ps; 35 | sigemptyset(&ps); 36 | sigaddset(&ps, SIGPIPE); 37 | pthread_sigmask(SIG_BLOCK, &ps, NULL); 38 | 39 | auto server = std::make_shared(); 40 | server->Run(std::atoi(argv[2])); 41 | return 1; 42 | } 43 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_server/test_util.cpp: -------------------------------------------------------------------------------- 1 | #include "test_util.h" 2 | #include 3 | 4 | std::string test_str(const std::string& str_prefix, const size_t str_len) 5 | { 6 | std::ostringstream ostr; 7 | ostr << str_prefix << ':'; 8 | std::string str = ostr.str(); 9 | 10 | // when len <= prefixLen 11 | // test_str(adfadf, 3) == adf 12 | if (str.size() >= str_len) 13 | { 14 | str.resize(str_len); 15 | return str; 16 | } 17 | 18 | // when len < 20 19 | // test_str(adf, 13) == adfa:67890123 20 | if (str_len < 20) 21 | { 22 | for (size_t i = str.size() + 1; i <= str_len; ++i) 23 | str.push_back(char(((i % 10) + 0x30))); 24 | return str; 25 | } 26 | 27 | // when len >= 20 28 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 29 | { 30 | // asdf:===== 31 | str.resize(10, '='); 32 | 33 | // (20_56789)(30_56789) 34 | while (str.size() + 10 <= str_len) 35 | { 36 | const size_t new_len = str.size() + 10; 37 | std::ostringstream tmp_ostrm; 38 | tmp_ostrm << str << "(" << new_len << '_'; 39 | str = tmp_ostrm.str(); 40 | for (size_t i = str.size() + 1; i < new_len; ++i) 41 | str.push_back(char(((i % 10) + 0x30))); 42 | str += ')'; 43 | } 44 | 45 | // 12345 46 | if (str.size() < str_len) 47 | { 48 | for (size_t i = str.size() + 1; i <= str_len; ++i) 49 | { 50 | char c = ((i % 10) + 0x30); 51 | str.push_back(c); 52 | } 53 | } 54 | return str; 55 | } 56 | 57 | return str; 58 | } 59 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_server/test_util.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DD_TEST_UTIL_H__ 3 | #define _DD_TEST_UTIL_H__ 4 | #include 5 | 6 | // when len <= prefixLen 7 | // test_str(adfadf, 3) == adf 8 | // when len < 20 9 | // test_str(adf, 13) == adfa:67890123 10 | // when len >= 20 11 | // test_str(asdf, 45) = asdf:=====(20_56789)(30_56789)12345 12 | std::string test_str(const std::string& str_prefix, const size_t str_len); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_server/udt_server.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "test_util.h" 12 | #include "udt_server.h" 13 | 14 | const int g_IP_Version = AF_INET; 15 | //const int g_Socket_Type = SOCK_STREAM; 16 | const int g_Socket_Type = SOCK_DGRAM; 17 | 18 | /* get system time */ 19 | static inline void itimeofday(long *sec, long *usec) 20 | { 21 | struct timeval time; 22 | gettimeofday(&time, NULL); 23 | if (sec) *sec = time.tv_sec; 24 | if (usec) *usec = time.tv_usec; 25 | } 26 | 27 | /* get clock in millisecond 64 */ 28 | static inline uint64_t iclock64(void) 29 | { 30 | long s, u; 31 | uint64_t value; 32 | itimeofday(&s, &u); 33 | value = ((uint64_t)s) * 1000 + (u / 1000); 34 | return value; 35 | } 36 | 37 | 38 | std::string get_cur_time_str() 39 | { 40 | time_t tmpcal_ptr = {0}; 41 | struct tm *tmp_ptr = NULL; 42 | tmpcal_ptr = time(NULL); 43 | tmp_ptr = localtime(&tmpcal_ptr); 44 | std::ostringstream osstrm; 45 | osstrm << tmp_ptr->tm_hour << ":" << tmp_ptr->tm_min << "." << tmp_ptr->tm_sec; 46 | return osstrm.str(); 47 | } 48 | 49 | 50 | 51 | UDTServer::UDTServer(void) : 52 | listen_sock_(UDT::INVALID_SOCK) 53 | { 54 | } 55 | 56 | // return -1 means error. otherwise return 0 57 | int UDTServer::CreateListenSocket(int listen_port) 58 | { 59 | listen_sock_ = UDT::socket(AF_INET, SOCK_STREAM, 0); 60 | //listen_sock_ = UDT::socket(AF_INET, SOCK_DGRAM, 0); 61 | if (UDT::INVALID_SOCK == listen_sock_) 62 | { 63 | std::cout << "UDT socket: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage(); 64 | return -1; 65 | } 66 | 67 | // setopt 68 | { 69 | bool block = false; 70 | UDT::setsockopt(listen_sock_, 0, UDT_SNDSYN, &block, sizeof(bool)); 71 | UDT::setsockopt(listen_sock_, 0, UDT_RCVSYN, &block, sizeof(bool)); 72 | 73 | //UDT::setsockopt(listen_sock_, 0, UDT_MSS, new int(1500), sizeof(int)); // default is 1500 74 | 75 | int snd_buf = 934400;// 1460 * 64 = 93440 76 | int rcv_buf = 934400; 77 | UDT::setsockopt(listen_sock_, 0, UDT_SNDBUF, &snd_buf, sizeof(int)); // default is 10MB 78 | UDT::setsockopt(listen_sock_, 0, UDT_RCVBUF, &rcv_buf, sizeof(int)); // default is 10MB 79 | 80 | 81 | //int fc = 4096; 82 | //UDT::setsockopt(listen_sock_, 0, UDT_FC, &fc, sizeof(int)); 83 | 84 | bool reuse = true; 85 | UDT::setsockopt(listen_sock_, 0, UDT_REUSEADDR, &reuse, sizeof(bool)); 86 | 87 | bool rendezvous = false; 88 | UDT::setsockopt(listen_sock_, 0, UDT_RENDEZVOUS, &rendezvous, sizeof(bool)); 89 | } 90 | 91 | // bind 92 | sockaddr_in my_addr; 93 | my_addr.sin_family = AF_INET; 94 | my_addr.sin_port = htons(listen_port); 95 | my_addr.sin_addr.s_addr = INADDR_ANY; 96 | std::memset(&(my_addr.sin_zero), '\0', 8); 97 | if (UDT::ERROR == UDT::bind(listen_sock_, (sockaddr*)&my_addr, sizeof(my_addr))) 98 | { 99 | std::cout << "UDT bind: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 100 | return -1; 101 | } 102 | 103 | // listen 104 | // 105 | if (UDT::ERROR == UDT::listen(listen_sock_, 20)) 106 | { 107 | std::cout << "UDT listen: " << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 108 | return -1; 109 | } 110 | 111 | // success 112 | return 0; 113 | } 114 | 115 | void UDTServer::Run(int listen_port) 116 | { 117 | // create, bind and listen 118 | // 119 | CreateListenSocket(listen_port); 120 | 121 | while (true) 122 | { 123 | struct sockaddr addr; 124 | int addrlen = sizeof(sockaddr); 125 | 126 | const UDTSOCKET accept_ret = UDT::accept(listen_sock_, &addr, &addrlen); 127 | if (accept_ret == UDT::INVALID_SOCK) 128 | { 129 | CUDTException& lasterror = UDT::getlasterror(); 130 | const int error_code = lasterror.getErrorCode(); 131 | 132 | if (error_code == CUDTException::EASYNCRCV) 133 | { 134 | { 135 | std::cout << "."; 136 | static time_t static_last_time = 0; 137 | const time_t cur_time = std::time(NULL); 138 | if (cur_time != static_last_time) 139 | { 140 | static_last_time = cur_time; 141 | std::cout << std::endl << get_cur_time_str() << " "; 142 | } 143 | std::cout.flush(); 144 | } 145 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 146 | continue; 147 | } 148 | 149 | std::cout << "UDT accept: " << error_code << " " << lasterror.getErrorMessage() << std::endl; 150 | break; 151 | } 152 | 153 | { 154 | const UDTSOCKET new_sock = accept_ret; 155 | std::thread connection_thread(std::bind(&UDTServer::WorkThread, shared_from_this(), new_sock)); 156 | connection_thread.detach(); 157 | } 158 | } 159 | 160 | 161 | 162 | 163 | std::cout << "Close server ..."; 164 | int close_state = UDT::close(listen_sock_); 165 | if (close_state != 0) 166 | std::cout << "UDT close:" << UDT::getlasterror().getErrorCode() << ' ' << UDT::getlasterror().getErrorMessage() << std::endl; 167 | 168 | std::cout << "ok\n"; 169 | } 170 | 171 | void UDTServer::WorkThread(const UDTSOCKET& sock) 172 | { 173 | std::string msg_buf_need_send; 174 | while (true) 175 | { 176 | // recv msg 177 | TryRecvMsg(sock, msg_buf_need_send); 178 | 179 | // send msg. 180 | if (msg_buf_need_send.size() > 0) 181 | TrySendMsg(sock, msg_buf_need_send); 182 | 183 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 184 | } 185 | 186 | 187 | } 188 | 189 | void UDTServer::TryRecvMsg(const UDTSOCKET& sock, std::string& msg_buf_need_send) 190 | { 191 | do 192 | { 193 | const std::string recved_msg = DoRecvMsg(sock); 194 | if (recved_msg.size() > 0) 195 | msg_buf_need_send += recved_msg; 196 | else 197 | break; 198 | } while (true); 199 | } 200 | 201 | void UDTServer::TrySendMsg(const UDTSOCKET& sock, std::string& msg_buf_need_send) 202 | { 203 | if (!msg_buf_need_send.empty()) 204 | { 205 | const int send_ret = DoSendMsg(sock, msg_buf_need_send); 206 | if (send_ret > 0) 207 | msg_buf_need_send.erase(0, send_ret); 208 | } 209 | } 210 | 211 | // return the actual size of data that has been sent 212 | int UDTServer::DoSendMsg(const UDTSOCKET& sock, const std::string& msg) 213 | { 214 | //std::cout << "UDT client DoSendMsg: " << msg << std::endl; 215 | 216 | int send_ret = UDT::send(sock, msg.c_str(), msg.size(), 0); 217 | if (UDT::ERROR == send_ret) 218 | { 219 | CUDTException& lasterror = UDT::getlasterror(); 220 | const int error_code = lasterror.getErrorCode(); 221 | if (error_code == CUDTException::EASYNCSND) 222 | { 223 | std::cerr << "N"; std::cerr.flush(); 224 | return 0; 225 | } 226 | 227 | std::cout << "UDT sendmsg: " << error_code << ' ' << lasterror.getErrorMessage() << std::endl; 228 | return 0; 229 | } 230 | if (static_cast(send_ret) != msg.size()) 231 | { 232 | std::cout << "UDT sendmsg: not all msg send!" << std::endl; 233 | return 0; 234 | } 235 | return send_ret; 236 | } 237 | 238 | std::string UDTServer::DoRecvMsg(const UDTSOCKET& sock) 239 | { 240 | int recv_ret = 0; 241 | char recv_buf[1024 * 100]; 242 | 243 | if (UDT::ERROR == (recv_ret = UDT::recv(sock, recv_buf, sizeof(recv_buf), 0))) 244 | { 245 | CUDTException& lasterror = UDT::getlasterror(); 246 | const int error_code = lasterror.getErrorCode(); 247 | 248 | if (error_code == CUDTException::EASYNCRCV) // no data available for read. 249 | { 250 | return ""; 251 | } 252 | 253 | std::cout << "UDT recv: " << error_code << " " << lasterror.getErrorMessage() << std::endl; 254 | if (CUDTException::EINVPARAM == error_code || CUDTException::ECONNLOST == error_code || CUDTException::EINVSOCK == error_code) { 255 | } 256 | return ""; 257 | } 258 | 259 | if (recv_ret > 0) 260 | { 261 | std::string recved_str(recv_buf, recv_ret); 262 | return recved_str; 263 | } 264 | 265 | std::cout << "UDT recv msg with zero len" << std::endl; 266 | return ""; 267 | } 268 | 269 | 270 | -------------------------------------------------------------------------------- /udt_bench_mark/udt_stream_server/udt_server.h: -------------------------------------------------------------------------------- 1 | #ifndef __UDT_SERVER_H_ 2 | #define __UDT_SERVER_H_ 3 | 4 | #include 5 | #include 6 | 7 | typedef int UDTSOCKET; 8 | 9 | class UDTServer : public std::enable_shared_from_this 10 | { 11 | public: 12 | UDTServer(void); 13 | void Run(int listen_port); 14 | 15 | private: 16 | int CreateListenSocket(int port); 17 | void WorkThread(const UDTSOCKET& sock); 18 | 19 | void TryRecvMsg(const UDTSOCKET& sock, std::string& msg_queue_need_send); 20 | void TrySendMsg(const UDTSOCKET& sock, std::string& msg_queue_need_send); 21 | std::string DoRecvMsg(const UDTSOCKET& sock); 22 | 23 | // return the actual size of data that has been sent 24 | int DoSendMsg(const UDTSOCKET& sock, const std::string& msg); 25 | 26 | private: 27 | UDTSOCKET listen_sock_; 28 | }; 29 | 30 | #endif 31 | --------------------------------------------------------------------------------