9191start 1
9292count 5
9393src_delta 2000
94- tools sendip nc bash
94+ tools sendip socat nc bash
9595proto udp
9696
9797race_repeat 3
116116start 10
117117count 5
118118src_delta 2000
119- tools sendip nc bash
119+ tools sendip socat nc bash
120120proto udp6
121121
122122race_repeat 3
141141start 1
142142count 5
143143src_delta 2000
144- tools sendip nc bash
144+ tools sendip socat nc bash
145145proto udp
146146
147147race_repeat 0
@@ -163,7 +163,7 @@ src mac
163163start 10
164164count 5
165165src_delta 2000
166- tools sendip nc bash
166+ tools sendip socat nc bash
167167proto udp6
168168
169169race_repeat 0
@@ -185,7 +185,7 @@ src mac proto
185185start 10
186186count 5
187187src_delta 2000
188- tools sendip nc bash
188+ tools sendip socat nc bash
189189proto udp6
190190
191191race_repeat 0
@@ -207,7 +207,7 @@ src addr4
207207start 1
208208count 5
209209src_delta 2000
210- tools sendip nc bash
210+ tools sendip socat nc bash
211211proto udp
212212
213213race_repeat 3
@@ -227,7 +227,7 @@ src addr6 port
227227start 10
228228count 5
229229src_delta 2000
230- tools sendip nc
230+ tools sendip socat nc
231231proto udp6
232232
233233race_repeat 3
@@ -247,7 +247,7 @@ src mac proto addr4
247247start 1
248248count 5
249249src_delta 2000
250- tools sendip nc bash
250+ tools sendip socat nc bash
251251proto udp
252252
253253race_repeat 0
@@ -264,7 +264,7 @@ src mac
264264start 1
265265count 5
266266src_delta 2000
267- tools sendip nc bash
267+ tools sendip socat nc bash
268268proto udp
269269
270270race_repeat 0
@@ -286,7 +286,7 @@ src mac addr4
286286start 1
287287count 5
288288src_delta 2000
289- tools sendip nc bash
289+ tools sendip socat nc bash
290290proto udp
291291
292292race_repeat 0
@@ -337,7 +337,7 @@ src addr4
337337start 1
338338count 5
339339src_delta 2000
340- tools sendip nc
340+ tools sendip socat nc
341341proto udp
342342
343343race_repeat 3
@@ -363,7 +363,7 @@ src mac
363363start 1
364364count 1
365365src_delta 2000
366- tools sendip nc bash
366+ tools sendip socat nc bash
367367proto udp
368368
369369race_repeat 0
@@ -541,6 +541,24 @@ setup_send_udp() {
541541 dst_port=
542542 src_addr4=
543543 }
544+ elif command -v socat -v > /dev/null; then
545+ send_udp () {
546+ if [ -n " ${src_addr4} " ]; then
547+ B ip addr add " ${src_addr4} " dev veth_b
548+ __socatbind=" ,bind=${src_addr4} "
549+ if [ -n " ${src_port} " ]; then
550+ __socatbind=" ${__socatbind} :${src_port} "
551+ fi
552+ fi
553+
554+ ip addr add " ${dst_addr4} " dev veth_a 2> /dev/null
555+ [ -z " ${dst_port} " ] && dst_port=12345
556+
557+ echo " test4" | B socat -t 0.01 STDIN UDP4-DATAGRAM:${dst_addr4} :${dst_port} " ${__socatbind} "
558+
559+ src_addr4=
560+ src_port=
561+ }
544562 elif command -v nc > /dev/null; then
545563 if nc -u -w0 1.1.1.1 1 2> /dev/null; then
546564 # OpenBSD netcat
@@ -606,6 +624,29 @@ setup_send_udp6() {
606624 dst_port=
607625 src_addr6=
608626 }
627+ elif command -v socat -v > /dev/null; then
628+ send_udp6 () {
629+ ip -6 addr add " ${dst_addr6} " dev veth_a nodad \
630+ 2> /dev/null
631+
632+ __socatbind6=
633+
634+ if [ -n " ${src_addr6} " ]; then
635+ if [ -n " ${src_addr6} != " ${src_addr6_added} ]; then
636+ B ip addr add " ${src_addr6} " dev veth_b nodad
637+
638+ src_addr6_added=${src_addr6}
639+ fi
640+
641+ __socatbind6=" ,bind=[${src_addr6} ]"
642+
643+ if [ -n " ${src_port} " ] ; then
644+ __socatbind6=" ${__socatbind6} :${src_port} "
645+ fi
646+ fi
647+
648+ echo " test6" | B socat -t 0.01 STDIN UDP6-DATAGRAM:[${dst_addr6} ]:${dst_port} " ${__socatbind6} "
649+ }
609650 elif command -v nc > /dev/null && nc -u -w0 1.1.1.1 1 2> /dev/null; then
610651 # GNU netcat might not work with IPv6, try next tool
611652 send_udp6 () {
0 commit comments