[ONOS] Bandwidth issue fix
Change-Id: I72007a2e211b807906d58172d3c58b07f6613a55
Showing
4 changed files
with
16 additions
and
4 deletions
... | @@ -152,7 +152,16 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -152,7 +152,16 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
152 | throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex); | 152 | throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex); |
153 | } | 153 | } |
154 | 154 | ||
155 | - cb.writeInt(Float.floatToIntBits(iBandwidth)); | 155 | + //Convert to bytes per second |
156 | + float bwBytes = iBandwidth / 8.0f; | ||
157 | + //Bytes/sec to IEEE floating format | ||
158 | + int bandwidth = Float.floatToIntBits(bwBytes); | ||
159 | + | ||
160 | + cb.writeByte(bandwidth >>> 24); | ||
161 | + cb.writeByte(bandwidth >> 16 & 0xff); | ||
162 | + cb.writeByte(bandwidth >> 8 & 0xff); | ||
163 | + cb.writeByte(bandwidth & 0xff); | ||
164 | + | ||
156 | short hLength = (short) (cb.writerIndex() - objStartIndex); | 165 | short hLength = (short) (cb.writerIndex() - objStartIndex); |
157 | cb.setShort(objLenIndex, hLength); | 166 | cb.setShort(objLenIndex, hLength); |
158 | //will be helpful during print(). | 167 | //will be helpful during print(). | ... | ... |
... | @@ -492,6 +492,8 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -492,6 +492,8 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
492 | switch (tlv.getType()) { | 492 | switch (tlv.getType()) { |
493 | case LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH: | 493 | case LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH: |
494 | maxReservableBw = ((BgpLinkAttrMaxLinkBandwidth) tlv).linkAttrMaxLinkBandwidth(); | 494 | maxReservableBw = ((BgpLinkAttrMaxLinkBandwidth) tlv).linkAttrMaxLinkBandwidth(); |
495 | + //will get in bytes/second , convert to MBPS to store in network config service | ||
496 | + maxReservableBw = maxReservableBw * 8 / 1000000; | ||
495 | break; | 497 | break; |
496 | default: // do nothing | 498 | default: // do nothing |
497 | } | 499 | } | ... | ... |
... | @@ -1005,7 +1005,8 @@ public class BgpTopologyProviderTest { | ... | @@ -1005,7 +1005,8 @@ public class BgpTopologyProviderTest { |
1005 | linkStateAttr.add(tlv); | 1005 | linkStateAttr.add(tlv); |
1006 | tlv = BgpLinkAttrTeDefaultMetric.of(20); | 1006 | tlv = BgpLinkAttrTeDefaultMetric.of(20); |
1007 | linkStateAttr.add(tlv); | 1007 | linkStateAttr.add(tlv); |
1008 | - tlv = BgpLinkAttrMaxLinkBandwidth.of(70, LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH); | 1008 | + tlv = BgpLinkAttrMaxLinkBandwidth.of((float) 8.75 * 1_000_000L, |
1009 | + LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH); | ||
1009 | linkStateAttr.add(tlv); | 1010 | linkStateAttr.add(tlv); |
1010 | linkPathAttributes.add(new LinkStateAttributes(linkStateAttr)); | 1011 | linkPathAttributes.add(new LinkStateAttributes(linkStateAttr)); |
1011 | details.setPathAttribute(linkPathAttributes); | 1012 | details.setPathAttribute(linkPathAttributes); | ... | ... |
... | @@ -1010,9 +1010,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1010,9 +1010,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1010 | //build ERO object | 1010 | //build ERO object |
1011 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); | 1011 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); |
1012 | 1012 | ||
1013 | - int iBandwidth = DEFAULT_BANDWIDTH_VALUE; | 1013 | + float iBandwidth = DEFAULT_BANDWIDTH_VALUE; |
1014 | if (tunnel.annotations().value(BANDWIDTH) != null) { | 1014 | if (tunnel.annotations().value(BANDWIDTH) != null) { |
1015 | - iBandwidth = Float.floatToIntBits(Float.parseFloat(tunnel.annotations().value(BANDWIDTH))); | 1015 | + iBandwidth = Float.valueOf(tunnel.annotations().value(BANDWIDTH)); |
1016 | } | 1016 | } |
1017 | // build bandwidth object | 1017 | // build bandwidth object |
1018 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); | 1018 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); | ... | ... |
-
Please register or login to post a comment