ADDITIONAL SYSTEM INFORMATION :
Java:
/usr/lib/jvm/jdk-17-oracle-x64/bin/java -version
java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)
uname -a
Linux xxx 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Set traffc class value to 10 and get 10 by `getTrafficClass` method, but ip package show 0 in jdk17.
But it works with jdk11.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. start server side by nc -l 8001
2. Capture the traffic by tcpdump : tcpdump -vvv -nnX -c1000
3. Run client and sent a package with traffic class 10 to server
4. You can see ip package tos value is 0x0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ip tos value is 10
ACTUAL -
14:22:37.643746 IP (tos 0x0, ttl 61, id 4843, offset 0, flags [DF], proto TCP (6), length 52)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [S], cksum 0x99bd (correct), seq 1194522346, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 9], length 0
0x0000: 4500 0034 12eb 4000 3d06 e206 0acb 1876 E..4..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6ea 0000 0000 .......AG2......
0x0020: 8002 7210 99bd 0000 0204 05b4 0101 0402 ..r.............
0x0030: 0103 0309 ....
14:22:37.643789 IP (tos 0x0, ttl 61, id 4844, offset 0, flags [DF], proto TCP (6), length 40)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [.], cksum 0x71ab (correct), seq 1194522347, ack 584628180, win 58, length 0
0x0000: 4500 0028 12ec 4000 3d06 e211 0acb 1876 E..(..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6eb 22d8 b7d4 .......AG2.."...
0x0020: 5010 003a 71ab 0000 0000 0000 0000 P..:q.........
14:22:37.645627 IP (tos 0x0, ttl 61, id 4845, offset 0, flags [DF], proto TCP (6), length 41)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [P.], cksum 0x70a2 (correct), seq 0:1, ack 1, win 58, length 1
0x0000: 4500 0029 12ed 4000 3d06 e20f 0acb 1876 E..)..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6eb 22d8 b7d4 .......AG2.."...
0x0020: 5018 003a 70a2 0000 0100 0000 0000 P..:p.........
14:22:37.646338 IP (tos 0x0, ttl 61, id 4846, offset 0, flags [DF], proto TCP (6), length 40)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [F.], cksum 0x71a9 (correct), seq 1, ack 1, win 58, length 0
0x0000: 4500 0028 12ee 4000 3d06 e20f 0acb 1876 E..(..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6ec 22d8 b7d4 .......AG2.."...
0x0020: 5011 003a 71a9 0000 0000 0000 0000 P..:q.........
14:22:37.646381 IP (tos 0x0, ttl 61, id 4847, offset 0, flags [DF], proto TCP (6), length 40)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [.], cksum 0x71a8 (correct), seq 2, ack 2, win 58, length 0
0x0000: 4500 0028 12ef 4000 3d06 e20e 0acb 1876 E..(..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6ed 22d8 b7d5 .......AG2.."...
0x0020: 5010 003a 71a8 0000 0000 0000 0000 P..:q.........
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
public class SetTrafficClassTest {
public static void main(String[] args) throws IOException {
if (args.length != 3) {
System.err.println("Arguments: <host> <port> <ip_tos>");
return;
}
Socket socket = new Socket(args[0], Integer.parseInt(args[1]));
socket.setTcpNoDelay(true);
OutputStream os = socket.getOutputStream();
byte[] bytes = new byte[] {1};
int tc = Integer.parseInt(args[2]);
socket.setTrafficClass(tc);
os.write(bytes);
System.out.println("Set Traffic class to " + tc + ", got " + socket.getTrafficClass());
os.flush();
os.close();
socket.close();
}
}
---------- END SOURCE ----------
FREQUENCY : always
Java:
/usr/lib/jvm/jdk-17-oracle-x64/bin/java -version
java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)
uname -a
Linux xxx 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Set traffc class value to 10 and get 10 by `getTrafficClass` method, but ip package show 0 in jdk17.
But it works with jdk11.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. start server side by nc -l 8001
2. Capture the traffic by tcpdump : tcpdump -vvv -nnX -c1000
3. Run client and sent a package with traffic class 10 to server
4. You can see ip package tos value is 0x0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ip tos value is 10
ACTUAL -
14:22:37.643746 IP (tos 0x0, ttl 61, id 4843, offset 0, flags [DF], proto TCP (6), length 52)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [S], cksum 0x99bd (correct), seq 1194522346, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 9], length 0
0x0000: 4500 0034 12eb 4000 3d06 e206 0acb 1876 E..4..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6ea 0000 0000 .......AG2......
0x0020: 8002 7210 99bd 0000 0204 05b4 0101 0402 ..r.............
0x0030: 0103 0309 ....
14:22:37.643789 IP (tos 0x0, ttl 61, id 4844, offset 0, flags [DF], proto TCP (6), length 40)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [.], cksum 0x71ab (correct), seq 1194522347, ack 584628180, win 58, length 0
0x0000: 4500 0028 12ec 4000 3d06 e211 0acb 1876 E..(..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6eb 22d8 b7d4 .......AG2.."...
0x0020: 5010 003a 71ab 0000 0000 0000 0000 P..:q.........
14:22:37.645627 IP (tos 0x0, ttl 61, id 4845, offset 0, flags [DF], proto TCP (6), length 41)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [P.], cksum 0x70a2 (correct), seq 0:1, ack 1, win 58, length 1
0x0000: 4500 0029 12ed 4000 3d06 e20f 0acb 1876 E..)..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6eb 22d8 b7d4 .......AG2.."...
0x0020: 5018 003a 70a2 0000 0100 0000 0000 P..:p.........
14:22:37.646338 IP (tos 0x0, ttl 61, id 4846, offset 0, flags [DF], proto TCP (6), length 40)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [F.], cksum 0x71a9 (correct), seq 1, ack 1, win 58, length 0
0x0000: 4500 0028 12ee 4000 3d06 e20f 0acb 1876 E..(..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6ec 22d8 b7d4 .......AG2.."...
0x0020: 5011 003a 71a9 0000 0000 0000 0000 P..:q.........
14:22:37.646381 IP (tos 0x0, ttl 61, id 4847, offset 0, flags [DF], proto TCP (6), length 40)
10.203.24.118.48400 > 10.203.26.199.8001: Flags [.], cksum 0x71a8 (correct), seq 2, ack 2, win 58, length 0
0x0000: 4500 0028 12ef 4000 3d06 e20e 0acb 1876 E..(..@.=......v
0x0010: 0acb 1ac7 bd10 1f41 4732 f6ed 22d8 b7d5 .......AG2.."...
0x0020: 5010 003a 71a8 0000 0000 0000 0000 P..:q.........
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
public class SetTrafficClassTest {
public static void main(String[] args) throws IOException {
if (args.length != 3) {
System.err.println("Arguments: <host> <port> <ip_tos>");
return;
}
Socket socket = new Socket(args[0], Integer.parseInt(args[1]));
socket.setTcpNoDelay(true);
OutputStream os = socket.getOutputStream();
byte[] bytes = new byte[] {1};
int tc = Integer.parseInt(args[2]);
socket.setTrafficClass(tc);
os.write(bytes);
System.out.println("Set Traffic class to " + tc + ", got " + socket.getTrafficClass());
os.flush();
os.close();
socket.close();
}
}
---------- END SOURCE ----------
FREQUENCY : always