Skip to content

Conversation

@liam-mcb
Copy link

Following on from the discussion in #1982.

Added options to set the ToS/DSCP of the control connection.
This helps prevent the control connection from dropping when testing low-capacity networks.
It was suggested in the discussion thread that this option should be added to the existing --tos option with a slash separator.
I decided against that because the control ToS option is available to both the client and server.

@jake-rus
Copy link

jake-rus commented Jan 11, 2026

I checked, but for some reason with each test I capture two packets with TOS=0.
Without specifying the TOS, we get 14 packets with TOS=0. That is, two packets remain unmarked with the custom TOS we need.

host2:mgmt:~$ ip vrf exec default sudo iperf3 -s --control-tos 224 -p 40256  -D
host1:mgmt:~$ ip vrf exec default sudo iperf3 -c 5.0.0.2 -p 40256 -t 10 --tos 128 -i 0.1 -b 200M  --control-tos 224

This is with TOS=0

host2:mgmt:~$ sudo tcpdump -i swp1 -envvv 'ip[1] = 0 and (dst port 40256)'
tcpdump: listening on swp1, link-type EN10MB (Ethernet), capture size 262144 bytes
06:14:12.255604 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 74: (tos 0x0, ttl 64, id 8532, offset 0, flags [DF], proto TCP (6), length 60)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [S], cksum 0x7255 (correct), seq 2722782240, win 62720, options [mss 8960,sackOK,TS val 1672341852 ecr 0,nop,wscale 8], length 0
06:14:12.256869 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 8533, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [.], cksum 0xb8f4 (correct), ack 3336944208, win 245, options [nop,nop,TS val 1672341854 ecr 1071986776], length 0
^C
2 packets captured
2 packets received by filter
0 packets dropped by kernel

This is with TOS=224

host2:mgmt:~$ sudo tcpdump -i swp1 -env 'ip[1] = 224 and (dst port 40256)'
tcpdump: listening on swp1, link-type EN10MB (Ethernet), capture size 262144 bytes
06:14:12.257014 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 103: (tos 0xe0, ttl 64, id 8534, offset 0, flags [DF], proto TCP (6), length 89)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [P.], cksum 0x29db (correct), seq 2722782241:2722782278, ack 3336944208, win 245, options [nop,nop,TS val 1672341854 ecr 1071986776], length 37
06:14:12.258028 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0xe0, ttl 64, id 8535, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [.], cksum 0xb8cc (correct), ack 2, win 245, options [nop,nop,TS val 1672341855 ecr 1071986777], length 0
06:14:12.258075 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 70: (tos 0xe0, ttl 64, id 8536, offset 0, flags [DF], proto TCP (6), length 56)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [P.], cksum 0xb823 (correct), seq 37:41, ack 2, win 245, options [nop,nop,TS val 1672341855 ecr 1071986777], length 4
06:14:12.258123 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 223: (tos 0xe0, ttl 64, id 8537, offset 0, flags [DF], proto TCP (6), length 209)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [P.], cksum 0x7092 (correct), seq 41:198, ack 2, win 245, options [nop,nop,TS val 1672341855 ecr 1071986777], length 157
06:14:12.263885 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0xe0, ttl 64, id 8538, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [.], cksum 0xb820 (correct), ack 5, win 245, options [nop,nop,TS val 1672341861 ecr 1071986779], length 0
06:14:22.267485 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 67: (tos 0xe0, ttl 64, id 8539, offset 0, flags [DF], proto TCP (6), length 53)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [P.], cksum 0x8d04 (correct), seq 198:199, ack 5, win 245, options [nop,nop,TS val 1672351864 ecr 1071986779], length 1
06:14:22.268934 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 70: (tos 0xe0, ttl 64, id 8540, offset 0, flags [DF], proto TCP (6), length 56)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [P.], cksum 0x689e (correct), seq 199:203, ack 6, win 245, options [nop,nop,TS val 1672351866 ecr 1071996788], length 4
06:14:22.268986 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 392: (tos 0xe0, ttl 64, id 8541, offset 0, flags [DF], proto TCP (6), length 378)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [P.], cksum 0x39f6 (correct), seq 203:529, ack 6, win 245, options [nop,nop,TS val 1672351866 ecr 1071996788], length 326
06:14:22.270355 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0xe0, ttl 64, id 8542, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [.], cksum 0x6758 (correct), ack 338, win 244, options [nop,nop,TS val 1672351867 ecr 1071996790], length 0
06:14:22.270446 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 67: (tos 0xe0, ttl 64, id 8543, offset 0, flags [DF], proto TCP (6), length 53)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [P.], cksum 0x574e (correct), seq 529:530, ack 338, win 244, options [nop,nop,TS val 1672351868 ecr 1071996790], length 1
06:14:22.270471 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0xe0, ttl 64, id 8544, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [F.], cksum 0x6755 (correct), seq 530, ack 338, win 244, options [nop,nop,TS val 1672351868 ecr 1071996790], length 0
06:14:22.271392 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0xe0, ttl 64, id 8545, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53412 > 5.0.0.2.40256: Flags [.], cksum 0x6752 (correct), ack 339, win 244, options [nop,nop,TS val 1672351869 ecr 1071996791], length 0
^C
12 packets captured
12 packets received by filter
0 packets dropped by kernel

