如何使用Java获取DiffServe代码点(DSCP)整数的优先级部分?我希望它涉及移位,但是由于某种原因,我似乎无法获得我期望的值。
最佳答案
假设我正确理解了您的意思,请向右执行3位逻辑移位:dscp >>> 3
像这样:
for (int dscp = 0; dscp < 57; dscp++) {
System.out.println("DSCP:" + dscp + " Precedence:" + (dscp >>> 3));
}
输出:
DSCP:0 Precedence:0
DSCP:1 Precedence:0
DSCP:2 Precedence:0
DSCP:3 Precedence:0
DSCP:4 Precedence:0
DSCP:5 Precedence:0
DSCP:6 Precedence:0
DSCP:7 Precedence:0
DSCP:8 Precedence:1
DSCP:9 Precedence:1
DSCP:10 Precedence:1
DSCP:11 Precedence:1
DSCP:12 Precedence:1
DSCP:13 Precedence:1
DSCP:14 Precedence:1
DSCP:15 Precedence:1
DSCP:16 Precedence:2
DSCP:17 Precedence:2
DSCP:18 Precedence:2
DSCP:19 Precedence:2
DSCP:20 Precedence:2
DSCP:21 Precedence:2
DSCP:22 Precedence:2
DSCP:23 Precedence:2
DSCP:24 Precedence:3
DSCP:25 Precedence:3
DSCP:26 Precedence:3
DSCP:27 Precedence:3
DSCP:28 Precedence:3
DSCP:29 Precedence:3
DSCP:30 Precedence:3
DSCP:31 Precedence:3
DSCP:32 Precedence:4
DSCP:33 Precedence:4
DSCP:34 Precedence:4
DSCP:35 Precedence:4
DSCP:36 Precedence:4
DSCP:37 Precedence:4
DSCP:38 Precedence:4
DSCP:39 Precedence:4
DSCP:40 Precedence:5
DSCP:41 Precedence:5
DSCP:42 Precedence:5
DSCP:43 Precedence:5
DSCP:44 Precedence:5
DSCP:45 Precedence:5
DSCP:46 Precedence:5
DSCP:47 Precedence:5
DSCP:48 Precedence:6
DSCP:49 Precedence:6
DSCP:50 Precedence:6
DSCP:51 Precedence:6
DSCP:52 Precedence:6
DSCP:53 Precedence:6
DSCP:54 Precedence:6
DSCP:55 Precedence:6
DSCP:56 Precedence:7
关于java - DSCP优先级,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27551980/