- Notifications
You must be signed in to change notification settings - Fork6
A transmission protocol implementation based on UDP, inspired by libutp
License
CalvinNeo/ATP
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ATP is a message-oriented reliable transport protocol implementation.
- ATP provides reliable transportation of data as well as a series of TCP's features.
- ATP has a small sized head.
- ATP allows time critical data transmission by urgent mechanism and clock drift probing.
- ATP allows multiple connections established over the same port.
- ATP has a lightweight connecting/disconnecting mechanism. You can "fork" an established connection in ATP without extra 3-way handshake. You will endure shorter TIME_WAIT stage than TCP.
- ATP provides a framework as well as a service.
- C++17 standard(e.g. g++7.2)
Make the project by command
make lib
Run test on demos by command
make run_test
All APIs are available in/src/atp.h, and is compatible with C89
When ATP is used as a framework, it provides with a flexible underlying control. In this case, You must handle incoming UDP packets and maintain a timer outside the ATP framework. You must interact with the ATP context through two APIs:
atp_process_udp
When there's an incoming UDP packet, you must inform ATP context to parse the raw UDP packet by callingatp_process_udp
, the context will then dispatch the packets to correct ATP sockets.atp_timer_event
You must also maintain a timer, and callatp_timer_event
to generate timer signals for the context.
ASAF is not thread safe.
Most of these demos use healperatp_standalone_
APIs provided in/src/atp_standalone.h. These APIs help you from coding the connect/disconnect procedure yourself.
You can build all following tests by
make demos
sendfile/recvfile
The demo includes two separated programs: the sender and the receiver. A File will be sent from the sender to the receiver. In this demo, both sides set their UDP Socket to be nonblock, because there will be no multi-threading or multiplexing.You can set loss rate by modifying function
simulate_packet_loss_sendto
in/src/atp_callback.cpp.Build this demo by
make test TARGET=demo_file
send/recv
This demo is similar to sendfile/recvfile, instead of sending file, send/recv use stdin/stdout now. You can run with argument
-s
to simulate a ATPPacket by commands with certain format. This demo provides a convenient test method.Build this demo bymake test TARGET=demo_cmd
send_poll
This demo implements the sendfile's part with
poll
.Build this demo by
make test TARGET=demo_poll
send_aio
This demo implements the sendfile's part with aio.
Build this demo by
make test TARGET=send_aio
The whole project is opened under GNU GENERAL PUBLIC LICENSE Version 2.
GNU GENERAL PUBLIC LICENSE Version 2, June 1991Calvin NeoCopyright (C) 2017 Calvin NeoThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public License alongwith this program; if not, write to the Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.