This is with TOS=128

host2:mgmt:~$ sudo tcpdump -i swp1 -env 'ip[1] = 128 and (dst port 40256)'
------~~~~~~~--------
06:14:22.263067 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 9014: (tos 0x80, ttl 64, id 7877, offset 0, flags [DF], proto TCP (6), length 9000)
    5.0.0.1.53428 > 5.0.0.2.40256: Flags [.], cksum 0x1a68 (correct), seq 250052769:250061717, ack 1, win 245, options [nop,nop,TS val 1672351859 ecr 1071996778], length 8948
06:14:22.263130 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 9014: (tos 0x80, ttl 64, id 7878, offset 0, flags [DF], proto TCP (6), length 9000)
    5.0.0.1.53428 > 5.0.0.2.40256: Flags [.], cksum 0xadbb (correct), seq 250061717:250070665, ack 1, win 245, options [nop,nop,TS val 1672351859 ecr 1071996778], length 8948
06:14:22.263181 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 9014: (tos 0x80, ttl 64, id 7879, offset 0, flags [DF], proto TCP (6), length 9000)
    5.0.0.1.53428 > 5.0.0.2.40256: Flags [.], cksum 0x65e3 (correct), seq 250070665:250079613, ack 1, win 245, options [nop,nop,TS val 1672351859 ecr 1071996778], length 8948
06:14:22.263256 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 5866: (tos 0x80, ttl 64, id 7880, offset 0, flags [DF], proto TCP (6), length 5852)
    5.0.0.1.53428 > 5.0.0.2.40256: Flags [P.], cksum 0xfe57 (correct), seq 250079613:250085413, ack 1, win 245, options [nop,nop,TS val 1672351859 ecr 1071996778], length 5800
06:14:22.270386 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0x80, ttl 64, id 7881, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53428 > 5.0.0.2.40256: Flags [F.], cksum 0xeb8c (correct), seq 250085413, ack 1, win 245, options [nop,nop,TS val 1672351867 ecr 1071996783], length 0
06:14:22.271072 00:02:00:00:00:01 > 00:02:00:00:00:02, ethertype IPv4 (0x0800), length 66: (tos 0x80, ttl 64, id 7882, offset 0, flags [DF], proto TCP (6), length 52)
    5.0.0.1.53428 > 5.0.0.2.40256: Flags [.], cksum 0xeb82 (correct), ack 2, win 245, options [nop,nop,TS val 1672351868 ecr 1071996791], length 0
^C
19947 packets captured
22134 packets received by filter
2187 packets dropped by kernel

@liam-mcb
Copy link
Author

liam-mcb commented Jan 13, 2026

@jake-rus The initial 2 packets are unmarked as they are sent when the client connects within the netdial function.
To mark those packets, I could replace netdial to set the TOS before the socket connects, but I'm not sure what the maintainers would prefer.
Since they are sent before the main traffic is generated, the unmarked packets don't affect my tests.

@liam-mcb
Copy link
Author

@jake-rus I've pushed an update to add a netdial_with_tos function described in #1989 (comment) so now the TOS is set for all control packets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants