2 * (c) 2015 Cable Television Laboratories, Inc. All rights reserved.
5 package org.pcmm.gates.impl;
7 import org.pcmm.gates.ISessionClassID;
10 * SessionClassID is a 1-byte unsigned integer value which identifies the proper admission control policy or
11 * parameters to be applied for this Gate. The SessionClassID is a bit field, defined as follows:
12 * Bit 0-2: Priority, a number from 0 to 7, where 0 is low priority and 7 is high.
13 * Bit 3: Preemption, set to enable preemption of bandwidth allocated to lower priority sessions if necessary
15 * Bit 4-7: Configurable, default to 0
17 public class SessionClassID implements ISessionClassID {
20 * The priority field describes the relative importance of the session as compared to other sessions generated by
21 * the same PDP. The PEP MAY use this value to both implement priority based admission (in conjunction with the
22 * Preemption bit), and to defend the resulting flow from being preempted.
24 private transient byte priority;
27 * The preemption bit is used to by a PDP to direct the PEP to apply a priority-based admission control. Preemption
28 * support is optional; a PEP MAY ignore this bit. If preemption is not requested by the PDP or not implement by the
29 * PEP, then admission control policy will be on a first-come, first-served basis.
31 private transient byte preemption;
34 * The session ID value
40 * @param value - the session value
42 public SessionClassID(byte value) {
46 priority |= value >> 2;
47 preemption |= value >> 3;
52 * @param value - the session value
53 * @param priority - overrides the default priority value of 2
54 * @param preemption - overrides the default preemption value of 3
56 public SessionClassID(byte value, final byte priority, final byte preemption) {
58 this.priority = priority;
59 this.preemption = preemption;
63 public byte getPriority() {
68 public byte getPreemption() {
73 public byte toSingleByte() {
78 public boolean equals(final Object o) {
82 if (!(o instanceof SessionClassID)) {
85 final SessionClassID that = (SessionClassID) o;
86 return priority == that.priority && preemption == that.preemption && session == that.session;
90 public int hashCode() {
91 int result = (int) priority;
92 result = 31 * result + (int) preemption;
93 result = 31 * result + (int) session;