├── .gitignore ├── Makefile ├── CMakeLists.txt ├── README ├── LICENSE └── seqtest.c /.gitignore: -------------------------------------------------------------------------------- 1 | seqtest 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # This is a Makefile - it works worth GNUmake on Linux, Solaris, and illumos. 2 | # Use of cmake instaed is recommended, but if you lack cmake, this can help. 3 | # To use legacy (non-GNU) make, do "make UNAME=`uname`" 4 | 5 | UNAME =$(shell uname) 6 | 7 | CFLAGS_COMMON =-std=gnu99 -Wall -Werror 8 | CFLAGS_Linux =-D _GNU_SOURCE -D _XOPEN_SOURCE=700 9 | CFLAGS_SunOS =-D __EXTENSIONS__ -D _XOPEN_SOURCE=600 10 | CFLAGS +=$(CFLAGS_COMMON) $(CFLAGS_$(UNAME)) 11 | 12 | LDFLAGS_Linux =-lrt -lm 13 | LDFLAGS_SunOS =-lnsl -lsocket -lm -lrt -lpthread 14 | LDFLAGS +=$(LDFLAGS_$(UNAME)) 15 | 16 | all: seqtest 17 | 18 | seqtest: seqtest.c 19 | $(CC) $(CFLAGS) seqtest.c -o $@ $(LDFLAGS) 20 | 21 | clean: 22 | $(RM) seqtest 23 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016 Lucera Financial Infrastructures, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use file except in compliance with the License. 6 | # You may obtain a copy of the license at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # This program is used to stress test TCP connections, verifying that 16 | # ordering constraints are preserved across a connection. The intent 17 | # is to validate correct function of a TCP proxy. 18 | # 19 | 20 | cmake_minimum_required(VERSION 2.8) 21 | 22 | project(seqtest C) 23 | 24 | include(CheckLibraryExists) 25 | include(CheckFunctionExists) 26 | 27 | add_executable(seqtest seqtest.c) 28 | 29 | check_library_exists(socket getaddrinfo "" HAVE_LIBSOCKET) 30 | if (HAVE_LIBSOCKET) 31 | target_link_libraries(seqtest socket) 32 | LIST(APPEND CMAKE_REQUIRED_LIBRARIES socket) 33 | endif (HAVE_LIBSOCKET) 34 | 35 | check_library_exists(nsl gethostbyname "" HAVE_LIBNSL) 36 | if (HAVE_LIBNSL) 37 | target_link_libraries(seqtest nsl) 38 | LIST(APPEND CMAKE_REQUIRED_LIBRARIES nsl) 39 | endif (HAVE_LIBNSL) 40 | 41 | check_library_exists(rt clock_gettime "" HAVE_LIBRT) 42 | if (HAVE_LIBRT) 43 | target_link_libraries(seqtest rt) 44 | LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) 45 | endif (HAVE_LIBRT) 46 | 47 | check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD) 48 | if (HAVE_LIBPTHREAD) 49 | target_link_libraries(seqtest pthread) 50 | LIST(APPEND CMAKE_REQUIRED_LIBRARIES pthread) 51 | endif (HAVE_LIBPTHREAD) 52 | 53 | check_library_exists(m sqrt "" HAVE_LIBM) 54 | if (HAVE_LIBM) 55 | target_link_libraries(seqtest m) 56 | LIST(APPEND CMAKE_REQUIRED_LIBRARIES m) 57 | endif (HAVE_LIBM) 58 | 59 | check_function_exists(strlcpy HAVE_STRLCPY) 60 | if (HAVE_STRLCPY) 61 | add_definitions(-DHAVE_STRLCPY) 62 | endif (HAVE_STRLCPY) 63 | 64 | check_function_exists(gethrtime HAVE_GETHRTIME) 65 | if (HAVE_GETHRTIME) 66 | add_definitions(-DHAVE_GETHRTIME) 67 | endif (HAVE_GETHRTIME) 68 | 69 | check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) 70 | if (HAVE_CLOCK_GETTIME) 71 | add_definitions(-DHAVE_CLOCK_GETTIME) 72 | endif (HAVE_CLOCK_GETTIME) 73 | 74 | check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) 75 | if (HAVE_GETTIMEOFDAY) 76 | add_definitions(-DHAVE_GETTIMEOFDAY) 77 | endif (HAVE_GETTIMEOFDAY) 78 | 79 | install(TARGETS seqtest DESTINATION bin) 80 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | seqtest -- test TCP under load 2 | 3 | seqtest is a program that is designed to verify correct end-to-end TCP 4 | operation. It can also do some limited performance measurement. The biggest 5 | advantage it has over alternative programs is that it allows one to alter 6 | the traffic patterns and inject an element of randomness. This can be used 7 | to help uncover race conditions and other difficult-to-reproduce bugs. 8 | 9 | When run with a fixed number of iterations (see the count option below), and 10 | with replies, it will report the round trip latency between each message sent, 11 | and when its reply is received. 12 | 13 | It runs in three modes: 14 | 15 | * sender mode. In this mode seqtest sends a stream of packets, at some 16 | (randomized, possibly zero) interval to the replier. It also runs a thread 17 | to wait for replies from the replier, and verifies that messages are 18 | delivered in order. Most of the customization is done when running the 19 | sender side. 20 | 21 | * synchoronous sender mode. THis mode is just like sender mode, except that 22 | each thread waits for the reply before sending the next message. This is 23 | a better measurement of latency. 24 | 25 | * replier mode. In this mode, seqtest accepts incoming TCP connections, 26 | analyzes them for correctness (in order delivery, etc.) and optionally 27 | sends a reply. The size of the reply can vary, as well as the frequency 28 | with which replies are made. A random delay can also be inserted before 29 | sending the reply. 30 | 31 | 32 | In sender mode, the synopsis is as follows: 33 | 34 | seqtest -s [-d] [-o