├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── aws
├── ec2-prep.bash
└── python
│ ├── .gitignore
│ ├── LICENSE
│ ├── MANIFEST.in
│ ├── PUBLISH_STEPS
│ ├── README
│ ├── README.md
│ ├── build.bash
│ ├── clean.bash
│ ├── publish_layer.py
│ ├── python_packages
│ ├── README.md
│ ├── lambda_networking
│ │ ├── __init__.py
│ │ └── connect.py
│ └── setup.py
│ ├── setup.py
│ ├── src
│ └── udt4py.pyx
│ └── tests
│ ├── lambda
│ ├── LICENSE.TXT
│ ├── README
│ ├── build.bash
│ ├── sar-publish.bash
│ ├── src
│ │ ├── bandwidth.py
│ │ ├── networking_sample.py
│ │ └── requirements.txt
│ └── template.yaml
│ ├── speed.py
│ ├── udt_epoll.py
│ └── udt_socket.py
├── docs
├── CNAME
├── FAQ.md
├── _config.yml
├── getting_started.md
├── index.md
└── overview.md
└── udt
└── udt4
├── LICENSE.txt
├── Makefile
├── README.txt
├── RELEASE_NOTES.txt
├── app
├── Makefile
├── appclient.cpp
├── appserver.cpp
├── cc.h
├── recvfile.cpp
├── sendfile.cpp
├── test.cpp
└── test_util.h
├── doc
├── doc
│ ├── accept.htm
│ ├── bind.htm
│ ├── ccc.htm
│ ├── cleanup.htm
│ ├── close.htm
│ ├── connect.htm
│ ├── copy.htm
│ ├── ecode.htm
│ ├── epoll.htm
│ ├── error.htm
│ ├── footer.htm
│ ├── function.htm
│ ├── header.htm
│ ├── intro.htm
│ ├── listen.htm
│ ├── make.htm
│ ├── opt.htm
│ ├── peername.htm
│ ├── recv.htm
│ ├── recvfile.htm
│ ├── recvmsg.htm
│ ├── reference.htm
│ ├── select.htm
│ ├── selectex.htm
│ ├── send.htm
│ ├── sendfile.htm
│ ├── sendmsg.htm
│ ├── socket.htm
│ ├── sockname.htm
│ ├── startup.htm
│ ├── structure.htm
│ ├── t-cc.htm
│ ├── t-config.htm
│ ├── t-data.htm
│ ├── t-error.htm
│ ├── t-file.htm
│ ├── t-firewall.htm
│ ├── t-hello.htm
│ ├── t-intro.htm
│ ├── t-msg.htm
│ ├── t-udt3.htm
│ ├── trace.htm
│ ├── treeview.css
│ ├── tutorial.htm
│ └── udtdoc.css
├── hlp
│ ├── ix_book.gif
│ ├── ix_down.gif
│ ├── ix_end.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
│ └── ix_up.gif
├── index.htm
└── main.htm
├── draft-gg-udt-xx.txt
├── src
├── Makefile
├── api.cpp
├── api.h
├── buffer.cpp
├── buffer.h
├── cache.cpp
├── cache.h
├── ccc.cpp
├── ccc.h
├── channel.cpp
├── channel.h
├── common.cpp
├── common.h
├── core.cpp
├── core.h
├── epoll.cpp
├── epoll.h
├── list.cpp
├── list.h
├── md5.cpp
├── md5.h
├── packet.cpp
├── packet.h
├── queue.cpp
├── queue.h
├── udt.h
├── window.cpp
└── window.h
└── win
├── appclient.vcproj
├── appserver.vcproj
├── recvfile.vcproj
├── sendfile.vcproj
├── test.vcproj
├── udt.sln
└── udt.vcproj
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_STORE
2 | layer_staging/
3 | udt/udt4/src/udt
4 | udt/udt4/app/
5 | jnk
6 |
7 | # Ignore generated YAML files that are part of the SAM workflow process
8 | output.yaml
9 |
10 | # Byte-compiled / optimized / DLL files
11 | __pycache__/
12 | *.py[cod]
13 | *$py.class
14 |
15 | # C extensions
16 | *.so
17 | *.o
18 | *.a
19 |
20 | # Distribution / packaging
21 | .Python
22 | build/
23 | develop-eggs/
24 | dist/
25 | downloads/
26 | eggs/
27 | .eggs/
28 | lib/
29 | lib64/
30 | parts/
31 | sdist/
32 | var/
33 | wheels/
34 | *.egg-info/
35 | .installed.cfg
36 | *.egg
37 | MANIFEST
38 |
39 | # PyInstaller
40 | # Usually these files are written by a python script from a template
41 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
42 | *.manifest
43 | *.spec
44 |
45 | # Installer logs
46 | pip-log.txt
47 | pip-delete-this-directory.txt
48 |
49 | # Unit test / coverage reports
50 | htmlcov/
51 | .tox/
52 | .coverage
53 | .coverage.*
54 | .cache
55 | nosetests.xml
56 | coverage.xml
57 | *.cover
58 | .hypothesis/
59 | .pytest_cache/
60 |
61 | # Translations
62 | *.mo
63 | *.pot
64 |
65 | # Django stuff:
66 | *.log
67 | local_settings.py
68 | db.sqlite3
69 |
70 | # Flask stuff:
71 | instance/
72 | .webassets-cache
73 |
74 | # Scrapy stuff:
75 | .scrapy
76 |
77 | # Sphinx documentation
78 | docs/_build/
79 |
80 | # PyBuilder
81 | target/
82 |
83 | # Jupyter Notebook
84 | .ipynb_checkpoints
85 |
86 | # pyenv
87 | .python-version
88 |
89 | # celery beat schedule file
90 | celerybeat-schedule
91 |
92 | # SageMath parsed files
93 | *.sage.py
94 |
95 | # Environments
96 | .env
97 | .venv
98 | env/
99 | venv/
100 | ENV/
101 | env.bak/
102 | venv.bak/
103 |
104 | # Spyder project settings
105 | .spyderproject
106 | .spyproject
107 |
108 | # Rope project settings
109 | .ropeproject
110 |
111 | # mkdocs documentation
112 | /site
113 |
114 | # mypy
115 | .mypy_cache/
116 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Racially insensitive terminology in documentation or software
32 | * Other conduct which could reasonably be considered inappropriate in a
33 | professional setting
34 |
35 | ## Our Responsibilities
36 |
37 | Project maintainers are responsible for clarifying the standards of acceptable
38 | behavior and are expected to take appropriate and fair corrective action in
39 | response to any instances of unacceptable behavior.
40 |
41 | Project maintainers have the right and responsibility to remove, edit, or
42 | reject comments, commits, code, wiki edits, issues, and other contributions
43 | that are not aligned to this Code of Conduct, or to ban temporarily or
44 | permanently any contributor for other behaviors that they deem inappropriate,
45 | threatening, offensive, or harmful.
46 |
47 | ## Scope
48 |
49 | This Code of Conduct applies both within project spaces and in public spaces
50 | when an individual is representing the project or its community. Examples of
51 | representing a project or community include using an official project e-mail
52 | address, posting via an official social media account, or acting as an appointed
53 | representative at an online or offline event. Representation of a project may be
54 | further defined and clarified by project maintainers.
55 |
56 | ## Enforcement
57 |
58 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
59 | reported by contacting the project team at timawagner@gmail.com. All
60 | complaints will be reviewed and investigated and will result in a response that
61 | is deemed necessary and appropriate to the circumstances. The project team is
62 | obligated to maintain confidentiality with regard to the reporter of an incident.
63 | Further details of specific enforcement policies may be posted separately.
64 |
65 | Project maintainers who do not follow or enforce the Code of Conduct in good
66 | faith may face temporary or permanent repercussions as determined by other
67 | members of the project's leadership.
68 |
69 | ## Attribution
70 |
71 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
72 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
73 |
74 | [homepage]: https://www.contributor-covenant.org
75 |
76 | For answers to common questions about this code of conduct, see
77 | https://www.contributor-covenant.org/faq
78 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Additional code and derivative works created by the Serverless Networking project are licensed as follows:
2 | BSD 2-Clause License
3 |
4 | Copyright (c) 2019, Serverless Tech, Inc.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 |
10 | 1. Redistributions of source code must retain the above copyright notice, this
11 | list of conditions and the following disclaimer.
12 |
13 | 2. Redistributions in binary form must reproduce the above copyright notice,
14 | this list of conditions and the following disclaimer in the documentation
15 | and/or other materials provided with the distribution.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 | udt4py License:
29 | Copyright (c) 2014, Samsung Electronics Co.,Ltd.
30 | All rights reserved.
31 |
32 | Redistribution and use in source and binary forms, with or without
33 | modification, are permitted provided that the following conditions are met:
34 |
35 | 1. Redistributions of source code must retain the above copyright notice, this
36 | list of conditions and the following disclaimer.
37 | 2. Redistributions in binary form must reproduce the above copyright notice,
38 | this list of conditions and the following disclaimer in the documentation
39 | and/or other materials provided with the distribution.
40 |
41 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
42 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
43 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
45 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 |
52 | The views and conclusions contained in the software and documentation are those
53 | of the authors and should not be interpreted as representing official policies,
54 | either expressed or implied, of Samsung Electronics Co.,Ltd.
55 |
56 | UDT License:
57 | Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois.
58 | All rights reserved.
59 |
60 | Redistribution and use in source and binary forms, with or without
61 | modification, are permitted provided that the following conditions are
62 | met:
63 |
64 | * Redistributions of source code must retain the above
65 | copyright notice, this list of conditions and the
66 | following disclaimer.
67 |
68 | * Redistributions in binary form must reproduce the
69 | above copyright notice, this list of conditions
70 | and the following disclaimer in the documentation
71 | and/or other materials provided with the distribution.
72 |
73 | * Neither the name of the University of Illinois
74 | nor the names of its contributors may be used to
75 | endorse or promote products derived from this
76 | software without specific prior written permission.
77 |
78 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
79 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
80 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
81 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
82 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
83 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
84 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
85 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
86 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
87 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ServerlessNetworkingClients
2 | Client SDKs for ServerlessNetworking.
3 | User documentation can be found at https://networkingclients.serverlesstech.net/
4 |
--------------------------------------------------------------------------------
/aws/ec2-prep.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Commands needed to turn a vanilla EC2 Amazon Linux 2 machine into
3 | # one that's ready to build & use udt, udt4py, and aws commands.
4 | sudo yum install python37
5 | sudo yum install gcc
6 | sudo yum install gcc-c++
7 | sudo yum install git
8 | sudo yum install python3-devel
9 |
10 |
--------------------------------------------------------------------------------
/aws/python/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_STORE
2 | .vscode/
3 |
4 | stage_layer/
5 |
6 | *.py[cod]
7 | *.cpp
8 |
9 | # C extensions
10 | *.so
11 | *.o
12 |
13 | # Packages
14 | *.egg
15 | *.egg-info
16 | dist
17 | build
18 | eggs
19 | parts
20 | bin
21 | var
22 | sdist
23 | develop-eggs
24 | .installed.cfg
25 | lib
26 | lib64
27 | __pycache__
28 | build
29 |
30 | # Installer logs
31 | pip-log.txt
32 |
33 | # Unit test / coverage reports
34 | .coverage
35 | .tox
36 | nosetests.xml
37 |
38 | # Translations
39 | *.mo
40 |
41 | # Mr Developer
42 | .mr.developer.cfg
43 | .project
44 | .pydevproject
45 |
--------------------------------------------------------------------------------
/aws/python/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, Samsung Electronics Co.,Ltd.
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 met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 | 2. Redistributions in binary form must reproduce the above copyright notice,
10 | this list of conditions and the following disclaimer in the documentation
11 | and/or other materials provided with the distribution.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | The views and conclusions contained in the software and documentation are those
25 | of the authors and should not be interpreted as representing official policies,
26 | either expressed or implied, of Samsung Electronics Co.,Ltd..
27 |
--------------------------------------------------------------------------------
/aws/python/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include udt4py/udt4py.pyx
2 | exclude udt4py/udt4py.cpp
3 | include tests/*.py
4 | include LICENSE
5 | include README
6 | include README.md
7 | include setup.py
8 |
--------------------------------------------------------------------------------
/aws/python/PUBLISH_STEPS:
--------------------------------------------------------------------------------
1 | . venv/bin/activate
2 | # If from a clean install...
3 | pip install boto3
4 | python publish_layer.py
5 |
--------------------------------------------------------------------------------
/aws/python/README:
--------------------------------------------------------------------------------
1 | README.md
--------------------------------------------------------------------------------
/aws/python/README.md:
--------------------------------------------------------------------------------
1 | udt4py
2 | ======
3 |
4 | libudt4 Python wrapper written with Cython.
5 |
6 | Tested with Python 2.7 and Python 3.3 on Linux. In buffer operations bytes,
7 | bytearray and memoryview objects are supported, allowing zero-copy operations.
8 |
9 | In order to build the native module, execute:
10 |
11 | ```bash
12 | python3 setup.py build_ext --inplace
13 | ```
14 |
15 | In Ubuntu, you will need ``cython3`` package.
16 | To run the tests, execute:
17 |
18 | ```bash
19 | PYTHONPATH=`pwd` nosetests3 -w tests --tests udt_socket,udt_epoll
20 | ```
21 |
22 | Example usage:
23 |
24 | ```python
25 | from udt4py import UDTSocket
26 |
27 |
28 | if __name__ == "__main__":
29 | socket = UDTSocket()
30 | socket.bind("0.0.0.0:7777")
31 | socket.listen()
32 | channel = socket.accept()
33 | msg = bytearray(5)
34 | channel.recv(msg)
35 | ```
36 |
37 | Released under Simplified BSD License.
38 | Copyright (c) 2014, Samsung Electronics Co.,Ltd.
39 |
--------------------------------------------------------------------------------
/aws/python/build.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Build udt4py. This script can only be run from the .../aws/python directory and must
3 | # be executed either on an EC2 Amazon Linux2 instance or in a Docker container emulating
4 | # the Lambda environment in order for it to be runtime binary compatible with Lambda execution.
5 | # Make sure the the ec2-prep command has been run before attempting this from EC2!
6 | #
7 | # To prepare to run this script, see ../ec2-prep.bash
8 | # To package the result of running this script, see ./package.py
9 | # To clean up the artifacts from this script, see ./clean.bash
10 |
11 | # Ensure that udt4 itself has been built
12 | echo "Ensuring udt4 C++ library is built"
13 | pushd ../../udt/udt4
14 | make
15 | popd
16 |
17 | # Create a Python virtual environment
18 | echo "Setting up Python 3 virtual environment and staging ground"
19 | rm -rf venv
20 | mkdir venv
21 | python3 -m venv venv
22 | . venv/bin/activate
23 |
24 | # Ensure websockets installed; we'll add this to the layer
25 | pip install --upgrade pip
26 | pip install websockets
27 | pip install boto3
28 |
29 | # Cython build requires the C/C++ udt4 includes in order to compile
30 | echo "Compiling and packaging udt4py"
31 | export LD_LIBRARY_PATH=../../udt/udt4/src
32 | python setup.py build_ext --inplace
33 |
34 | # Package lambda_networking
35 | echo "Packaging lambda_networking"
36 | pushd python_packages
37 | python setup.py sdist bdist
38 | popd
39 | echo "Installing lambda_networking"
40 | pip install python_packages/
41 |
42 | # Minimal test to ensure build, install, and LD_LIBRARY_PATH all work
43 | echo "Verifying lambda_networking package and built libraries all load"
44 | export LD_LIBRARY_PATH=../../udt/udt4/src
45 | python python_packages/lambda_networking/connect.py
46 |
47 | # Stage for publishing but don't actually publish in this script
48 | echo "Staging layer (see publish script for actual publishing commands)"
49 | rm -rf stage_layer
50 | export DIR=stage_layer/python/lib/python3.7/site-packages
51 | mkdir stage_layer && mkdir stage_layer/lib && mkdir stage_layer/python && mkdir stage_layer/python/lib && mkdir stage_layer/python/lib/python3.7 && mkdir $DIR
52 | # Package UDT C++ networking library
53 | cp ../../udt/udt4/src/libudt.so stage_layer/lib
54 | # Package udt4py Python wrapper
55 | cp udt4py.cpython-37m-x86_64-linux-gnu.so $DIR
56 | # Package the required Python dependencies (websockets, e.g.)
57 | # Remove C files and all pyc's in the __pycache__; they're not needed for layer execution.
58 | cp -r venv/lib/python3.7/site-packages/websockets $DIR
59 | rm -rf $DIR/websockets/__pycache__
60 | rm -f $DIR/websockets/*.c
61 | rm -rf $DIR/websockets/extensions/__pycache__
62 | cp -r venv/lib/python3.7/site-packages/lambda_networking $DIR
63 | rm -rf $DIR/lambda_networking/__pycache__
64 | cd stage_layer && zip -r layer.zip lib python
65 |
66 | echo "Layer build script completed"
67 |
--------------------------------------------------------------------------------
/aws/python/clean.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Clean the pyx build artifacts
3 | python setup.py clean --all
4 | rm -rf *egg*
5 | rm -f *.so
6 | rm -f src/*.cpp
7 | rm -rf stage_layer
8 | rm -rf build
9 | pushd python_packages
10 | python setup.py clean --all
11 | rm -rf *.egg-info
12 | rm -rf dist
13 | rm -rf __pycache__
14 | rm -rf lambda_networking/__pycache__
15 | popd
16 |
17 |
--------------------------------------------------------------------------------
/aws/python/publish_layer.py:
--------------------------------------------------------------------------------
1 | import boto3
2 | import json
3 | # Globals
4 | LayerName = 'ServerlessNetworking-Python3'
5 | lambda_sdk = boto3.client('lambda')
6 |
7 | # Create a new (version of) this layer. Requires the build & package
8 | # step to have been previously performed in this directory. AWS permissions
9 | # sufficient for the two calls below must be in the ambiant environment for this to work.
10 | try:
11 | print('Initiating layer publish (this will take a few seconds)...')
12 | layer = lambda_sdk.publish_layer_version(
13 | LayerName=LayerName,
14 | Description='ServerlessNetworking AWS Lambda layer for Python3 functions',
15 | Content={
16 | 'ZipFile': open('stage_layer/layer.zip', 'rb').read()
17 | },
18 | CompatibleRuntimes=['python3.7'],
19 | LicenseInfo='BSD-3-Clause'
20 | )
21 | print('Layer publishing result:')
22 | print(json.dumps(layer))
23 | # Give the world permission to use this layer.
24 | response = lambda_sdk.add_layer_version_permission(
25 | LayerName=LayerName,
26 | VersionNumber=layer["Version"],
27 | StatementId='ServerlessNetworkingClientPublishScript',
28 | Action='lambda:GetLayerVersion',
29 | Principal='*'
30 | )
31 | print('Layer permissioning result:')
32 | print(json.dumps(response))
33 | except Exception as e:
34 | print('Attempt to create layer failed: ' + str(e))
35 |
--------------------------------------------------------------------------------
/aws/python/python_packages/README.md:
--------------------------------------------------------------------------------
1 | # Lambda Networking Python 3 Package
2 |
3 | To use this package see the
4 | [User and API docs](http://networkingclients.serverlesstech.net)
5 |
6 | To create issues or pull requests visit
7 | [the GitHub repo](https://github.com/serverlessunicorn/ServerlessNetworkingClients)
8 |
--------------------------------------------------------------------------------
/aws/python/python_packages/lambda_networking/__init__.py:
--------------------------------------------------------------------------------
1 | # Marker file to autodetect Python package in this directory.
2 | """Lambda Networking is a Python 3 package that supports peer-to-peer networking built on top of udt4py and udt4."""
3 |
--------------------------------------------------------------------------------
/aws/python/python_packages/setup.py:
--------------------------------------------------------------------------------
1 | print('setup.py for lambda_networking package is starting...')
2 | import setuptools
3 |
4 | print('Loading README.md')
5 | with open("README.md", "r") as fh:
6 | long_description = fh.read()
7 |
8 | print('Running setup on lambda_networking package')
9 | setuptools.setup(
10 | name="lambda_networking",
11 | version="0.0.1",
12 | author="Tim Wagner",
13 | author_email="info@serverlesstech.net",
14 | description="Peer-to-peer networking for AWS Lambda",
15 | long_description=long_description,
16 | long_description_content_type="text/markdown",
17 | url="https://github.com/serverlessunicorn/ServerlessNetworkingClients",
18 | packages=setuptools.find_packages(),
19 | classifiers=[
20 | "Programming Language :: Python :: 3",
21 | "License :: OSI Approved :: BSD License",
22 | "Operating System :: Unix",
23 | ],
24 | python_requires='>=3.7',
25 | )
26 | print('Setup of lambda_networking package complete')
27 |
28 |
--------------------------------------------------------------------------------
/aws/python/setup.py:
--------------------------------------------------------------------------------
1 | """
2 | Copyright (c) 2014, Samsung Electronics Co.,Ltd.
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 |
25 | The views and conclusions contained in the software and documentation are those
26 | of the authors and should not be interpreted as representing official policies,
27 | either expressed or implied, of Samsung Electronics Co.,Ltd..
28 | """
29 |
30 | """
31 | udt4py - libudt4 Cython-ish wrapper.
32 | URL: https://github.com/vmarkovtsev/udt4py
33 | Original author: Vadim Markovtsev The accept method retrieves an incoming connection. If no error occurs, accept returns the UDT socket descriptor of the new connection; otherwise, it returns
33 | UDT::INVALID_SOCK. 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. If an error is returned, the error information
37 | can be retrieved by getlasterror. One of the following error can cause an accept error: 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. 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. The accepted sockets will inherit all proper attributes from the listening socket. listen, connect, setsockopt, getsockopt The bind method binds a UDT socket to a known or an available local address. If the binding is successful, bind returns 0, otherwise it returns UDT::ERROR and the specific error information can be retrieved using getlasterror. 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. 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. 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. 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. 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. listen, connect, setsockopt, getsockopt The cleanup method releases the UDT library from your application. If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror. In the current version, this method always succeed. 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. The method must be called before the application exits, or before the UDT DLL is released, otherwise memory leak could happen. The close method closes a UDT connection. If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror. 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. 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. 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. All sockets should be closed if they are not used any more. The connect method connects to a server socket (in regular mode) or a peer socket (in rendezvous mode) to set up a UDT connection. If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror. 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. 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. 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. 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). Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois. Redistribution and use in source and binary forms, with or without
15 | modification, are permitted provided that the following conditions are
16 | met: 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 The getlasterror method the last UDT error within the same thread. 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. 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. Error Code List, Error Handling The UDT socket functions are contained in the UDT namespace. The methods are listed in the table below: Welcome to the UDT4 SDK documentation. 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. Visit http://udt.sf.net for most recent news on UDT. Check out most current UDT release at SourceForge or from CVS. export CVS_RSH=ssh In this documentation: The listen method enables a server UDT entity to wait for clients to connect. If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror. 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. 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. Here is the content of the distribution: ./src: UDT source code 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). The available operating system options are: LINUX, BSD, and OSX. The command is in the format: make -e os=XXX arch=YYY 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 | accept
13 |
16 | UDTSOCKET u,
17 | struct sockaddr* addr,
18 | int* addrlen
19 | );Parameters
22 |
23 |
30 |
31 | Return Value
32 |
40 |
66 |
67 |
41 |
45 | Error Name
42 | Error Code
43 | Comment
44 |
46 |
50 | EINVSOCK
47 | 5004
48 | u is an invalid UDT socket.
49 |
51 |
55 | ENOLISTEN
52 | 5006
53 | u is not in the listening state.
54 |
56 |
60 | ERDVNOSERV
57 | 5007
58 | u is set up to support rendezvous connection.
59 |
61 |
65 | EASYNCRCV
62 | 6002
63 | u is non-blocking (UDT_RCVSYN = false) but there is no connection available.
64 | Description
68 | See Also
75 | bind
13 |
17 | UDTSOCKET u,
18 | struct sockaddr* name,
19 | int* namelen
20 | );
21 |
22 | int bind(
23 | #ifndef WIN32
24 | int udpsock
25 | #else
26 | SOCKET udpsock
27 | #endif
28 | );
29 | Parameters
32 |
33 |
42 |
43 | Return Value
44 |
48 |
69 |
70 |
49 |
53 | Error Name
50 | Error Code
51 | Comment
52 |
54 |
58 | EBOUNDSOCK
55 | 5001
56 | u has already been bound to certain address.
57 |
59 |
63 | EINVPARAM
60 | 5003
61 | the address is either invalid or unavailable.
62 |
64 |
68 | EINVSOCK
65 | 5004
66 | u is an invalid UDT socket.
67 | Description
71 | See Also
84 | cleanup
13 |
16 | );Parameters
19 |
20 |
22 |
23 | Return Value
24 | Description
27 | See Also
30 |
31 | close
13 |
16 | UDTSOCKET u
17 | );Parameters
20 |
21 |
24 |
25 | Return Value
26 |
29 |
40 |
41 |
30 |
34 | Error Name
31 | Error Code
32 | Comment
33 |
35 |
39 | EINVSOCK
36 | 5004
37 | u is an invalid UDT socket.
38 | Description
42 | See Also
51 |
52 | connect
13 |
16 | UDTSOCKET u,
17 | const struct sockaddr* name,
18 | int* namelen
19 | );Parameters
22 |
23 |
30 |
31 | Return Value
32 |
35 |
71 |
72 |
36 |
40 | Error Name
37 | Error Code
38 | Comment
39 |
41 |
45 | ENOSERVER
42 | 1001
43 | server or peer socket does not exist, or there is no network connection.
44 |
46 |
50 | ECONNREJ
47 | 1002
48 | the connection request was rejected by the peer.
49 |
51 |
55 | ESECFAIL
52 | 1004
53 | connection was aborted due to possible attacks.
54 |
56 |
60 | 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 |
61 |
65 | EINVSOCK
62 | 5004
63 | u is not a valid socket ID.
64 |
66 |
70 | ERDVUNBOUND
67 | 5008
68 | the rendezvous mode has been enable, but bind was not called before connect.
69 | Description
73 | See Also
82 |
83 |
13 | All rights reserved.
18 |
24 |
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 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/udt/udt4/doc/doc/error.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | getlasterror
13 |
16 | );Parameters
19 |
20 |
22 |
23 | Return Value
24 | Description
28 | See Also
31 |
11 | Copyright © 2001 - 2011 Yunhong Gu. All rights reserved.
12 | Last modified: Tuesday, February 8, 2011 1:10 PM.
13 |
14 |
15 |
--------------------------------------------------------------------------------
/udt/udt4/doc/doc/function.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UDT Socket Functions
13 |
14 |
17 |
110 |
111 |
18 |
21 | Method
19 | Fuctionality
20 |
22 |
25 | accept
23 | accept a connection.
24 |
26 |
29 | bind
27 | assign a local name to an unnamed udt socket.
28 |
30 |
33 | cleanup
31 | release the complete UDT library.
32 |
34 |
37 | close
35 | close the opened UDT entity and shutdown the connection.
36 |
38 |
41 | connect
39 | connect to the server or the peer side.
40 |
42 |
45 | epoll
43 | watch for a group of UDT and system sockets for IO events.
44 |
46 |
49 | getlasterror
47 | retrieve last UDT error in the current thread.
48 |
50 |
53 | getpeername
51 | read the address of the peer side of the connection
52 |
54 |
57 | getsockname
55 | read the local address of the UDT socket.
56 |
58 |
61 | getsockopt
59 | read UDT options.
60 |
62 |
65 | listen
63 | enable UDT into listening state and is ready for connection request.
64 |
66 |
69 | perfmon
67 | monitor internal protocol parameters and udt performance.
68 |
70 |
73 | recv
71 | receive data.
72 |
74 |
77 | recvfile
75 | receive data into a file.
76 |
78 |
81 | recvmsg
79 | receive a message.
80 |
82 |
85 | select
83 | wait for a number of UDT sockets to change status.
84 |
86 |
89 | send
87 | send data.
88 |
90 |
93 | sendfile
91 | send a file.
92 |
94 |
97 | sendmsg
95 | send a message.
96 |
98 |
101 | setsockopt
99 | configure UDT options.
100 |
102 |
105 | socket
103 | create a new UDT socket.
104 |
106 |
109 | startup
107 | initialize the UDT library.
108 | See Also
112 |
113 |
114 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/udt/udt4/doc/doc/intro.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UDT: UDP-based Data Transfer Library - version 4
11 |
12 |
13 |
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
28 |
34 | listen
13 |
16 | UDTSOCKET u
17 | int backlog
18 | );Parameters
21 |
22 |
27 |
28 | Return Value
29 |
32 |
58 |
59 |
33 |
37 | Error Name
34 | Error Code
35 | Comment
36 |
38 |
42 | ECONNSOCK
39 | 5002
40 | u is already connected.
41 |
43 |
47 | EINVSOCK
44 | 5004
45 | u is an invalid socket.
46 |
48 |
52 | EUNBOUNDSOCK
49 | 5005
50 | u is not bound.
51 |
53 |
57 | ERDVNOSERV
54 | 5007
55 | u is in rendezvous mode.
56 | Description
60 | See Also
65 |
66 | Installation Guide
17 |
22 | ./app: Example applications
23 | ./doc: UDT documentation
24 | ./win: Visual C++ project files for Windows version of UDT
The available options for hardware architecture are: IA32, IA64, POWERPC, and AMD64.
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/udt4/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/udt4/doc/doc/recv.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
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 |
ETIMEOUT | 71 |6003 | 72 |Timeout on UDT_RCVTIMEO . | 73 |
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 78 | 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.
79 |In blocking mode (default), recv waits until there is some data received into the receiver buffer. In non-blocking mode, recv returns immediately and 80 | returns error if no data available.
81 |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 82 | the timer expires, error will be returned. UDT_RCVTIMEO has no effect for non-blocking socket.
83 | 84 |87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /udt/udt4/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/udt4/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 |
ETIMEOUT | 68 |6003 | 69 |Timeout on UDT_RCVTIMEO . | 70 |
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 75 | 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 76 | 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, 77 | but the message will still be discarded after this recvmsg call.
78 |In blocking mode (default), recvmsg waits until there is a valid message received into the receiver buffer. In non-blocking mode, 79 | recvmsg returns immediately and returns error if no message available.
80 |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 81 | no message available when the timer expires, error will be returned. UDT_RCVTIMEO has no effect for non-blocking socket.
82 | 83 |86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /udt/udt4/doc/doc/reference.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
This section describes in detail the UDT API, including:
12 | 13 |20 | 21 | 22 | -------------------------------------------------------------------------------- /udt/udt4/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 | -------------------------------------------------------------------------------- /udt/udt4/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/udt4/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 |
ETIMEOUT | 71 |6003 | 72 |Timeout on UDT_SNDTIMEO . | 73 |
EPEERERR | 76 |7000 | 77 |The peer side has an unrecoverable error and this call has to be cancelled. | 78 |
The send method sends certain amount of data from the application buffer. If the the size limit of sending buffer queue is reached, 83 | send only sends a portion of the application buffer and returns the actual size of data that has been sent.
84 |In blocking mode (default), send waits until there is some sending buffer space available. In non-blocking mode, send 85 | returns immediately and returns error if the sending queue limit is already limited.
86 |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 87 | buffer space available when the timer expires, error will be returned. UDT_SNDTIMEO has no effect for non-blocking socket.
88 | 89 |92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /udt/udt4/doc/doc/sendfile.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
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/udt4/doc/doc/socket.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
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/udt4/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/udt4/doc/doc/startup.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
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/udt4/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 | -------------------------------------------------------------------------------- /udt/udt4/doc/doc/t-config.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
Options of UDT are read and set through getsockopt and setsockopt methods. Before modifying any option, bear in mind that it is NOT required that you modify the default options. If the application has sound performance with the default options, just use the default configurations.
14 | 15 |UDT_MSS is used to configure the packet size. In most situations, the optimal UDT packet size is the network MTU size. The default value is 1500 bytes. A UDT connection will choose the 16 | smaller value of the MSS between the two peer sides. For example, if you want to set 9000-byte MSS, you have to set this option at both sides, and one of the value has to be exactly equal to 17 | 9000, and the other must not be less than 9000.
18 | 19 |UDT uses a different semantics of synchronization mode from traditional sockets. It can set the sending and receiving synchronization independently, which allows more flexibility. 20 | However, UDT does not allow non-blocking operation on connection setup and close. The sychronization mode of sending and receiving can be set on UDT_SNDSYN and UDT_RCVSYN, respectively.
21 | 22 |The UDT buffer size is (UDT_SNDBUF and UDT_RCVBUF) used to limit the size of temporary storage of sending/receiving data. The buffer size is only a limit and memory is allocated upon necessary. Generally, larger 23 | buffer (but not so large that the physical memory is used up) is better. For good performance the the buffer sizes for both sides should be at least Bandwidth*RTT.
24 | 25 |UDT uses UDP as the data channel, so the UDP buffer size affects the performance. Again, a larger value is generally better, but the effects become smaller and disappear as the buffer 26 | size increases. Generally, the sending buffer size can be a small value, because it does not limit the packet sending much but a large value may increase the end-to-end delay.
27 | 28 |UDT_FC is actually an internal parameter and you should set it to not less than UDT_RCVBUF/UDT_MSS. The default value is relatively large, therefore unless you set a very large 29 | receiver buffer, you do not need to change this option.
30 | 31 |UDT_LINGER is similar to the SO_LINGER option on the regular sockets. It allows the UDT socket continue to sent out data in the sending buffer when close is called.
32 | 33 |UDT_RENDEZVOUS is used to enable rendezvous connection setup. When rendezvous mode is enabled, a UDT socket cannot call listen or accept; instead, in order to set up a rendezvous 34 | connection, both the peer sides must call connect at approximately the same time. This is useful in traversing a firewall.
35 | 36 |UDT_SNDTIMEO and UDT_RCVTIMEO are similar to SO_SNDTIMEO and SO_RCVTIMEO, respectively. They are used to set a timeout value for packet sending and receiving.
37 |UDT_REUSEADDR allows applications to decide whether to share a UDP port with other UDT connections. By default this option is true, which means all UDT connections that are bind to 0 will try to reuse any existing UDP socket. In addition, multiple UDT connections can bind to the same port number other than 0. If UDT_REUSEADDR is set to false, an exclusive UDP port will be assign to this UDT socket. There are a few situations when UDT_REUSEADDR should be set to false. First, two UDT sockets cannot listen on the same port number, so either the second UDT socket is explicitly bound to a different port, or UDT_REUSEADDR is set to false for this UDT socket. Second, a UDT socket bound to a specific port number cannot connect to the other UDT socket bound to the same port on the same IP address.
38 |Example: read current UDT settings
39 |Example: modify UDT settings
51 |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/udt4/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/udt4/doc/doc/t-file.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
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/udt4/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/udt4/doc/doc/t-hello.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
In 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/udt4/doc/doc/t-intro.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
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 | -------------------------------------------------------------------------------- /udt/udt4/doc/doc/t-msg.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
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 | -------------------------------------------------------------------------------- /udt/udt4/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/udt4/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/udt4/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 | -------------------------------------------------------------------------------- /udt/udt4/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/udt4/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/udt4/doc/hlp/ix_book.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_book.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_down.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_down.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_end.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_endm.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_endm.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_endp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_endp.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_leaf.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_leaf.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_line.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_link.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_link.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_list.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_list.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_listm.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_listm.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_listp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_listp.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_open.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_space.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_space.gif -------------------------------------------------------------------------------- /udt/udt4/doc/hlp/ix_up.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverlessunicorn/ServerlessNetworkingClients/a3be34d3b3791a95ae041f3c6aca37e1bf8c6b02/udt/udt4/doc/hlp/ix_up.gif -------------------------------------------------------------------------------- /udt/udt4/doc/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |