From 6fa60be75ccaebadc0c4dcc4ea16d4fed3f34502 Mon Sep 17 00:00:00 2001 From: Sam Kumar Date: Fri, 6 Aug 2021 22:04:31 -0700 Subject: [PATCH] [tcp] add third_party module for TCPlp (#6885) This commit creates a module in third_party for TCPlp code. It is a placeholder for now; the actual code will be added in future commits. --- configure.ac | 1 + examples/apps/cli/Makefile.am | 1 + examples/apps/ncp/Makefile.am | 1 + src/posix/Makefile.am | 1 + tests/fuzz/Makefile.am | 1 + tests/unit/Makefile.am | 2 +- third_party/CMakeLists.txt | 2 + third_party/Makefile.am | 2 + third_party/tcplp/CMakeLists.txt | 46 +++++++++++++++++++++ third_party/tcplp/Makefile.am | 68 ++++++++++++++++++++++++++++++++ third_party/tcplp/README.md | 33 ++++++++++++++++ third_party/tcplp/tcplp.c | 0 third_party/tcplp/tcplp.h | 0 13 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 third_party/tcplp/CMakeLists.txt create mode 100644 third_party/tcplp/Makefile.am create mode 100644 third_party/tcplp/README.md create mode 100644 third_party/tcplp/tcplp.c create mode 100644 third_party/tcplp/tcplp.h diff --git a/configure.ac b/configure.ac index 41983a512..8e9530452 100644 --- a/configure.ac +++ b/configure.ac @@ -1007,6 +1007,7 @@ src/lib/url/Makefile third_party/Makefile third_party/jlink/Makefile third_party/mbedtls/Makefile +third_party/tcplp/Makefile examples/Makefile examples/apps/Makefile examples/apps/cli/Makefile diff --git a/examples/apps/cli/Makefile.am b/examples/apps/cli/Makefile.am index f5ba445b5..a20a28bc3 100644 --- a/examples/apps/cli/Makefile.am +++ b/examples/apps/cli/Makefile.am @@ -40,6 +40,7 @@ CPPFLAGS_COMMON += \ $(NULL) LDADD_COMMON += \ + $(top_builddir)/third_party/tcplp/libtcplp.a \ $(NULL) LDFLAGS_COMMON += \ diff --git a/examples/apps/ncp/Makefile.am b/examples/apps/ncp/Makefile.am index 9cf17e43e..3763eefe2 100644 --- a/examples/apps/ncp/Makefile.am +++ b/examples/apps/ncp/Makefile.am @@ -40,6 +40,7 @@ CPPFLAGS_COMMON += \ $(NULL) LDADD_COMMON += \ + $(top_builddir)/third_party/tcplp/libtcplp.a \ $(NULL) LDFLAGS_COMMON += \ diff --git a/src/posix/Makefile.am b/src/posix/Makefile.am index f71fb9140..3844ea1f3 100644 --- a/src/posix/Makefile.am +++ b/src/posix/Makefile.am @@ -57,6 +57,7 @@ LIBTOOLFLAGS_COMMON = --preserve-dup-deps LDADD_COMMON = \ $(top_builddir)/src/posix/platform/libopenthread-posix.a \ -lutil \ + $(top_builddir)/third_party/tcplp/libtcplp.a \ $(NULL) if OPENTHREAD_TARGET_LINUX diff --git a/tests/fuzz/Makefile.am b/tests/fuzz/Makefile.am index cfdac597f..a0c4384b4 100644 --- a/tests/fuzz/Makefile.am +++ b/tests/fuzz/Makefile.am @@ -43,6 +43,7 @@ AM_CPPFLAGS = \ COMMON_LDADD = \ $(top_builddir)/src/core/libopenthread-ftd.a \ $(top_builddir)/third_party/mbedtls/libmbedcrypto.a \ + $(top_builddir)/third_party/tcplp/libtcplp.a \ $(LIB_FUZZING_ENGINE) \ $(NULL) diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 62e85a496..277343f0e 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -73,6 +73,7 @@ AM_CPPFLAGS += \ endif COMMON_LDADD = \ + $(top_builddir)/third_party/tcplp/libtcplp.a \ $(NULL) if OPENTHREAD_ENABLE_NCP @@ -296,4 +297,3 @@ endif # OPENTHREAD_BUILD_COVERAGE endif # OPENTHREAD_BUILD_TESTS include $(abs_top_nlbuild_autotools_dir)/automake/post.am - diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 365623c24..d57660fe6 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -29,3 +29,5 @@ if(NOT OT_EXTERNAL_MBEDTLS) add_subdirectory(mbedtls) endif() + +add_subdirectory(tcplp) diff --git a/third_party/Makefile.am b/third_party/Makefile.am index 1410a6a10..5e374316d 100644 --- a/third_party/Makefile.am +++ b/third_party/Makefile.am @@ -38,9 +38,11 @@ EXTRA_DIST = \ DIST_SUBDIRS = \ jlink \ mbedtls \ + tcplp \ $(NULL) SUBDIRS = \ + tcplp \ $(NULL) if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS diff --git a/third_party/tcplp/CMakeLists.txt b/third_party/tcplp/CMakeLists.txt new file mode 100644 index 000000000..ad34b1184 --- /dev/null +++ b/third_party/tcplp/CMakeLists.txt @@ -0,0 +1,46 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +project("TCPlp" C) + +set(src_tcplp + tcplp.c +) + +set(tcplp_static_target "tcplp") + +add_library(${tcplp_static_target} STATIC ${src_tcplp}) +set_target_properties(${tcplp_static_target} PROPERTIES OUTPUT_NAME tcplp) +target_include_directories(${tcplp_static_target} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/bsdtcp + ${CMAKE_CURRENT_SOURCE_DIR}/lib + PRIVATE + ${OT_PUBLIC_INCLUDES} + $ +) diff --git a/third_party/tcplp/Makefile.am b/third_party/tcplp/Makefile.am new file mode 100644 index 000000000..c5beca454 --- /dev/null +++ b/third_party/tcplp/Makefile.am @@ -0,0 +1,68 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include $(abs_top_nlbuild_autotools_dir)/automake/pre.am + +EXTRA_DIST = \ + tcplp.h \ + $(NULL) + +lib_LIBRARIES = \ + libtcplp.a \ + $(NULL) + +# Do not enable -Wsign-compare for TCPlp +override CFLAGS := $(filter-out -Wsign-compare,$(CFLAGS)) +override CFLAGS := $(CFLAGS) -Wno-sign-compare + +# Do not enable -Wunused-parameter for TCPlp +override CFLAGS := $(filter-out -Wunused-parameter,$(CFLAGS)) +override CFLAGS := $(CFLAGS) -Wno-unused-parameter + +# Do not enable -Waddress-of-packed-member for TCPlp +override CFLAGS := $(filter-out -Waddress-of-packed-member,$(CFLAGS)) +override CFLAGS := $(CFLAGS) -Wno-address-of-packed-member + +# Do not enable -pedantic-errors for TCPlp +override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) + +TCPLP_SRCDIR = $(top_srcdir)/third_party/tcplp + +libtcplp_a_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/core \ + -I$(TCPLP_SRCDIR)/bsdtcp \ + -I$(TCPLP_SRCDIR)/lib \ + $(TCPLP_CPPFLAGS) \ + $(NULL) + +libtcplp_a_SOURCES = \ + tcplp.c + $(NULL) + +include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/third_party/tcplp/README.md b/third_party/tcplp/README.md new file mode 100644 index 000000000..d67aa5054 --- /dev/null +++ b/third_party/tcplp/README.md @@ -0,0 +1,33 @@ +# TCPlp + +This module will contain a port of TCPlp for OpenThread. Currently, it only +contains part of the implementation; the rest will be added in future pull +requests. + +## URL + +Based on https://github.com/ucbrise/tcplp. + +## License + +BSD 3-Clause + +TCPlp is derived from the TCP stack in the FreeBSD Operating System. Files +taken from FreeBSD retain their original copyright notices and licenses (which +are BSD-like licenses). New code contributed as part of TCPlp is provided +under the BSD 3-Clause License. + +## Description + +TCPlp is a full-scale TCP stack for low-power wireless networks and +resource-constrained embedded systems. It is designed to support performant and +efficient TCP operation over IEEE 802.15.4 networks. It is based on the TCP +stack in the FreeBSD operating system. + +TCPlp is a software artifact that accompanies an NSDI 2020 paper: + +Sam Kumar, Michael P Andersen, Hyung-Sin Kim, and David E. Culler. Performant TCP for Low-Power Wireless Networks. NSDI 2020. + +The paper is available at the following locations: +* https://www.usenix.org/conference/nsdi20/presentation/kumar +* https://arxiv.org/abs/1811.02721 diff --git a/third_party/tcplp/tcplp.c b/third_party/tcplp/tcplp.c new file mode 100644 index 000000000..e69de29bb diff --git a/third_party/tcplp/tcplp.h b/third_party/tcplp/tcplp.h new file mode 100644 index 000000000..e69de29bb