3.5 Routing Algorithms
3.5.2 Simple Filter-Based Routing
In this section simple filter-based routing is described. This routing strategy uses filter forwarding to update the routing configuration in reaction to sub- scribing and unsubscribing clients: new and canceled subscriptions are simply flooded into the broker network such that they reach every broker. This allows the brokers to update their routing tables accordingly. The only assumption that underlies simple routing is that each filter can be uniquely identified. The algorithm works as follows:
• Initially, the routing table TB of each broker B is initialized to ∅.
• If a client X subscribes to a filter F , the corresponding broker adds (F, X) to its routing table and sends an admin({F }, ∅) message to all neighbors (see Fig. 3.9).
• If a client X unsubscribes to a filter F , the broker removes (F, X) from its routing table and sends an admin(∅, {F }) message to all neighbors. • If a broker receives an admin({F }, ∅) message from a neighbor U , it adds
an entry (F, U ) to its routing table (see Fig. 3.9). Moreover, the broker forwards the received admin message to all of its neighbors except U . • If a broker receives an admin(∅, {F }) message from a neighbor U , it ex-
tracts the entry (F, U ) from its routing table. Moreover, the broker for- wards the received admin message to all of its neighbors except U . This strategy is simple but it implies that every broker has to handle a new or canceled subscription. Moreover, the algorithm requires that every broker has global knowledge about all active subscriptions because any routing table contains a routing entry for every active subscription. The corresponding in- stantiation of the administer procedure is shown in Figure 3.8.
Set procedure administer(Sender S, Set , Set )
begin TB← TB∪ {(F, S) | F ∈ } TB← TB\ {(G, S) | G ∈ } 5 ← {(H, , ) | H ∈ NB\ {S}} return end
Figure 3.8: Simple Filter-Based Routing
Correctness Proof. Following, the correctness of simple routing is proved (Theorem 3.6) by showing that the initial routing configuration is valid (Lemma 3.14) and that the instantiation of administer (Lemma 3.18) is legal for that initial routing configuration. This proves the correctness of simple routing (see Theorem 3.6).
Routing TableTB1 5.admin({F}, ∅) 5. admin( {F},∅) 2. . . .(F, X 1) B1 X1 4. . . . (F, B1) 4. . . . (F, B1) B2 B4 B5 B3 3. admin( {F}, ∅) 1.sub(F) 3.admin( {F}, ∅ )
Figure 3.9: Diagram explaining simple routing (new subscription).
Lemma 3.14 (Legal Empty Routing Configuration) If for each broker Bi
the routing table TBi is initialized to ∅, the initial routing configuration is legal.
Proof sketch: Here, it is simply shown that both requirements of legal initial routing configurations are met. First, it is shown that the remote initial routing configuration is legal. After that, it is proved that the local initial routing configuration is legal. Assume: TBi is initialized to ∅ Prove: 1. e(Bi, Bj) ∈ E ⇒ νB0i({Bj}) ⊇ ν 0 Bj(NBj \ {Bi}) 2. νB0i(LBi) = ∅ Proof: h1i1. e(Bi, Bj) ∈ E ⇒ νB0i({Bj}) ⊇ ν 0 Bj(NBj \ {Bi}) Assume: e(Bi, Bj) ∈ E Prove: νB0i({Bj}) ⊇ ν 0 Bj(NBj \ {Bi}) h2i1. ν0 Bi({Bj}) = ∅
Proof: Implied by Lemma assumption and assumption of step h1i1. h2i2. ν0
Bj(NBj \ {Bi}) = ∅
Proof: Implied by Lemma assumption and assumption of step h1i1. h2i3. Q.E.D.
Proof: by step h2i1,h2i2, and assumption of step h1i1. h1i2. ν0
Bi(LBi) = ∅
Proof: follows directly from Lemma assumption. h1i3. Q.E.D.
Proof: by step h1i1 and h1i2.
After we have proved that the empty initial routing configuration is legal, it is shown that simple routing is legal for this initial configuration. Before
we prove this property we need some preparation. Let QE
B(D) (E stands for “except”) be the set of all filters of all routing entries in the routing table of a broker B except those regarding destination D. Moreover, let QO
for “only”) be the set of all filters of all routing entries in the routing table of a broker B regarding destination D:
QE
B(D) = {F | ∃(F, D
0) ∈ T
B∧ D0 6= D} (3.9)
QOB(D) = {F | ∃(F, D) ∈ TB} (3.10)
Now consider for a broker B and one of its neighbors H the following sets:
α = QEB(H) (3.11)
β = QO
H(B) (3.12)
The sets α and β are those routing entries that determine νB(LB∪ NB\ {H}) and νH({B}), respectively. More precisely, the definition of ν (Eq. 3.1) implies that νB(LB∪ NB\ {H}) = ∪F∈αN (F ) and νH({B}) = ∪F∈βN (F ).
Lemma 3.15 If α = β, then νH({B}) = νB(LB∪ NB\ {H}).
Proof: The property follows directly from the Definitions of α (Eq. 3.11), β (Eq. 3.12), and ν (Eq. 3.1).
The above Lemma states that if α and β contain the same filters, then H forwards exactly those notifications to B that B forwards in turn to all other destinations. This situation is depicted in Fig. 3.10. Simple routing ensures that this property holds among corresponding versions of α and β.
β = QO H(B)
α = Q
E B(H)
=
Filter
Figure 3.10: Relation among α and β for simple routing.
The following Lemma proves that B sends an admin message to H if α changes.
Lemma 3.16 If simple routing is used and α changes, then B sends an admin message to H.
Proof: From the framework algorithm (see Fig. 3.6) and the algorithm in Fig. 3.8 (simple routing) we know that α can only change, if B receives a sub or unsub message from a local client or an admin message from a neighbor except H. In all these cases, administeris called and a triple is returned for H (see Fig. 3.8, line 5). According to the framework this implies that an admin message is sent to H.
Lemma 3.17 If simple routing with the empty legal initial routing configuration is used, the following property holds: If H receives an admin message m from B, then αid(m)= βid(m).
Proof sketch: The Lemma is proved by an induction. First, it is shown that the property holds for the first admin message that H receives from B. Here, the fact that the property holds initially due to the legal initial routing configuration is used. After that, the induction step is shown that uses Lemma 3.16.
Now, we are prepared to show that simple routing is legal for the empty initial routing configuration.
Lemma 3.18 The administer procedure shown in Fig. 3.8 (simple routing ) is legal for the legal empty initial routing configuration.
Proof sketch: We prove that the administer procedure shown in Fig. 3.8 (simple routing) is legal by showing that the properties 1 to 3 of Def. 3.4 are satisfied. Proof:
h1i1. Property 1 is satisfied.
Proof: It is easy to see that the procedure returns. h1i2. Property 2 is satisfied.
h2i1. Property 2a is satisfied.
Proof: As unsub and sub messages are handled in the same way, the same proof as in Lemma 3.13 holds.
h2i2. Property 2b is satisfied. Assume: S ∈ NB
Prove: νBid(m)({S}) ⊇ νSid(m)(LS∪ NS\ {B}) Proof: by Lemmas 3.15 and 3.17.
h2i3. Property 2c is satisfied.
Proof: The algorithms in Fig. 3.6 (framework) and Fig. 3.8 (simple routing) imply that the routing entries regarding a destination can only be affected by a message received from this destination (see Fig. 3.8, lines 3/4).
h2i4. Q.E.D.
Proof: by h2i1, h2i2, and h2i3. h1i3. Property 3 is satisfied.
h2i1. Q.E.D.
Proof: Properties 3 is satisfied because administer shown in Fig. 3.8 (simple routing) returns exactly one triple for each neighbor except S (see Fig. 3.8, line 5).
h1i4. Q.E.D.
Proof: by h1i1, h1i2, and h1i3.
Theorem 3.6 (Correctness of Simple Filter-Based Routing) The routing framework with administer shown in Fig. 3.8 (simple routing) and the empty legal initial routing configuration satisfy Def. 2.1.