├── src ├── version ├── version.sh ├── udr_util.h ├── Makefile ├── udr_threads.h ├── udr_options.h ├── udr_log.cpp ├── cc.h └── udr_util.cpp ├── tests ├── fixtures │ └── fixture1.txt ├── requirements.txt ├── test_simple.py └── conftest.py ├── udt ├── doc │ ├── main.htm │ ├── hlp │ │ ├── ix_end.gif │ │ ├── ix_up.gif │ │ ├── ix_book.gif │ │ ├── ix_down.gif │ │ ├── ix_endm.gif │ │ ├── ix_endp.gif │ │ ├── ix_leaf.gif │ │ ├── ix_line.gif │ │ ├── ix_link.gif │ │ ├── ix_list.gif │ │ ├── ix_listm.gif │ │ ├── ix_listp.gif │ │ ├── ix_open.gif │ │ └── ix_space.gif │ ├── doc │ │ ├── treeview.css │ │ ├── header.htm │ │ ├── footer.htm │ │ ├── reference.htm │ │ ├── udtdoc.css │ │ ├── startup.htm │ │ ├── tutorial.htm │ │ ├── error.htm │ │ ├── cleanup.htm │ │ ├── intro.htm │ │ ├── t-udt3.htm │ │ ├── t-file.htm │ │ ├── copy.htm │ │ ├── t-msg.htm │ │ ├── socket.htm │ │ ├── close.htm │ │ ├── trace.htm │ │ ├── listen.htm │ │ ├── peername.htm │ │ ├── t-data.htm │ │ ├── t-firewall.htm │ │ ├── t-intro.htm │ │ ├── make.htm │ │ ├── t-error.htm │ │ ├── recvfile.htm │ │ ├── accept.htm │ │ ├── sendfile.htm │ │ ├── recv.htm │ │ ├── recvmsg.htm │ │ ├── send.htm │ │ ├── function.htm │ │ ├── sockname.htm │ │ ├── selectex.htm │ │ ├── t-hello.htm │ │ ├── connect.htm │ │ ├── t-cc.htm │ │ ├── bind.htm │ │ └── select.htm │ └── index.htm ├── tuner │ ├── settings.txt │ ├── tune.sh │ ├── Makefile │ ├── README.md │ ├── cc.h │ ├── recvfile.cpp │ └── appserver.cpp ├── Makefile ├── ssl │ ├── Makefile │ ├── tls_common.h │ └── epoll.cpp ├── app │ ├── udcat_common.h │ ├── Makefile │ ├── cc.h │ ├── udcat_common.cpp │ ├── recvfile.cpp │ ├── udcat_client.cpp │ ├── appserver.cpp │ └── udcat_server.cpp ├── RELEASE_NOTES.txt ├── src │ ├── Makefile │ ├── md5.h │ └── cache.cpp ├── README.txt ├── LICENSE.txt └── win │ ├── udt.sln │ ├── recvfile.vcproj │ ├── sendfile.vcproj │ ├── test.vcproj │ ├── appclient.vcproj │ └── appserver.vcproj ├── Makefile ├── server ├── udrd.conf.example └── daemon.py ├── .travis.yml ├── LICENSE.txt ├── .gitignore └── .travis └── setup_ssh.sh /src/version: -------------------------------------------------------------------------------- 1 | v0.9.4-11-g7885528 2 | -------------------------------------------------------------------------------- /tests/fixtures/fixture1.txt: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /tests/requirements.txt: -------------------------------------------------------------------------------- 1 | pytest==2.9.1 2 | -------------------------------------------------------------------------------- /udt/doc/main.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/main.htm -------------------------------------------------------------------------------- /udt/doc/hlp/ix_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_end.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_up.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_up.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_book.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_book.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_down.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_down.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_endm.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_endm.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_endp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_endp.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_leaf.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_leaf.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_line.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_link.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_link.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_list.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_list.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_listm.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_listm.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_listp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_listp.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_open.gif -------------------------------------------------------------------------------- /udt/doc/hlp/ix_space.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinetd/UDR/HEAD/udt/doc/hlp/ix_space.gif -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DIRS = udt src 2 | TARGETS = all clean 3 | 4 | $(TARGETS): %: $(patsubst %, %.%, $(DIRS)) 5 | 6 | $(foreach TGT, $(TARGETS), $(patsubst %, %.$(TGT), $(DIRS))): 7 | $(MAKE) -C $(subst ., , $@) -------------------------------------------------------------------------------- /udt/tuner/settings.txt: -------------------------------------------------------------------------------- 1 | /etc/sysctl.conf,/etc/sysctl.conf,0 134217728 2097152 8900,0 134217728 2097152 8900 0 2 | /etc/sysctl.conf,/etc/sysctl.conf,1 134217728 2097152 8900,1 134217728 2097152 8900 10000 3 | -------------------------------------------------------------------------------- /udt/Makefile: -------------------------------------------------------------------------------- 1 | DIRS = src app 2 | TARGETS = all clean install 3 | 4 | $(TARGETS): %: $(patsubst %, %.%, $(DIRS)) 5 | 6 | $(foreach TGT, $(TARGETS), $(patsubst %, %.$(TGT), $(DIRS))): 7 | $(MAKE) -C $(subst ., , $@) 8 | -------------------------------------------------------------------------------- /udt/doc/doc/treeview.css: -------------------------------------------------------------------------------- 1 | /* jSh - Stylesheet for JavaScript TreeView documentation */ 2 | 3 | pre { margin-left:10px; } 4 | h1,h2,h3,h4,h5,h6,pre,tt { color:#0000CC; } 5 | a.an { text-decoration:none; } 6 | a:active { color:#CC0000; text-decoration:none; } 7 | a:link { color:#CC0000; text-decoration:underline; } 8 | a:visited { color:#990066; text-decoration:underline; } 9 | -------------------------------------------------------------------------------- /src/version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -d ../.git ]; then git describe --tags --long > version ; fi; 3 | 4 | version=`cat version` 5 | 6 | printf "#ifndef VERSION_H\n#define VERSION_H\n" > version.h 7 | #printf "extern const char * version = \"%s" "$version" >> version.h 8 | printf "static const char * version = \"%s" "$version" >> version.h 9 | printf "\";\n#endif" >> version.h 10 | -------------------------------------------------------------------------------- /udt/doc/doc/header.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |This section describes in detail the UDT API, including:
12 | 13 |20 | 21 | 22 | -------------------------------------------------------------------------------- /udt/app/udcat_common.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2013 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of . 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | // this should be maxline size 20 | #define BUF_SIZE 100000 21 | 22 | void* recvdata(void*); 23 | 24 | void* senddata(void*); 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # The UDR binary and other files 16 | src/udr 17 | src/version.h 18 | *.udr_key 19 | udt/app/appclient 20 | udt/app/appserver 21 | udt/app/recvfile 22 | udt/app/sendfile 23 | udt/app/test 24 | udt/src/udt 25 | udt/app/udcat_client 26 | udt/app/udcat_server 27 | 28 | #server 29 | *.pyc 30 | server/rsyncd.conf 31 | server/udrd.conf 32 | server/udr.log 33 | server/motd.txt 34 | server/rsynclog 35 | server/.venv 36 | server/.venv2.4 37 | server/.venv2.6 38 | 39 | # Emacs files 40 | *~ 41 | 42 | # Vim files 43 | *.swp 44 | 45 | # Python 46 | *.cache 47 | __pycache__/ 48 | *.py[cod] 49 | .Python 50 | env/ 51 | venv/ 52 | .venv/ 53 | build/ 54 | develop-eggs/ 55 | dist/ 56 | downloads/ 57 | eggs/ 58 | lib/ 59 | lib64/ 60 | parts/ 61 | sdist/ 62 | var/ 63 | *.egg-info/ 64 | .installed.cfg 65 | *.egg 66 | 67 | # Misc 68 | *.log 69 | -------------------------------------------------------------------------------- /udt/tuner/tune.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # example: 3 | # ./tune.sh 127.0.0.1 lacadmin /home/lacadmin/udr_crypto/udt/tuner/appserver /home/lacadmin/udr_crypto/udt/src 4 | 5 | port=9000 6 | 7 | host=$1 8 | remote_user=$2 9 | server_command=$3 10 | remote_udt_path=$4 11 | 12 | count=0 13 | interval=60 14 | 15 | settings_file=settings.txt 16 | client=./appclient 17 | export_ld="export LD_LIBRARY_PATH=$remote_udt_path" 18 | 19 | while read line; do 20 | 21 | server_sysctl=$(echo $line|cut -f1 -d ,) 22 | client_sysctl=$(echo $line|cut -f2 -d ,) 23 | server_args=$(echo $line|cut -f3 -d ,) 24 | client_args=$(echo $line|cut -f4 -d ,) 25 | 26 | sudo sysctl -p $client_sysctl 27 | ssh $remote_user@$host "sudo sysctl -p $server_sysctl" <&- 28 | 29 | ssh $remote_user@$host "$export_ld; $server_command $port $server_args & pid=\$!;sleep $interval;kill \$pid" <&- & 30 | 31 | $client $host $port $client_args > raw_out_test$count & 32 | client_pid=$! 33 | 34 | sleep $interval 35 | kill $client_pid 36 | 37 | count=$((count+1)) 38 | done < $settings_file 39 | -------------------------------------------------------------------------------- /src/udr_util.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2012 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of UDR. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | #ifndef UDR_PROCESSES_H 20 | #define UDR_PROCESSES_H 21 | 22 | pid_t fork_execvp(const char *program, char* argv[], int * ptc, int * ctp); 23 | int get_server_connection(char * host, char * port, char * udr_cmd, char * line, int line_size); 24 | 25 | #endif -------------------------------------------------------------------------------- /udt/RELEASE_NOTES.txt: -------------------------------------------------------------------------------- 1 | version 4.10 2 | 3 | added UDT_SNDDATA and UDT_RCVDATA options 4 | fixed a bug that causes unnecessary connection timeout 5 | improved epoll UDT event handling 6 | 7 | version 4.9 8 | 9 | asynchronous close 10 | asynchronous connect 11 | some bug fixes, especially on EPOLL 12 | improved cache code 13 | removed unnecessary NAK (reduced loss retransmission) 14 | receiver side error can unblock a blocked sender 15 | 16 | version 4.8 17 | 18 | fix a bug that may cause seg fault on concurrent close on the same socket 19 | add epoll support 20 | increase the listener's scalability to 100K concurrent connections 21 | fix a bug that may cause accept/select to return positively when an accepted socket is closed immediately after accept returns 22 | fix a bug that may cause connect to fail if the server closes listening socket immediately after accept returns 23 | fix recvfile fstream write status bug (e.g., when disk is full, recvfile should handle properly now) 24 | 25 | version 4.7a 26 | 27 | fix timeout bug introduced in 4.7 28 | initialize CHandShake 29 | 30 | version 4.7 31 | 32 | Fix several related bugs that can cause hang/memory leak/segmentation fault during cleanup() 33 | -------------------------------------------------------------------------------- /udt/src/Makefile: -------------------------------------------------------------------------------- 1 | C++ = g++ -g 2 | 3 | ifndef os 4 | os = LINUX 5 | endif 6 | 7 | ifndef arch 8 | arch = AMD64 9 | endif 10 | 11 | CCFLAGS = -fPIC -Wall -Wextra -D$(os) -finline-functions -O3 -fno-strict-aliasing #-msse3 12 | 13 | ifeq ($(arch), IA32) 14 | CCFLAGS += -DIA32 15 | endif 16 | 17 | ifeq ($(arch), POWERPC) 18 | CCFLAGS += -mcpu=powerpc 19 | endif 20 | 21 | ifeq ($(arch), SPARC) 22 | CCFLAGS += -DSPARC 23 | endif 24 | 25 | ifeq ($(arch), IA64) 26 | CCFLAGS += -DIA64 27 | endif 28 | 29 | ifeq ($(arch), AMD64) 30 | CCFLAGS += -DAMD64 31 | endif 32 | 33 | OBJS = md5.o common.o window.o list.o buffer.o packet.o channel.o queue.o ccc.o cache.o core.o epoll.o api.o 34 | DIR = $(shell pwd) 35 | 36 | all: libudt.so libudt.a udt 37 | 38 | %.o: %.cpp %.h udt.h 39 | $(C++) $(CCFLAGS) $< -c 40 | 41 | libudt.so: $(OBJS) 42 | ifneq ($(os), OSX) 43 | $(C++) -shared -o $@ $^ 44 | else 45 | $(C++) -dynamiclib -o libudt.dylib -lstdc++ -lpthread -lm $^ 46 | endif 47 | 48 | libudt.a: $(OBJS) 49 | ar -rcs $@ $^ 50 | 51 | udt: 52 | cp udt.h udt 53 | 54 | clean: 55 | rm -f *.o *.so *.dylib *.a udt 56 | 57 | install: 58 | export LD_LIBRARY_PATH=$(DIR):$$LD_LIBRARY_PATH 59 | -------------------------------------------------------------------------------- /udt/tuner/Makefile: -------------------------------------------------------------------------------- 1 | C++ = g++ 2 | 3 | ifndef os 4 | os = LINUX 5 | endif 6 | 7 | ifndef arch 8 | arch = AMD64 9 | endif 10 | 11 | CCFLAGS = -Wall -D$(os) -I../src -finline-functions -O3 12 | 13 | ifeq ($(arch), IA32) 14 | CCFLAGS += -DIA32 #-mcpu=pentiumpro -march=pentiumpro -mmmx -msse 15 | endif 16 | 17 | ifeq ($(arch), POWERPC) 18 | CCFLAGS += -mcpu=powerpc 19 | endif 20 | 21 | ifeq ($(arch), IA64) 22 | CCFLAGS += -DIA64 23 | endif 24 | 25 | ifeq ($(arch), SPARC) 26 | CCFLAGS += -DSPARC 27 | endif 28 | 29 | LDFLAGS = -L../src -ludt -lstdc++ -lpthread -lm 30 | 31 | ifeq ($(os), UNIX) 32 | LDFLAGS += -lsocket 33 | endif 34 | 35 | ifeq ($(os), SUNOS) 36 | LDFLAGS += -lrt -lsocket 37 | endif 38 | 39 | DIR = $(shell pwd) 40 | 41 | APP = appserver appclient sendfile recvfile 42 | 43 | all: $(APP) 44 | 45 | %.o: %.cpp 46 | $(C++) $(CCFLAGS) $< -c 47 | 48 | appserver: appserver.o 49 | $(C++) $^ -o $@ $(LDFLAGS) 50 | appclient: appclient.o 51 | $(C++) $^ -o $@ $(LDFLAGS) 52 | sendfile: sendfile.o 53 | $(C++) $^ -o $@ $(LDFLAGS) 54 | recvfile: recvfile.o 55 | $(C++) $^ -o $@ $(LDFLAGS) 56 | 57 | clean: 58 | rm -f *.o $(APP) 59 | 60 | install: 61 | export PATH=$(DIR):$$PATH 62 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | C++ = g++ 2 | 3 | ifndef os 4 | os = LINUX 5 | endif 6 | 7 | ifndef arch 8 | arch = AMD64 9 | endif 10 | 11 | CCFLAGS = -Wall -D$(os) -I../udt/src -finline-functions -g 12 | 13 | ifeq ($(arch), IA32) 14 | CCFLAGS += -DIA32 #-mcpu=pentiumpro -march=pentiumpro -mmmx -msse 15 | endif 16 | 17 | ifeq ($(arch), POWERPC) 18 | CCFLAGS += -mcpu=powerpc 19 | endif 20 | 21 | ifeq ($(arch), IA64) 22 | CCFLAGS += -DIA64 23 | endif 24 | 25 | ifeq ($(arch), SPARC) 26 | CCFLAGS += -DSPARC 27 | endif 28 | 29 | LDFLAGS = -L../src ../udt/src/libudt.a -lstdc++ -lpthread -lm -lssl -lcrypto 30 | 31 | ifeq ($(os), UNIX) 32 | LDFLAGS += -lsocket 33 | endif 34 | 35 | ifeq ($(os), OSX) 36 | LDFLAGS += -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib 37 | CCFLAGS += -I/usr/local/opt/openssl/include 38 | endif 39 | 40 | ifeq ($(os), SUNOS) 41 | LDFLAGS += -lrt -lsocket 42 | endif 43 | 44 | DIR = $(shell pwd) 45 | 46 | APP = version.h udr 47 | 48 | all: $(APP) 49 | 50 | version.h: 51 | ./version.sh 52 | 53 | %.o: %.cpp 54 | $(C++) $(CCFLAGS) $< -c 55 | 56 | udr: udr.o udr_threads.o udr_util.o udr_options.o 57 | $(C++) $^ -o $@ $(LDFLAGS) 58 | 59 | clean: 60 | rm -f *.o $(APP) 61 | 62 | install: 63 | export PATH=$(DIR):$$PATH 64 | -------------------------------------------------------------------------------- /udt/doc/doc/udtdoc.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | background-color: #FFFFFF; 5 | font-family: Verdana, Arial, Helvetica, sans-serif; 6 | font-size: 12px; 7 | line-height: 18px; 8 | color: #333333; 9 | } 10 | 11 | .note1 { 12 | font-family: Verdana, Arial, Helvetica, sans-serif; 13 | font-size: 12px; 14 | font-style: normal; 15 | line-height: normal; 16 | color: #333333; 17 | padding: 0px 0px 10px 10px; 18 | margin-top: 0; 19 | margin-bottom: 0; 20 | list-style-image: none; 21 | } 22 | 23 | .ref_head { 24 | font-family: Verdana, Arial, Helvetica, sans-serif; 25 | font-size: 12px; 26 | font-style: italic; 27 | font-weight: bold; 28 | background-color: #99CCFF; 29 | padding: 3px 3px 3px 3px; 30 | } 31 | 32 | .code { 33 | font-family: "Courier New", Courier, monospace; 34 | font-size: 10px; 35 | line-height: 12px; 36 | background-color: #C0C0C0; 37 | padding: 5px 5px 5px 5px; 38 | } 39 | 40 | .func_name { 41 | font-family: Verdana, Arial, Helvetica, sans-serif; 42 | font-size: 18px; 43 | color: #000000; 44 | } 45 | 46 | .table_headline { 47 | font-family: Verdana, Arial, Helvetica, sans-serif; 48 | font-size: 12px; 49 | background-color: #C0C0C0; 50 | padding: 2px 2px 2px 2px; 51 | } 52 | -------------------------------------------------------------------------------- /udt/ssl/tls_common.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2013 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of . 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | #ifndef TLS_COMMON_H 20 | #define TLS_COMMON_H 21 | 22 | #include
The startup method initializes the UDT library.
14 | 15 |If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror.
25 |In the current version, this method always succeed.
26 |The startup method initializes the UDT library. In particular, it starts the garbage collection thread. This method must be called before any other UDT calls. Failure to do so may cause memory leak.
28 |If startup is called multiple times in one application, only the first one is effective, while the rest will do nothing.
29 |32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /udt/doc/doc/tutorial.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
This tutorial is a quick guide on how to program with UDT and includes explanations and examples. You can learn the basics of UDT programming in this tutorial. This tutorial supposes that 12 | you are familiar with socket programming. The example codes can be found in the ./app directory of the software release, which can be compiled and run directly.
13 | 14 | In this section: 15 | 16 |30 | 31 | 32 | -------------------------------------------------------------------------------- /udt/doc/doc/error.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The getlasterror method the last UDT error within the same thread.
14 | 15 |The last UDT error within the same thread is retrieved and returned in an ERRORINFO structure. If there is no error, a special SUCCESS code (0) will be 25 | returned. The getlasterror will always succeed. The returned value is a reference to the internal UDT ERRORINFO structure and application may clear it if necessary.
26 | 27 |The getlasterror method reads the last UDT error in the thread where this method is called. The error information is stored in thread specific storage.
29 | 30 |Error Code List, Error Handling
32 |33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /udt/doc/doc/cleanup.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The cleanup method releases the UDT library from your application.
14 | 15 |If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror.
25 |In the current version, this method always succeed.
26 |The cleanup method releases the UDT library. All the remaining open connections will be closed. The background garbage collection is closed. However, this method will do nothing if no startup was ever called, or this is a repeated cleanup call.
28 |The method must be called before the application exits, or before the UDT DLL is released, otherwise memory leak could happen.
29 |32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /udt/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above 9 | copyright notice, this list of conditions and the 10 | following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the 13 | above copyright notice, this list of conditions 14 | and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the University of Illinois 18 | nor the names of its contributors may be used to 19 | endorse or promote products derived from this 20 | software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 23 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /src/udr_threads.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2012 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of UDR. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | #ifndef UDR_THREADS_H 20 | #define UDR_THREADS_H 21 | 22 | #include "crypto.h" 23 | #include "udr_options.h" 24 | 25 | const int max_block_size = 64*1024; //what should this be? maybe based on UDT buffer size? 26 | 27 | typedef struct timeout_mon_args{ 28 | FILE * logfile; 29 | int timeout; 30 | } timeout_mon_args; 31 | 32 | 33 | struct thread_data{ 34 | UDTSOCKET * udt_socket; 35 | int fd; 36 | int id; 37 | crypto * crypt; 38 | bool log; 39 | string logfile_dir; 40 | bool is_complete; 41 | }; 42 | 43 | void *handle_to_udt(void *threadarg); 44 | void *udt_to_handle(void *threadarg); 45 | 46 | int run_sender(UDR_Options * udr_options, unsigned char * passphrase, const char* cmd, int argc, char ** argv); 47 | int run_receiver(UDR_Options * udr_options); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /udt/tuner/README.md: -------------------------------------------------------------------------------- 1 | UDT Tuner 2 | === 3 | 4 | This is a modification of udt/app/app(client/server) that takes cli args 5 | along with a bash script that will run the client server pair with UDT and 6 | sysctl settings. 7 | 8 | USAGE 9 | ------ 10 | Running the bash script tune.sh will read settings from the file settings.txt then as specified by cli args ssh to a remote host load a sysctl file and start the appserver with parameters from the local settings.txt. Then tune.sh loads a local sysctl file and starts the appclient. Both the server and client run for 1 minute and are then killed. The output of appclient is writting to raw_out_testN where N is the line of settings.txt being run starting from 0. 11 | 12 | ### Basic usage: 13 | ./tune.sh 127.0.0.1 lacadmin /home/lacadmin/udr_crypto/udt/tuner/appserver /home/lacadmin/udr_crypto/udt/src 14 | 15 | tune.sh will ssh to 127.0.0.1 as lacadmin then export LD_LIBRARY_PATH=/home/lacadmin/udr_crypto/udt/src then start /home/lacadmin/udr_crypto/udt/tuner/appserver 16 | 17 | ### Example settings.txt: 18 | /etc/sysctl.conf,/etc/sysctl.conf,0 134217728 2097152 8900,0 134217728 2097152 8900 0 19 | /etc/sysctl.conf,/etc/sysctl.conf,1 134217728 2097152 8900,1 134217728 2097152 8900 10000 20 | 21 | On the remote server run: 22 | sudo sysctl -p /etc/sysctl.conf 23 | Then locally run: 24 | sudo sysctl -p /etc/sysctl.conf 25 | Then remotely run: 26 | PATH_FROM_ARGS/appserver 9000 0 134217728 2097152 8900 27 | Then locally: 28 | ./appclient HOST_FROM_ARGS 9000 0 134217728 2097152 8900 0 29 | 30 | 0 means no blast congestion control. 134217728 is the UDT buffer size, 2097152 is the UDP buffer size, 8900 is the UDT MSS, and 0 is the blast rate. 31 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | conftest.py 4 | ---------------------------------- 5 | 6 | Setup for UDR pytest test suite 7 | """ 8 | 9 | from subprocess import Popen, PIPE 10 | from os.path import dirname, realpath, join 11 | from os import environ 12 | 13 | import pytest 14 | 15 | 16 | def raise_for_error(proc): 17 | """Raises a RuntimeError if :param:`proc` did not exit successfully""" 18 | 19 | proc.poll() 20 | if proc.returncode != 0: 21 | raise RuntimeError(proc.stderr.read()) 22 | 23 | 24 | @pytest.fixture(scope='session') 25 | def ssh_port(): 26 | return environ.get('UDT_SSH_PORT', '10022') 27 | 28 | 29 | @pytest.fixture(scope='session') 30 | def src_dir(): 31 | return join(dirname(dirname(realpath(__file__))), 'src') 32 | 33 | 34 | @pytest.fixture(scope='session') 35 | def udr_path(): 36 | return join(src_dir(), 'udr') 37 | 38 | 39 | @pytest.fixture(scope='session') 40 | def fixture_dir(): 41 | return join(dirname(dirname(realpath(__file__))), 'tests', 'fixtures') 42 | 43 | 44 | @pytest.fixture(scope='session') 45 | def default_args(udr_path, ssh_port): 46 | return [ 47 | '-v', 48 | '-c'+udr_path, 49 | '-P'+ssh_port, 50 | 'rsync', 51 | ] 52 | 53 | @pytest.yield_fixture 54 | def udr(udr_path, src_dir): 55 | """Returns a Popen partial function to run UDR""" 56 | 57 | # Return a partial to start the process (savinging it in closure 58 | # bound _process to clean up later) 59 | processes = [] 60 | def start_udr(args=[]): 61 | """Starts udr with arguments :param:`args`""" 62 | print(f'Running with args {args}') 63 | process = Popen([udr_path]+list(args), stdout=PIPE, stderr=PIPE) 64 | processes.append(process) 65 | return processes[-1] 66 | 67 | yield start_udr 68 | 69 | for process in processes: 70 | process.wait() 71 | -------------------------------------------------------------------------------- /udt/doc/doc/intro.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
Welcome to the UDT4 SDK documentation.
14 |UDT is a high performance data transfer protocol - UDP-based data transfer protocol. It was designed for 15 | data intensive applications over high speed wide area networks, to overcome the efficiency and fairness problems of TCP. 16 | As its name indicates, UDT is built on top of UDP and it provides both reliable data streaming and messaging services.
17 |Visit http://udt.sf.net for most recent news on UDT.
18 | 19 |Check out most current UDT release at SourceForge or from CVS.
20 | 21 |export CVS_RSH=ssh
22 | cvs -d:pserver:anonymous@udt.cvs.sourceforge.net:/cvsroot/udt login
23 | [NOTE: when prompt for password, press the RETURN/ENTER key]
24 | cvs -d:pserver:anonymous@udt.cvs.sourceforge.net:/cvsroot/udt co UDT4
In this documentation:
27 |35 | 36 | 37 | -------------------------------------------------------------------------------- /udt/doc/doc/t-udt3.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
If you have never used UDT before, please skip this page.
14 | 15 |If you are familiar with previous versions of UDT, in particular UDT3, please noted that we have several major changes in UDT4 and you may need to modify your existing code a little 16 | in order to use UDT4. In addition, different versions of UDT do not communicate with each other.
17 | 18 |UDT4 have made the following improvements
19 |Finally, UDT4 does not provide the NS-2 simulation code (nor any support to previous versions of simulation code) any more.
31 | 32 |33 | 34 | 35 | -------------------------------------------------------------------------------- /udt/ssl/epoll.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2013 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of . 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | struct udt_epoll_args { 20 | int efd; 21 | int signal_fd; 22 | }; 23 | 24 | 25 | void *epoll_signal_thread(void *my_args) 26 | { 27 | struct udt_epoll_args *args = (struct udt_epoll_args*)my_args; 28 | std::set
While you can always use regular UDT::send and UDT::recv to transfer a file, UDT provides a more convinient and optimized way for file transfer. An application can use UDT::sendfile 14 | and UDT::recvfile directly. In addition, file transfer IO API and regular data IO API are orthogonal. E.g., the data stream sent out by UDT::sendfile does not necessarily require 15 | UDT::recvfile to accept.
16 | 17 |The sendfile and recvfile methods are blocking call and are not affected by UDT_SNDSYN, UDT_RCVSYN, UDT_SBDTIMEO, or UDT_RCVTIMEO. They always complete the call with the specified 18 | size parameter for sending or receiving unless errors occur.
19 | 20 |UDT uses C++ fstream for file IO.
21 | 22 |Example: send a file using UDT.
23 |Example: Receive data into a file.
40 |54 | 55 | 56 | -------------------------------------------------------------------------------- /udt/doc/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois.
13 | All rights reserved.
Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are 16 | met:
17 |THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 |
When a UDT socket is created as SOCK_DGRAM type, UDT will send and receive data as messages. The boundary of the message is preserved and the message is delivered 14 | as a whole unit. Sending or receving messages do not need a loop; a message will be either completely delivered or not delivered at all. However, at the receiver 15 | side, if the user buffer is shorter than the message length, only part of the message will be copied into the user buffer while the message will still be 16 | discarded.
17 | 18 |Example: send and receive messages using UDT.
19 |At the sender side, applications can specify two options for every message. The first is the life time (TTL) of a message. The default value is infinite, which 31 | means that the message will always be delivered. If the value is a postive one, UDT will discard the message if it cannot be delivered by the life time expires. 32 | The second is the order of the message. An in-order message means that this message will not be delivered unless all the messages prior to it are either delivered 33 | or discarded.
34 | 35 |Synchronization modes (blocking vs. non-blocking) are also applied to SOCK_DGRAM sockets, so does not other UDT mechanisms including but limited to congestion 36 | control, flow control, and connection maintainence. Finally, note that UDT SOCK_DGRAM socket is also connection oriented. A UDT connection can only be set up 37 | between the same socket types.
38 | 39 |40 | 41 | 42 | -------------------------------------------------------------------------------- /src/udr_options.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2012 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of UDR. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | #ifndef UDR_OPTIONS_H 20 | #define UDR_OPTIONS_H 21 | #include
The socket method creates a new UDT socket.
14 | 15 |If no error occurs, socket returns the new UDT socket descriptor; otherwise, it returns UDT::INVALID_SOCK and the error information can be retrieved by getlasterror.
34 | 35 || Error Name | 38 |Error Code | 39 |Comment | 40 |
| EINVPARAM | 43 |5003 | 44 |Invalid parameters. | 45 |
The socket methods creates a new socket. The is no limits for the number of UDT sockets in one system, as long as there is enough system 50 | resource. UDT supports both IPv4 and IPv6, which can be selected by the af parameter. On the other hand, two socket types are supports in UDT, i.e., 51 | SOCK_STREAM for data streaming and SOCK_DGRAM for messaging. Note that UDT sockets are connection oriented in all cases.
52 | 53 |57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /udt/app/udcat_common.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2013 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of . 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | #include
The close method closes a UDT connection.
14 | 15 |If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror.
27 | 28 || Error Name | 31 |Error Code | 32 |Comment | 33 |
| EINVSOCK | 36 |5004 | 37 |u is an invalid UDT socket. | 38 |
The close method gracefully shutdowns the UDT connection and releases all related data structures associated with the UDT socket. If there is no connection associated 43 | with the socket, close simply release the socket resources.
44 |On a blocking socket, if UDT_LINGER is non-zero, the close call will wait until all data in the sending buffer are sent out or the waiting time has exceeded the 45 | expiration time set by UDT_LINGER. However, if UDT_SYNSND is set to false (i.e., non-blocking sending), close will return immediately and any linger data will be sent at background until the linger timer expires.
46 |The closing UDT socket will send a shutdown message to the peer side so that the peer socket will also be closed. This is a best-effort message. If the message is not successfully 47 | delivered, the peer side will also be closed after a time-out. In UDT, shutdown is not supported.
48 |All sockets should be closed if they are not used any more.
49 | 50 |53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /udt/doc/doc/trace.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The perfmon method retrieves the internal protocol parameters and performance trace.
14 | 15 |If success, 0 is returned and trace information is written into trace; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror.
34 | 35 || Error Name | 38 |Error Code | 39 |Comment | 40 |
| ECONNLOST | 43 |2001 | 44 |connection is broken. | 45 |
| EINVSOCK | 48 |5004 | 49 |u is an invalid socket. | 50 |
| EUNBOUNDSOCK | 53 |5005 | 54 |u is not connected. | 55 |
The perfmon method reads the performance data since the last time perfmon is executed, or since the connection is started. The result in written into a TRACEINFO structure.
60 |There are three kinds of performance information that can be read by applications: the total counts since the connection is started, the periodical counts since last time the counts are cleared, and instant parameter values.
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /udt/doc/doc/listen.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |The listen method enables a server UDT entity to wait for clients to connect.
14 | 15 |If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror.
30 | 31 || Error Name | 34 |Error Code | 35 |Comment | 36 |
| ECONNSOCK | 39 |5002 | 40 |u is already connected. | 41 |
| EINVSOCK | 44 |5004 | 45 |u is an invalid socket. | 46 |
| EUNBOUNDSOCK | 49 |5005 | 50 |u is not bound. | 51 |
| ERDVNOSERV | 54 |5007 | 55 |u is in rendezvous mode. | 56 |
The listen method lets a UDT socket enter listening state. The socket must call bind before a listen call. In addition, if the 61 | socket is enable for rendezvous mode, neither listen nor accept can be used on the socket. A UDT socket can call listen more than once, 62 | in which case only the first call is effective, while all subsequent calls will be ignored if the socket is already in listening state.
63 | 64 |67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /udt/doc/doc/peername.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The getpeername method retrieves the address informtion of the peer side of a connected UDT socket.
14 | 15 |On success, getlasterror returns 0 and the peer address information is stored in name; otherwise it returns UDT::ERROR and the specific error information can be 33 | retrieved using getlasterror.
34 | 35 || Error Name | 38 |Error Code | 39 |Comment | 40 |
| ENOCONN | 43 |2002 | 44 |u is not connected. | 45 |
| EINVPARAM | 48 |5003 | 49 |Invalid parameters. | 50 |
| EINVSOCK | 53 |5004 | 54 |u is an invailid UDT socket. | 55 |
The getpeername retrieves the address of the peer side associated to the connection. The UDT socket must be connected at the time when this method is called. The 60 | namelen must provide the leangth of the name parameter, which should be enough to hold the address information. On return, namelen contains the length of the result.
61 | 62 |65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /udt/doc/doc/t-data.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
This section describes using UDT to transfer data in streaming mode. This is exactly the same as using traditional BSD socket.
14 | 15 |In streaming mode, neither a send or a recv call can guarantee that all data are sent or received in one call, because there is no boundary information in the data stream. Application 16 | should use loops for both sending and receiving.
17 | 18 |Example: send a data block (buf, size) using UDT.
19 |Similarily, to receive data stream, the following example code can be used.
35 |Example: receive "size" of data into buffer "buf"
36 |UDT supports both blocking and non-blocking mode. The above example demonstrated the blocking mode. In non-blocking mode, UDT::send and UDT::recv will return immediately if there is 53 | no buffer available. Usually, non-blocking calls are used together with accept.
54 |UDT also supports timed blocking IO with UDT_SNDTIMEO and UDT_RCVTIMEO. This is in the middle between complete blocking and complete non-blocking calls. Timed IO will block the 55 | sending or receiving call for a limited period. This is sometimes useful if the application does not know if and when the peer side will send a message.
56 | 57 |58 | 59 | 60 | -------------------------------------------------------------------------------- /udt/doc/doc/t-firewall.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
While UDT was originally written for extremely high speed data transfer, there are many other potential benefits from this reliable UDP-based library. One particular usage is to setup 14 | reliable connections between machines behind firewalls. To meet this requirement, UDT has added the rendezvous connection setup support.
15 | 16 |Traditional BSD socket setup process requires explicit server side and client side. To punch NAT firewalls, a common method is to use the SO_REUSEADDR socket option to open two sockets 17 | bound to the same port, one listens and the other connects. UDT provides the more convenient rendezvous connection setup, in which there is no server or client, and two users can connect to 18 | each other directly.
19 | 20 |With UDT, all sockets within one process can be bound to the same UDP port (but at most one listening socket on the same port is allowed). This is also helpful for system administrators to open a specific UDP port for all UDT traffic.
21 | 22 |Example: Rendezvous connection setup. (Note that there is no need to set UDT_REUSEADDR here because it is true by default.)
23 |In addition, UDT also allows to bind on an existing UDP socket. This is useful in two situations. First, sometimes the application must send packet to a name server in order to obtain its address (for example, this is true when behind an NAT firewall). Users may create a UDP socket and send some UDP packets to the name server to obtain the binding address. Then the UDP socket can be used directly for UDT (see bind) so that the application does not need to close the UDP socket and open a new UDT socket on the same address again.
34 |Second, some firewalls working on local system may change the port mapping or close the "hole" is the punching UDP socket is closed, thus a new UDT socket on the same address will not be able to traverse the firewall. In this situation, binding the UDT socket on the existing UDP socket is not only convenient but necessary.
35 |36 | 37 | 38 | -------------------------------------------------------------------------------- /udt/app/recvfile.cpp: -------------------------------------------------------------------------------- 1 | #ifndef WIN32 2 | #include
The prerequisite knowledge for using UDT is sound experience on C++ and socket programing. This is enough to use UDT in distributed applications. If you are familiar with computer 14 | networking, you may find UDT more powerful.
15 | 16 |UDT is a C++ library, which has almost identical routines as the BSD socket APIs. Using UDT in a C++ program is very straightforward. In fact, you may easily modify your existing code 17 | from TCP to UDT.
18 | 19 |Because of the similarity between UDT API and BSD socket API, UDT defines its own namespace UDT to differentiate the UDT APIs from the regular socket APIs. A qualifier of UDT:: should be 20 | put before the UDT socket call. UDTSOCKET is a data type to describe a UDT socket. For a complete UDT structures and constant definitions, please see Reference:UDT Structures. For a complete 21 | description of UDT socket APIs, please see Reference:UDT Functions.
22 | 23 |For those socket APIs that does not involve with a socket descriptor, e.g., inet_pton, they are not wrapped by UDT API, and the applications should continue to use the original functions. 24 | For those socket APIs or options not appropriate to UDT, e.g., certain TCP options, they are simply not available in UDT API.
25 | 26 |For example, using BSD socket, you write:
27 | 28 |Its counterpart in UDT is like this:
33 | 34 |UDT API is thread-safe. UDT sockets can be shared by multiple threads and UDT API on the same socket can be made concurrently. However, because of its application level nature, UDT 39 | sockets cannot be shared among processes. That is, a UDT socket created in one process cannot be used in another process.
40 | 41 |If you use a programming language other than C++, you may need to write certain wrapper for the UDT C++ API. For example, you may use "extern C" to wrap UDT API in C; there are also 42 | ways to call C++ API in Java.
43 | 44 |To use UDT in a C++ application:
45 | 46 |Header
47 |#include <udt.h>
48 | 49 |Library (depending on platforms)
50 |libudt.so
libudt.a
udt.dll
udt.lib
udt.dylib
Namespace
53 |UDT
54 | 55 |56 | 57 | 58 | -------------------------------------------------------------------------------- /src/cc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2012 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of UDR. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | #include
The UDT library is distributed with source code, example applications, and documentation. Currently the source code can be compiled on both Linux and Windows system.
18 | 19 |Here is the content of the distribution:
20 | 21 |./src: UDT source code
22 | ./app: Example applications
23 | ./doc: UDT documentation
24 | ./win: Visual C++ project files for Windows version of UDT
The library is in the original source code format without any installation tools, so installation is simply a make command. To make the C++ source code on different platform, the user 27 | needs to explicitly tell make the current operating system and hardware architecture with the "-e" option (except for Windows).
28 |The available operating system options are: LINUX, BSD, and OSX.
The available options for hardware architecture are: IA32, IA64, POWERPC, and AMD64.
The command is in the format:
31 | 32 |make -e os=XXX arch=YYY
33 | 34 |where XXX and YYY are one of the options above. Note that it is case sensitive. There is a default value for Linux on the IA32 architecture, so if UDT is compiled on it, simply use 35 | make. 36 |
37 | 38 | On Windows, use the Visual Studio .Net project files at ./win directory. It requires Visual C++ 7.0 or above to compile. Windows XP or above is also required under the default setting. 39 |If other Windows compilers are used, you may need to create 40 | your own Makefile or project files. In particular, if you use Visual C++ 6.0 or your system is Windows 2000 or certain embeded Windows systems, please define LEGACY_WIN32 in your Makefile or project files. You may also need to download Windows platform SDK in order to get the <wspiapi.h> header file.
41 |After a successful make, you can begin to use the UDT library. The (only) header file udt.h and the library libudt.a (depending on the target system, libudt.so, libudt.dylib, and udt.dll 42 | may be available) are located in ./src directory.
43 | Proper environment configuration should be set up before using UDT library. For example, if using libudt.so, the library path environment variable must be updated as: 44 | 45 | 46 | 47 | export LD_LIBRARY_PATH=[location of libudt.so, e.g., ../src]:$LD_LIBRARY_PATH 48 | 49 | 50 |On Windows, copy udt.dll to the proper directory.
51 |52 | 53 | 54 | -------------------------------------------------------------------------------- /udt/doc/doc/t-error.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
All UDT API will return an error upon a failed operation. Particularly, UDT defines UDT::INVALID_SOCK and UDT::ERROR as error returned values. Application should check the return 14 | value against these two constants (several routine return false as error value).
15 | 16 |On error, getlasterror can be used to retrieve the error information. In fact, the function returns the latest error occurred in the thread where the function is called. getlasterror returns an ERRORINFO structure, it contains both the error code and special text error message. Two helper functions of getErrorCode and getErrorMessage can be used to read these 17 | information.
18 |The UDT error information is thread local (that is, an error in another thread will not affect the error information in the current thread). The returned value is a reference to the UDT internal error structure.
19 |Note that a successful call will NOT clear the error. Therefore, applications should use the return value of a UDT API to check the result of a UDT call. getlasterror only provides detailed information when necessary. However, application can use getlasterror().clear() to clear the previously logged error if needed.
20 |Example: check UDT::bind error.
21 |In the example above, the output will be:
39 |The UDT error code only reflects the operation error of the UDT socket level. Applications can still read the system level error (e.g., errno in Linux, GetLastError in Windows) to read 44 | more specific error information. However, the error message obtained by getErrorMessage contains information of both the UDT level error and the system level error.
45 | 46 |47 | 48 | 49 | -------------------------------------------------------------------------------- /udt/doc/doc/recvfile.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The recvfile method reads certain amount of data into a local file.
14 | 15 |On success, recvfile returns the actual size of received data. Otherwise UDT::ERROR is returned and specific error information can be retrieved by getlasterror.
40 | 41 || Error Name | 44 |Error Code | 45 |Comment | 46 |
| ECONNLOST | 49 |2001 | 50 |connection has been broken and no data left in receiver buffer. | 51 |
| ENOCONN | 54 |2002 | 55 |u is not connected. | 56 |
| EFILE | 59 |4000 | 60 |File or disk system errors. | 61 |
| EINVSOCK | 64 |5004 | 65 |u is not an valid socket. | 66 |
| EDGRAMILL | 69 |5010 | 70 |cannot use recvfile in SOCK_DGRAM mode. | 71 |
The recvfile method reads certain amount of data and write it into a local file. It is always in blocking mode and neither UDT_RCVSYN nor UDT_RCVTIMEO affects this method. The actual size of data to expect must be known before calling recvfile, otherwise deadlock may occur due to insufficient incoming data.
76 |79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /udt/doc/doc/accept.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The accept method retrieves an incoming connection.
14 | 15 |If no error occurs, accept returns the UDT socket descriptor of the new connection; otherwise, it returns 33 | UDT::INVALID_SOCK.
34 |On a successful return, the address of the peer 35 | side of the connection is written into addr, and its length is in addrlen, if the addr parameter is not NULL.
36 |If an error is returned, the error information 37 | can be retrieved by getlasterror. One of the following error can cause an accept error:
38 | 39 || Error Name | 42 |Error Code | 43 |Comment | 44 |
| EINVSOCK | 47 |5004 | 48 |u is an invalid UDT socket. | 49 |
| ENOLISTEN | 52 |5006 | 53 |u is not in the listening state. | 54 |
| ERDVNOSERV | 57 |5007 | 58 |u is set up to support rendezvous connection. | 59 |
| EASYNCRCV | 62 |6002 | 63 |u is non-blocking (UDT_RCVSYN = false) but there is no connection available. | 64 |
Once a UDT socket is in listening state, it accepts new connections and maintains the pending connections in a queue. An accept call retrieves 69 | the first connection in the queue, removes it from the queue, and returns the associate socket descriptor.
70 |If there is no connections in the queue when accept is called, a blocking socket will wait until a new connection is set up, whereas a 71 | non-blocking socket will return immediately with an error.
72 |The accepted sockets will inherit all proper attributes from the listening socket.
73 | 74 |listen, connect, setsockopt, getsockopt
76 |77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /udt/tuner/recvfile.cpp: -------------------------------------------------------------------------------- 1 | #ifndef WIN32 2 | #include
The sendfile method sends out part or the whole of a local file.
14 | 15 |On success, sendfile returns the actual size of data that has been sent. Otherwise UDT::ERROR is returned and specific error information can be retrieved by 39 | getlasterror.
40 | 41 || Error Name | 44 |Error Code | 45 |Comment | 46 |
| ECONNLOST | 49 |2001 | 50 |connection has been broken. | 51 |
| ENOCONN | 54 |2002 | 55 |u is not connected. | 56 |
| EINVOP | 59 |4000 | 60 |File or disk system errors. | 61 |
| EINVSOCK | 64 |5004 | 65 |u is not an valid socket. | 66 |
| EDGRAMILL | 69 |5010 | 70 |cannot use sendfile in SOCK_DGRAM mode. | 71 |
| EPEERERR | 74 |7000 | 75 |The peer side has an unrecoverable error and this call has to be cancelled. | 76 |
The sendfile method sends certain amount of out of a local file. It is always in blocking mode an neither UDT_SNDSYN nor UDT_SNDTIMEO affects this method. However, the sendfile method has a streaming semantics same as send.
81 |Note that sendfile does NOT nessesarily require recvfile at the peer side. Sendfile/recvfile and send/recv are orthogonal 82 | UDT methods.
83 | 84 |87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /udt/src/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | 20 | L. Peter Deutsch 21 | ghost@aladdin.com 22 | 23 | */ 24 | /* $Id: md5.h,v 1.2 2007/12/24 05:58:37 lilyco Exp $ */ 25 | /* 26 | Independent implementation of MD5 (RFC 1321). 27 | 28 | This code implements the MD5 Algorithm defined in RFC 1321, whose 29 | text is available at 30 | http://www.ietf.org/rfc/rfc1321.txt 31 | The code is derived from the text of the RFC, including the test suite 32 | (section A.5) but excluding the rest of Appendix A. It does not include 33 | any code or documentation that is identified in the RFC as being 34 | copyrighted. 35 | 36 | The original and principal author of md5.h is L. Peter Deutsch 37 |
The recv method reads certain amount of data into a local memory buffer.
14 | 15 |On success, recv returns the actual size of received data. Otherwise UDT::ERROR is returned and specific error information can be retrieved by getlasterror. If UDT_RCVTIMEO is set to a positive value, zero will be returned if no data is received before the timer expires.
37 | 38 || Error Name | 41 |Error Code | 42 |Comment | 43 |
| ECONNLOST | 46 |2001 | 47 |connection has been broken and no data left in receiver buffer. | 48 |
| ENOCONN | 51 |2002 | 52 |u is not connected. | 53 |
| EINVSOCK | 56 |5004 | 57 |u is not an valid socket. | 58 |
| EDGRAMILL | 61 |5010 | 62 |cannot use recv in SOCK_DGRAM mode. | 63 |
| EASYNCRCV | 66 |6002 | 67 |u is non-blocking (UDT_RCVSYN = false) but no data is available. | 68 |
The recv method reads certain amount of data from the protocol buffer. If there is not enough data in the buffer, recv only reads the available data 73 | in the protocol buffer and returns the actual size of data received. However, recv will never read more data than the buffer size indicates by len.
74 |In blocking mode (default), recv waits until there is some data received into the receiver buffer. In non-blocking mode, recv returns immediately and 75 | returns error if no data available.
76 |If UDT_RCVTIMEO is set and the socket is in blocking mode, recv only waits a limited time specified by UDT_RCVTIMEO option. If there is still no data available when 77 | the timer expires, zero will be returned. UDT_RCVTIMEO has no effect for non-blocking socket.
78 | 79 |select, send, sendfile, recvfile
81 |82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /udt/doc/doc/recvmsg.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The recvmsg method receives a valid message.
14 | 15 |On success, recvmsg returns the actual size of received message. Otherwise UDT::ERROR is returned and specific error information can be retrieved by getlasterror. If UDT_RCVTIMEO is set to a positive value, zero will be returned if no message is received before the timer expires.
34 | 35 || Error Name | 38 |Error Code | 39 |Comment | 40 |
| ECONNLOST | 43 |2001 | 44 |connection has been broken and no data left in receiver buffer. | 45 |
| ENOCONN | 48 |2002 | 49 |u is not connected. | 50 |
| EINVSOCK | 53 |5004 | 54 |u is not an valid socket. | 55 |
| ESTREAMILL | 58 |5009 | 59 |cannot use recvmsg in SOCK_STREAM mode. | 60 |
| EASYNCRCV | 63 |6002 | 64 |u is non-blocking (UDT_RCVSYN = false) but no message is available. | 65 |
The recvmsg method reads a message from the protocol buffer. The UDT socket must be in SOCK_DGRAM mode in order to send or receive messages. Message is the minimum 70 | data unit in this situation. Each recvmsg will read no more than one message, even if the message is smaller than the size of buf and there 71 | are more messages available. On the other hand, if the buf is not enough to hold the first message, only part of the message will be copied into the buffer, 72 | but the message will still be discarded after this recvmsg call.
73 |In blocking mode (default), recvmsg waits until there is a valid message received into the receiver buffer. In non-blocking mode, 74 | recvmsg returns immediately and returns error if no message available.
75 |If UDT_RCVTIMEO is set and the socket is in blocking mode, recvmsg only waits a limited time specified by UDT_RCVTIMEO option. If there is still 76 | no message available when the timer expires, zero will be returned. UDT_RCVTIMEO has no effect for non-blocking socket.
77 | 78 |81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /udt/doc/doc/send.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The send method sends out certain amount of data from an application buffer.
14 | 15 |On success, send returns the actual size of data that has been sent. Otherwise UDT::ERROR is returned and specific error information can be retrieved by getlasterror. If UDT_SNDTIMEO is set to a positive value, zero will be returned if no data is sent before the timer expires.
37 | 38 || Error Name | 41 |Error Code | 42 |Comment | 43 |
| ECONNLOST | 46 |2001 | 47 |connection has been broken. | 48 |
| ENOCONN | 51 |2002 | 52 |u is not connected. | 53 |
| EINVSOCK | 56 |5004 | 57 |u is not an valid socket. | 58 |
| EDGRAMILL | 61 |5010 | 62 |cannot use send in SOCK_DGRAM mode. | 63 |
| EASYNCSND | 66 |6001 | 67 |u is non-blocking (UDT_SNDSYN = false) but buffer space is available for sending. | 68 |
| EPEERERR | 71 |7000 | 72 |The peer side has an unrecoverable error and this call has to be cancelled. | 73 |
The send method sends certain amount of data from the application buffer. If the the size limit of sending buffer queue is reached, 78 | send only sends a portion of the application buffer and returns the actual size of data that has been sent.
79 |In blocking mode (default), send waits until there is some sending buffer space available. In non-blocking mode, send 80 | returns immediately and returns error if the sending queue limit is already limited.
81 |If UDT_SNDTIMEO is set and the socket is in blocking mode, send only waits a limited time specified by UDT_SNDTIMEO option. If there is still no 82 | buffer space available when the timer expires, zero will be returned. UDT_SNDTIMEO has no effect for non-blocking socket.
83 | 84 |select, send, sendfile, recvfile
86 |87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /udt/win/udt.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "appclient", "appclient.vcproj", "{4C848417-B545-468B-AA0C-44EE73BC7B9B}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C} = {D84D100A-7C21-4CCB-B16E-0FB37137C16C} 5 | EndProjectSection 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "appserver", "appserver.vcproj", "{1F726B88-8807-4E99-9982-CCE33198BEE8}" 8 | ProjectSection(ProjectDependencies) = postProject 9 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C} = {D84D100A-7C21-4CCB-B16E-0FB37137C16C} 10 | EndProjectSection 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "recvfile", "recvfile.vcproj", "{3D73B2C7-9C2A-4901-9714-03FFB9367644}" 13 | ProjectSection(ProjectDependencies) = postProject 14 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C} = {D84D100A-7C21-4CCB-B16E-0FB37137C16C} 15 | EndProjectSection 16 | EndProject 17 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sendfile", "sendfile.vcproj", "{88AFBB12-0392-4210-A89C-E932BE3AB2E0}" 18 | ProjectSection(ProjectDependencies) = postProject 19 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C} = {D84D100A-7C21-4CCB-B16E-0FB37137C16C} 20 | EndProjectSection 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udt", "udt.vcproj", "{D84D100A-7C21-4CCB-B16E-0FB37137C16C}" 23 | ProjectSection(ProjectDependencies) = postProject 24 | EndProjectSection 25 | EndProject 26 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{C70F9A98-ECFF-4DC7-895D-0E41936BD1BA}" 27 | ProjectSection(ProjectDependencies) = postProject 28 | EndProjectSection 29 | EndProject 30 | Global 31 | GlobalSection(SolutionConfiguration) = preSolution 32 | Debug = Debug 33 | Release = Release 34 | EndGlobalSection 35 | GlobalSection(ProjectConfiguration) = postSolution 36 | {4C848417-B545-468B-AA0C-44EE73BC7B9B}.Debug.ActiveCfg = Debug|Win32 37 | {4C848417-B545-468B-AA0C-44EE73BC7B9B}.Debug.Build.0 = Debug|Win32 38 | {4C848417-B545-468B-AA0C-44EE73BC7B9B}.Release.ActiveCfg = Release|Win32 39 | {4C848417-B545-468B-AA0C-44EE73BC7B9B}.Release.Build.0 = Release|Win32 40 | {1F726B88-8807-4E99-9982-CCE33198BEE8}.Debug.ActiveCfg = Debug|Win32 41 | {1F726B88-8807-4E99-9982-CCE33198BEE8}.Debug.Build.0 = Debug|Win32 42 | {1F726B88-8807-4E99-9982-CCE33198BEE8}.Release.ActiveCfg = Release|Win32 43 | {1F726B88-8807-4E99-9982-CCE33198BEE8}.Release.Build.0 = Release|Win32 44 | {3D73B2C7-9C2A-4901-9714-03FFB9367644}.Debug.ActiveCfg = Debug|Win32 45 | {3D73B2C7-9C2A-4901-9714-03FFB9367644}.Debug.Build.0 = Debug|Win32 46 | {3D73B2C7-9C2A-4901-9714-03FFB9367644}.Release.ActiveCfg = Release|Win32 47 | {3D73B2C7-9C2A-4901-9714-03FFB9367644}.Release.Build.0 = Release|Win32 48 | {88AFBB12-0392-4210-A89C-E932BE3AB2E0}.Debug.ActiveCfg = Debug|Win32 49 | {88AFBB12-0392-4210-A89C-E932BE3AB2E0}.Debug.Build.0 = Debug|Win32 50 | {88AFBB12-0392-4210-A89C-E932BE3AB2E0}.Release.ActiveCfg = Release|Win32 51 | {88AFBB12-0392-4210-A89C-E932BE3AB2E0}.Release.Build.0 = Release|Win32 52 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C}.Debug.ActiveCfg = Debug|Win32 53 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C}.Debug.Build.0 = Debug|Win32 54 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C}.Release.ActiveCfg = Release|Win32 55 | {D84D100A-7C21-4CCB-B16E-0FB37137C16C}.Release.Build.0 = Release|Win32 56 | {C70F9A98-ECFF-4DC7-895D-0E41936BD1BA}.Debug.ActiveCfg = Debug|Win32 57 | {C70F9A98-ECFF-4DC7-895D-0E41936BD1BA}.Debug.Build.0 = Debug|Win32 58 | {C70F9A98-ECFF-4DC7-895D-0E41936BD1BA}.Release.ActiveCfg = Release|Win32 59 | {C70F9A98-ECFF-4DC7-895D-0E41936BD1BA}.Release.Build.0 = Release|Win32 60 | EndGlobalSection 61 | GlobalSection(ExtensibilityGlobals) = postSolution 62 | EndGlobalSection 63 | GlobalSection(ExtensibilityAddIns) = postSolution 64 | EndGlobalSection 65 | EndGlobal 66 | -------------------------------------------------------------------------------- /udt/doc/doc/function.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The UDT socket functions are contained in the UDT namespace. The methods are listed in the table below:
15 | 16 || Method | 19 |Fuctionality | 20 |
| accept | 23 |accept a connection. | 24 |
| bind | 27 |assign a local name to an unnamed udt socket. | 28 |
| cleanup | 31 |release the complete UDT library. | 32 |
| close | 35 |close the opened UDT entity and shutdown the connection. | 36 |
| connect | 39 |connect to the server or the peer side. | 40 |
| epoll | 43 |watch for a group of UDT and system sockets for IO events. | 44 |
| getlasterror | 47 |retrieve last UDT error in the current thread. | 48 |
| getpeername | 51 |read the address of the peer side of the connection | 52 |
| getsockname | 55 |read the local address of the UDT socket. | 56 |
| getsockopt | 59 |read UDT options. | 60 |
| listen | 63 |enable UDT into listening state and is ready for connection request. | 64 |
| perfmon | 67 |monitor internal protocol parameters and udt performance. | 68 |
| recv | 71 |receive data. | 72 |
| recvfile | 75 |receive data into a file. | 76 |
| recvmsg | 79 |receive a message. | 80 |
| select | 83 |wait for a number of UDT sockets to change status. | 84 |
| send | 87 |send data. | 88 |
| sendfile | 91 |send a file. | 92 |
| sendmsg | 95 |send a message. | 96 |
| setsockopt | 99 |configure UDT options. | 100 |
| socket | 103 |create a new UDT socket. | 104 |
| startup | 107 |initialize the UDT library. | 108 |
115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /udt/doc/doc/sockname.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The getsockname method retrieves the local address associated with a UDT socket.
14 | 15 |On success, getlasterror returns 0 and the local address information is stored in name; otherwise it returns UDT::ERROR and the specific error information can be 33 | retrieved using getlasterror.
34 | 35 || Error Name | 38 |Error Code | 39 |Comment | 40 |
| EINVPARAM | 43 |5003 | 44 |Invalid parameters. | 45 |
| EINVSOCK | 48 |5004 | 49 |u is an invailid UDT socket. | 50 |
| EUNBOUNDSOCK | 53 |5005 | 54 |u is not bound to a local address yet. | 55 |
The getsockname retrieves the local address associated with the socket. The UDT socket must be bound explicitly (via bind) or implicitly (via 60 | connect), otherwise this method will fail because there is no meaningful address bound to the socket.
61 |If getsockname is called after an explicit bind, but before connect, the IP address returned will be exactly the IP address that is used for bind and it may be 0.0.0.0 if ADDR_ANY is used. If getsockname is called after connect, the IP address returned will be the address that the peer socket sees. In the case when there is a proxy (e.g., NAT), the IP address returned will be the translated address by the proxy, but not a local address. If there is no proxy, the IP address returned will be a local address. In either case, the port number is local (i.e, not the translated proxy port).
62 |Because UDP is connection-less, using getsockname on a UDP port will almost always return 0.0.0.0 as IP address (unless it is bound to an explicit IP) . As a connection oriented protocol, UDT will return a meaningful IP address by getsockname if there is no proxy translation exist.
63 |UDT has no multihoming support yet. When there are multiple local addresses and more than one of them can be routed to the destination address, UDT may not behave properly due to the multi-path effect. In this case, the UDT socket must be explicitly bound to one of the local addresses.
64 |67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /udt/doc/doc/selectex.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The selectEx method queries a group of of UDT sockets for IO status.
19 |Note: selectEx is deprecated. Please use epoll instead, which is far more efficienct.
20 |If any of the read, write, or except group is not empty, selectEx returns the number of UDT sockets that are read for read/write or are broken/closed. If no socket is ready before timeout, zero is 44 | returned. If there is any error, UDT::ERROR is returned and the specific error information can be retrieved using getlasterror. The readfds,writefds and/or 45 | exceptfds will be updated to contain the ready sockets.
46 | 47 | 48 || Error Name | 51 |Error Code | 52 |Comment | 53 |
| EINVPARAM | 56 |5003 | 57 |All three socket sets are NULL or at least one of the socket is invalid. | 58 |
This function selectEx is an advanced version of select. In contrast to select, selectEx does not modify the input parameter fds, so that applications do not need to replicate or initialize it every time the function is called.
63 |The new function only has one group of input socket descriptors. If a particular event check is not necessary, the corresponding output parameter can be set to NULL. For example, if the application does not care about if a socket is ready for send, the parameter writefds can be NULL.
64 |Finally, selectEx specifies the absolute amount of time to wait, while select requires a clock time in the future to wait until.
65 |Overall, selectEx is more convinient and more efficient.
66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /udt/app/udcat_client.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | Copyright 2013 Laboratory for Advanced Computing at the University of Chicago 3 | 4 | This file is part of . 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions 16 | and limitations under the License. 17 | *****************************************************************************/ 18 | 19 | #includeIn this section we will introduce the simplest UDT program that can transfer data in high performance.
14 | 15 |This simple "Hello World!" example includes a server program and a client program just like any socket programming tutorial. These are the simpler version of the appserver and appclient 16 | examples in ./app directory.
17 | 18 |To compile, use gcc -o server server.cpp -I
19 |
UDT server example
25 | 26 |This simple server tries to bind itself at port 9000. If succeed, it listens at port 9000 and accepts a client and then reads a string.
77 |UDT client example
78 |The client side connects to the local address (127.0.0.1) at port 9000, and sends a "hello world!" message.
118 |Note that in this "Hello World!" example the UDT::send and UDT::recv routines should use a loop to check return value. However, since the string length is very small and can be hold in one packet, we omit the loop part in order to give a simpler example.
119 | 120 |121 | 122 | 123 | -------------------------------------------------------------------------------- /udt/doc/doc/connect.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The connect method connects to a server socket (in regular mode) or a peer socket (in rendezvous mode) to set up a UDT connection.
14 | 15 |If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror.
33 | 34 || Error Name | 37 |Error Code | 38 |Comment | 39 |
| ENOSERVER | 42 |1001 | 43 |server or peer socket does not exist, or there is no network connection. | 44 |
| ECONNREJ | 47 |1002 | 48 |the connection request was rejected by the peer. | 49 |
| ESECFAIL | 52 |1004 | 53 |connection was aborted due to possible attacks. | 54 |
| ECONNSOCK | 57 |5002 | 58 |the socket is not allowed to do a connectconnect call; it is either in listening state or has been already connected. | 59 |
| EINVSOCK | 62 |5004 | 63 |u is not a valid socket ID. | 64 |
| ERDVUNBOUND | 67 |5008 | 68 |the rendezvous mode has been enable, but bind was not called before connect. | 69 |
UDT is connection oriented, for both of its SOCK_STREAM and SOCK_DGRAM mode. connect must be called in order to set up a UDT connection. The name parameter is 74 | the address of the server or the peer side. In regular (default) client/server mode, the server side must has called bind and listen. In rendezvous mode, 75 | both sides must call bind and connect to each other at (approximately) the same time. Rendezvous connect may not be used for more than one connections on the same UDP port pair, in which case UDT_REUSEADDR may be set to false.
76 |UDT connect takes at least one round trip to finish. This may become a bottleneck if applications frequently connect and disconnect to the same address.
77 |When UDT_RCVSYN is set to false, the connect call will return immediately and perform the actual connection setup at background. Applications may use epoll to wait for the connect to complete.
78 |When connect fails, the UDT socket can still be used to connect again. However, if the socket was not bound before, it may be bound implicitly, as mentioned above, even 79 | if the connect fails. In addition, in the situation when the connect call fails, the UDT socket will not be automatically released, it is the applications' responsibility to close the socket, if the socket is not needed anymore (e.g., to re-connect).
80 | 81 |84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /udt/doc/doc/t-cc.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
You can add your own congestion control algorithm into UDT. It is as simple as to define several callback functions that will be triggered on certain events, e.g, when an ACK is 19 | received.
20 | 21 |All the congestion control callback functions are collected in a C++ class CCC. You have to inherit this class to define your own congestion control algorithm. That is, UDT/CCC uses an 22 | object-oriented design. CCC in defined in ccc.h, which you have to include in your files in order to enable this feature.
23 | 24 |The CCC class contains two control variables: m_dPktSndPeriod, and m_dCWndSize. m_dPktSndPeriod is a double float number representing the packet sending period (as to be used in rate 25 | control), in microseconds. m_dCWndSize is a double float number representing the size of the congestion window (cwnd), in number of packets. The congestion control algorithm will need to 26 | update at least one of them. For example, for pure window based approach, m_dPktSndPeriod should always be zero.
27 | 28 |The fast way to learn CCC is to use the examples in ./app/cc.h. The file cc.h also includes many more advanced control mechanisms that your control classes can be derived from. For 29 | example, if you are designing a new TCP variant, you can implement the new control class directly from CTCP.
30 | 31 |Here we demonstrate the usage of UDT/CCC by writing a reliable UDP blast control mechanism.
32 | 33 |In this example, CUDPBlast inherits from the base class CCC. In the constructor, it sets the congestion window size to a large value so that it will not affect the packet sending. (This 47 | is pure rate based method to blast UDP packets.) The method SetRate() can be used to set a fixed packet sending rate at any time.
48 | 49 |The application can use setsockopt/getsockopt to assign this control class to a UDT instance, and/or set its parameters.
50 | 51 |The above code assigns the CUDPBlast control algorthm to a UDT socket usock. Note that CCCFactory
To set a specific data sending rate, the application needs to obtain a handle to the concrete CCC class instance used by the UDT socket usock.
62 | 63 |The application can then call the method of setRate() to set a 500Mbps data rate.
70 | 71 |The UDT/CCC can be used to implement most control mechanims, including but not limited to rate-based approaches, TCP variants (e.g., TCP, Scalable, HighSpeed, BiC, Vegas, FAST), and 77 | group-based approaches (e.g., GTP, CM).
78 | 79 |1. Do NOT call regular UDT API inside CCC or its derived classes. Unknown error could happen.
81 | 82 |2. CCCFactory<...> is a C++ template class. You do not need to derive any classes from it.
83 | 84 |3. UDT will not release the CCCFactory<...> instance. The application should release it, at anywhere after the setsockopt() call.
85 | 86 |90 | 91 | 92 | -------------------------------------------------------------------------------- /server/daemon.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys, os, time, atexit 4 | from signal import SIGTERM 5 | 6 | class Daemon: 7 | """ 8 | A generic daemon class, based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ 9 | 10 | Usage: subclass the Daemon class and override the run() method 11 | """ 12 | def __init__(self, pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): 13 | self.stdin = stdin 14 | self.stdout = stdout 15 | self.stderr = stderr 16 | self.pidfile = pidfile 17 | 18 | def daemonize(self): 19 | """ 20 | do the UNIX double-fork magic, see Stevens' "Advanced 21 | Programming in the UNIX Environment" for details (ISBN 0201563177) 22 | http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 23 | """ 24 | try: 25 | pid = os.fork() 26 | if pid > 0: 27 | # exit first parent 28 | sys.exit(0) 29 | except OSError, e: 30 | sys.stderr.write("[FAIL] fork #1: %d (%s)\n" % (e.errno, e.strerror)) 31 | sys.exit(1) 32 | 33 | # decouple from parent environment 34 | os.chdir("/") 35 | os.setsid() 36 | os.umask(0) 37 | 38 | # do second fork 39 | try: 40 | pid = os.fork() 41 | if pid > 0: 42 | # exit from second parent 43 | sys.exit(0) 44 | except OSError, e: 45 | sys.stderr.write("[FAIL] fork #2: %d (%s)\n" % (e.errno, e.strerror)) 46 | sys.exit(1) 47 | 48 | # write pidfile 49 | pid = str(os.getpid()) 50 | file(self.pidfile,'w+').write("%s\n" % pid) 51 | 52 | atexit.register(self.delpid) 53 | 54 | # redirect standard file descriptors 55 | sys.stdout.flush() 56 | sys.stderr.flush() 57 | si = file(self.stdin, 'r') 58 | so = file(self.stdout, 'a+') 59 | se = file(self.stderr, 'a+', 0) 60 | os.dup2(si.fileno(), sys.stdin.fileno()) 61 | os.dup2(so.fileno(), sys.stdout.fileno()) 62 | os.dup2(se.fileno(), sys.stderr.fileno()) 63 | 64 | def delpid(self): 65 | os.remove(self.pidfile) 66 | 67 | def start(self): 68 | """ 69 | Start the daemon 70 | """ 71 | # Check for a pidfile to see if the daemon already runs 72 | try: 73 | pf = file(self.pidfile,'r') 74 | pid = int(pf.read().strip()) 75 | pf.close() 76 | except IOError: 77 | pid = None 78 | 79 | if pid: 80 | message = "[FAIL] pidfile %s already exists. Daemon already running?\n" 81 | sys.stderr.write(message % self.pidfile) 82 | sys.exit(1) 83 | 84 | # Start the daemon 85 | self.daemonize() 86 | self.run() 87 | 88 | def stop(self): 89 | """ 90 | Stop the daemon 91 | """ 92 | # Get the pid from the pidfile 93 | try: 94 | pf = file(self.pidfile,'r') 95 | pid = int(pf.read().strip()) 96 | pf.close() 97 | except IOError: 98 | pid = None 99 | 100 | if not pid: 101 | message = "[FAIL] pidfile %s does not exist. Daemon not running?\n" 102 | sys.stderr.write(message % self.pidfile) 103 | return # not an error in a restart 104 | 105 | # Try killing the daemon process 106 | try: 107 | while 1: 108 | os.kill(pid, SIGTERM) 109 | time.sleep(0.1) 110 | except OSError, err: 111 | err = str(err) 112 | if err.find("No such process") > 0: 113 | if os.path.exists(self.pidfile): 114 | os.remove(self.pidfile) 115 | else: 116 | sys.stderr.write("[FAIL]\n%s\n" % str(err)) 117 | sys.exit(1) 118 | 119 | #def restart(self): 120 | # """ 121 | # Restart the daemon 122 | # """ 123 | # self.stop() 124 | # self.start() 125 | 126 | def run(self): 127 | """ 128 | You should override this method when you subclass Daemon. It will be called after the process has been 129 | daemonized by start() or restart(). 130 | """ 131 | -------------------------------------------------------------------------------- /udt/win/recvfile.vcproj: -------------------------------------------------------------------------------- 1 | 2 |
The bind method binds a UDT socket to a known or an available local address.
14 | 15 |If the binding is successful, bind returns 0, otherwise it returns UDT::ERROR and the specific error information can be retrieved using getlasterror.
46 | 47 || Error Name | 50 |Error Code | 51 |Comment | 52 |
| EBOUNDSOCK | 55 |5001 | 56 |u has already been bound to certain address. | 57 |
| EINVPARAM | 60 |5003 | 61 |the address is either invalid or unavailable. | 62 |
| EINVSOCK | 65 |5004 | 66 |u is an invalid UDT socket. | 67 |
The bind method is usually to assign a UDT socket a local address, including IP address and port number. If INADDR_ANY is used, a proper IP address will be used once 72 | the UDT connection is set up. If 0 is used for the port, a randomly available port number will be used. The method getsockname can be used to retrieve this port 73 | number.
74 |The second form of bind allows UDT to bind directly on an existing UDP socket. This is usefule for firewall traversing in certain situations: 1) a UDP socket is created and its address is learned from a name server, there is no need to close the UDP socket and open a UDT socket on the same address again; 2) for certain firewall, especially some on local system, the port mapping maybe changed or the "hole" may be closed when a UDP socket is closed and reopened, thus it is necessary to use the UDP socket directly in UDT.
75 |Use the second form of bind with caution, as it violates certain programming rules regarding code robustness. Once the UDP socket descriptor is passed to UDT, it MUST NOT be touched again. DO NOT use this unless you clearly understand how the related systems work.
76 |The bind call is necessary in all cases except for a socket to listen. If bind is not called, UDT will automatically bind a 77 | socket to a randomly available address when a connection is set up.
78 |By default, UDT allows to reuse existing UDP port for new UDT sockets, unless UDT_REUSEADDR is set to false. When UDT_REUSEADDR is false, UDT will create an 79 | exclusive UDP port for this UDT socket. UDT_REUSEADDR must be called before bind. To reuse an existing UDT/UDP port, the new UDT socket must 80 | explicitly bind to the port. If the port is already used by a UDT socket with UDT_REUSEADDR as false, the new bind will return error. If 0 is passed 81 | as the port number, bind always creates a new port, no matter what value the UDT_REUSEADDR sets.
82 | 83 |listen, connect, setsockopt, getsockopt
85 |86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /udt/doc/doc/select.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
The select method queries one or more groups of UDT sockets.
19 |Note: select is deprecated. Please use epoll instead, which is far more efficienct.
20 |If any of the read or write query is positive, select returns the number of UDT sockets that are read for read/write. If no socket is ready before timeout, zero is 44 | returned. If there is any error, UDT::ERROR is returned and the specific error information can be retrieved using getlasterror. The readfds and/or 45 | writefds will be updated to contain the ready sockets only.
46 | 47 | 48 || Error Name | 51 |Error Code | 52 |Comment | 53 |
| EINVPARAM | 56 |5003 | 57 |All three socket sets are empty or at least one of the socket is invalid. | 58 |
The UDSET is a structure to store the UDT socket descriptors. If should only be processed with the following macros.
63 |The UDT descriptors sets originaly contains the sockets whose status is to be queried. When select returns, the descriptors sets only contain the sockets that are 75 | ready for IO. UD_ISSET can be used to check which one is ready.
76 |readfds is used to detect if any socket in this set is available for reading (recv, recvmsg), for accepting a new connection (accept), or the associated connection is broken. 77 | writefds is used to detect if any socket in this set has available buffer for sending (send, sendmsg). Currently exceptfds is not used.
78 | 79 |The following example shows how to check if a UDT socket is available for recv.
81 | 82 |
84 | UDTSOCKET u;
85 | ...
86 |
87 | timeval tv;
88 | UDSET readfds;
89 |
90 | tv.tv_sec = 1;
91 | tv.tv_usec = 0;
92 |
93 | UD_ZERO(&readfds);
94 | UD_SET(u, &readfds);
95 |
96 | int res = UDT::select(0, &readfds, NULL, NULL, &tv);
97 |
98 | if ((res != UDT::ERROR) && (UD_ISSET(u, &readfds)))
99 | // read data from u.
100 | else
101 | // timeout or error
102 |
109 | 110 | 111 | 112 | --------------------------------------------------------------------------------