1: Initialization:

2: Synchro_ADV //time synchronize ADV messages and simple node

3: isCH //is the node declared as CH

4: OUTPUT: isGw //is the node declared as candidate Gw

5: isGw = false

6: if (! isCH) then

7: while (t < Synchro_ADV) do

8: if (ReceiveADV) then

9: adv_C H + +

10: end if

11: end while

12: if (adv_C H >= 2) then

13: metric = compute_metric()

14: sendADV _GW (id, metric)

15: isGw = true

16: end if

17: end if