A Static Data Structure for Discrete Advance Bandwidth Reservations on the Internet
Andrej Brodnik
Andreas Nilsson
August 25, 2003
Abstract
In this paper we present a discrete data structure simi- lar to segment trees for handling reservations of a lim- ited resource over the time. The maximum time interval covered is fixed and defined in advance. The granularity and thereby possible sizes of the intervals represented by the data structure is also fixed in advance. The data structure, which is a version of a segment tree, is built only once. Neither nodes nor leaves are ever inserted, deleted or moved. Hence, the running time of the op- erations does not depend on the number of reservations previously made. The running time does not depend on the size of the interval of the reservation either. Let
be the number of leaves in the data structure. In the worst case, the number of touched (i.e. traversed) nodes in any operation is
, hence the running time of any operation is
.
1 Definition of the problem
Schel´en et. al. in [8, 9] proposed bandwidth brokers as an infrastructure for management of QoS traffic using differentiated services protocol ([1]). The bandwidth brokers communicate among themselves to make band- width reservations on Internet links. To accomplish their task they need to be able to update and query reser- vations of a bandwidth (resource) on a given link for a given time duration – we call the problem “The Band- width Reservation Problem” (BRP).
A reservation is a time interval during which we reserve constant bandwidth. The presented solution works in a discrete bounded universe, by which we mean a universe with a limited duration and fixed time granularity. By using fixed granularity we have divided the time into time slots (frames). We use slotted time to get a smaller data structure, faster operations and hence gain benefits of a larger aggregation. This was inspired
The complete version of paper appeared as [3].
Department of Theoretical Computer Science, Institute of Math- ematics, Physics, and Mechanics, Ljubljana, Slovenia
Department of Computer Science and Electrical Engineering, Lule˚a University of Technology, Lule˚a, Sweden
by the fact that problems are generally easier to solve in a bounded (discrete) universe than in the general case ([2]). We observe that the BRP is constrained by the physical world and therefore no reservations will occur in the past and very few in a distant future.
Throughout the paper we use the following notation:
We have a bounded maximum interval
starting at
and ending at
, hence
! "#%$&')(.
is divided into fixed size time slots of size
*. The size of the interval
is denoted by
+!+.
In general, a discrete interval,
,, is defined as the duration between a starting point
and an ending point
, and the interval is divided into discrete slots of size
*. In short,
,-. "/$&0(. Moreover, since
213546-16'!,876.
The bandwidth is denoted by
9. A reservation,
:
, is defined by an interval
,and a (constant) amount of reserved bandwidth
9, during
,. In short, reservation is a tuple
: <;9$=,>. Items related to reservations are denoted by a subscript, e.g.
: 6;?9A@'$B,C@D>.
A data structure storing reservations made is de- noted by
E. An item related to a “query” toward the data structure is denoted by a subscript
F, e.g.
,CGH3 IG0$J'G(
.
Definition 1 We have a bounded maximum interval
divided into time slots of size
*. Let a reservation,
:
<;?9A@'$B,C@D>
, be on an interval
,K@L7<with an
associated bandwidth,
9A@. Then the bandwidth reser- vation problem requires the following operations:
MJN/O&PRQRS
TEU$
:
, which increases the reserved band- width during the interval
,C@for
9A@.
VWPRXRPRSRP
TE8$
:
, which decreases the reserved band- width during the interval
,C@for
9A@.
YWZR[R\RP/OJPRQR]RPR^
E)$=,CG_
, which returns the maximum re-
served bandwidth, during the interval
,KG.
Note, deletion is the same as an insertion with a negative bandwidth.
The bandwidth reservation problem is not well stud- ied in the literature, but two related problems, the partial
1
sum problem ([4], brief in [5]), and the prefix sum prob- lem ([4]), are. These problems are related but their so- lution is unfortunately not well suited to solve the BRP.
2 Solution
Our solution Advanced Segment Tree (AST) is a mod- ified segment tree ([6]). In AST each node
`repre- sents a time interval and hence it contains the informa- tion about interval it represents, pointers to each of the node’s children, and values
a8bWcand
bWcdescribed more thoroughly further down.
The interval of the root is
. Let
ddenote the num- ber of levels that the data structure consists of. All nodes on level
ehave time intervals of the same size which do not intersect, but follow consecutively one an- other. This means that the union of all intervals on level
e
is
. Each level
ehas a divisor
f)gthat tells the num- ber of children that a node on that particular level has.
The divisors are gathered up from the root to the leaves in a vector
fhi;jflkj$=fnm$Jooo$=fqpsrskt>, where
flkis the number of the root’s children. The divisor
f gdoes not only tell the number of children that a node has, but also the size of the interval
gon level
e+I5gu+
+!+ e/6v
w
yxz{
w
| x
v}46e16d~o
(1)
Consequently the number of nodes on level
eis
g
v es3v
grk
I
k f
v4 e16d
(2)
and the total number of leaves in the data structure
p
p/rk
I
k f o
(3)
The divisors
f must be set so that
*w w
, where
is defined in eq. (3) and where
*is the time granu- larity; hence, the choices of
+!+,
*,
d,
and
fare related. The tree is only built once and therefore the tree is always perfectly balanced. The difference be- tween the segment tree and AST is the role of leaves. In the segment tree there is a leaf for every open interval,
rskJ$B
, and as well for the closed interval,
$= (. In AST leaves represent semi-open intervals
T $= " kB(. To describe our data structure we use the following nota- tion:
`
denotes “the current node” during a description of a traversal of the tree, while
` pdenotes the left- most child of
`, and
` @the rightmost child.
Each node
`stores the interval
,CcL "#c$&'c0(that the node subtends; the amount of bandwidth
b c
that was reserved over exactly the whole in- terval
, c; and
a8b c, the maximum value of re- served bandwidth on the interval
, csubtracted by
bWc
.
We start by describing the recursive query function
YWZR[R\RP/OJPRQR]RPR^
=`n$B, G
:
If the interval of node
`satisfies
,CG, cthen the returned value is
b c3 a)b c.
If
, Gis entirely contained within the interval of
`’s child
`the returned value is
bWc YRZW[R\RP/O&PWQR]RPR^
B` $B,CG}
.
If
, Gspans over intervals of
achildren of
`a v
, then
, Gis divided into
asubintervals – one for each of the
achildren it at least par- tially covers (cf. Fig. 1). I.e.
, G , G3 ,Cc , where
v5181a, and
, G{is the leftmost sub- interval of
, Gand
,Kc {is the interval of the left- most child of
`that has an interval that at least partially intersects with
,CG. The returned value is
k
¡
YRZW[R\RP/O&PWQR]RPR^
B`
$=,CG
¢
, which can be more efficiently computed as
YWZR[R\RP/OJPRQR]RPR^
=`'k£$B,
G
k¤ $
kj¥
¥¦¡
bWc
a)bWc'
$
YWZR[R\RP/OJPRQR]RPR^
=`¡§$B, G ¡¨
© ªB« ¬ ¯®° ±³² ´ µ³¶ · ¸ ¹
º » ¼
½¤¾ ¿³ÀuÁ ³ÃuÄ Å³ÆÈÇ É³ÊBË
̳ÍjΠϤÐ
Ñ Ò&Ó"ÔÕ ÖC×ØÙ Ú¤ÛÜÝ Þ¤ßàá âWãä
å
Figure 1: Circles represent nodes and rectangles repre- sent intervals.
M&N/O&PWQRS
beside inserting of a new reservation must also verify that the inserted reservation is not result in over-reservation. Since it is easier to explain a pure in- sertion and also trivial to integrate into it
YWZR[R\RP/OJPRQR]RPR^not increasing the running time of
(for details see [3]), we give here only the simple insertion:
If the interval of node
`satisfies that
, @ æ, c, then
b cis increased by
9 @.
If
,C@is entirely contained within the interval of
`
’s child
`, then
M&N/O&PWQRSB`A$&;j,K@$&9D@>W
is
2
called and when it returns the
a)b cis updated ac- cording to the equation
a)b c
kç
éè
Tb a)b
ê$
(4)
where
ëis the number of children
`has.
If
, @spans over intervals of
achildren of
`a ìv
, then
,C@is similarly divided as at the query: a sub-interval for each child of
`that
,C@intersects with (see Fig. 1). The
M&N/O&PRQWSfunction is called once for each of the
achildren
` ,
M&N/O&PWQRS
B`
$¤;j,C@
$&9D@D>W
. When all calls return,
the
a)bWcis updated as shown in eq. (4).
The
VRPRXRPRSWPB`n$¤;j,C@$&9D@D>W
is implemented as a call of
M&N/OJPRQRS
with a negated
9 @. The
M&N/O&PRQWSand the
YRZR[W\RP/O&PRQW]RPR^traverse the tree twice from the top to the bottom: once for each the rightmost and the leftmost part of the interval
,CG. In the middle part of
,KGthe recursion never goes deeper than
v
level. The update of the
a8bvalues is done during the traversal. Therefore, the running time is
. This brings us to the final theorem:
Theorem 1 The running time for all operations solving the bandwidth reservation problem as defined in Defini- tion 1 and using AST, is
.
Since our data structure is built only once and the nodes never change, it is possible to store it in an im- plicit way into an array ordered by levels (cf. standard heap order). Consequently, the index of the first ele- ment on level
e, is the number of nodes on all previous levels,
í g, plus
v. To calculate
í gwe use eq. (3) and vector
fto get
íjg
v es6v
grsk
îÈ
m î
rsk
"
k f vïv46e/1êdðo
Values
í gare precomputed. The number of nodes be- tween the node with the index
`on level
eand the first node on level
eis
`ñ!íjg, while the number of nodes between the first node on level
e vand
`’s first child is
B`ñHíjg k sòJf)g. Consequently,
`’s chil- dren have indices
ó è êíçg k B`ôñõíjgB ò¯f)g ë, where
ö
1êë4÷f g
. An implicit version of AST saves memory
for two pointers per node and speeds up the execution due to one memory probe less since vectors
fand
íare in cache.
3 Conclusions
In this paper we presented a discrete data structure Ad- vanced Segment Tree, AST, for reservations of limited
resources over a time-span. The data structure can be applied whenever a limited resource shall be reserved.
The data structure proposed has time complexity inde- pendent of the number of reservations made and the size of the interval. There are defined three operations on the data structure:
M&NO&PRQRSto insert a reservation,
VWPRXRPRSRP