Skip to content

Commit

Permalink
Implement sending multicast UDP packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluhm committed Jan 1, 2025
1 parent 23343c8 commit 485752c
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 27 deletions.
42 changes: 35 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,71 @@ udpbench-${VERSION}.tar.gz:

CLEANFILES+= out

.PHONY: test test-localhost test-localhost6 test-mmsg test-repeat
test: test-localhost test-localhost6 test-mmsg test-repeat

TEST =
TEST += localhost
test-localhost:
@echo '\n==== $@ ===='
./udpbench -p0 -t3 recv 127.0.0.1 >out & \
./udpbench -p0 -t3 recv 127.0.0.1 | tee out & \
sleep 1; \
port=`awk '/^sockname:/{print $$3}' out`; \
./udpbench -p$$port -t1 send 127.0.0.1 || exit 1; \
wait $$!
grep '^recv:' out

TEST += localhost6
test-localhost6:
@echo '\n==== $@ ===='
./udpbench -p0 -t3 recv ::1 >out & \
./udpbench -p0 -t3 recv ::1 | tee out & \
sleep 1; \
port=`awk '/^sockname:/{print $$3}' out`; \
./udpbench -p$$port -t1 send ::1 || exit 1; \
wait $$!
grep '^recv:' out

TEST += mmsg
test-mmsg:
@echo '\n==== $@ ===='
./udpbench -m1024 -p0 -t3 recv 127.0.0.1 >out & \
./udpbench -m1024 -p0 -t3 recv 127.0.0.1 | tee out & \
sleep 1; \
port=`awk '/^sockname:/{print $$3}' out`; \
./udpbench -m1024 -p$$port -t1 send 127.0.0.1 || exit 1; \
wait $$!
grep '^recv:' out

TEST += repeat
test-repeat:
@echo '\n==== $@ ===='
./udpbench -N1 -p0 -t3 recv 127.0.0.1 >out & \
./udpbench -N1 -p0 -t3 recv 127.0.0.1 | tee out & \
sleep 1; \
port=`awk '/^sockname:/{print $$3}' out`; \
./udpbench -N1 -p$$port -t1 send 127.0.0.1 || exit 1; \
wait $$!
grep '^recv:' out

TEST += mcast
test-mcast:
@echo '\n==== $@ ===='
./udpbench -I127.0.0.1 -p0 -t3 recv 224.0.0.123 | tee out & \
sleep 1; \
port=`awk '/^sockname:/{print $$3}' out`; \
./udpbench -I127.0.0.1 -L1 -T0 -p$$port -t1 \
send 224.0.0.123 || exit 1; \
wait $$!
grep -q 'sockname: 224.0.0.123 ' out

TEST += mcast-repeat
test-mcast-repeat:
@echo '\n==== $@ ===='
./udpbench -N2 -I127.0.0.1 -p0 -t3 recv 224.0.0.123 | tee out & \
sleep 1; \
port=`awk '/^sockname:/{print $$3}' out | sort -u`; \
./udpbench -N2 -I127.0.0.1 -L1 -T0 -p$$port -t1 \
send 224.0.0.123 || exit 1; \
wait $$!
grep -q 'sockname: 224.0.0.123 ' out
grep -q 'sockname: 224.0.0.124 ' out

.PHONY: ${TEST:S/^/test-/}
test: ${TEST:S/^/test-/}

.include <bsd.prog.mk>
Loading

0 comments on commit 485752c

Please sign in to comment.