Strange WDS behaviour when a new node is powered-on

Hi all,

For MANET environment, I am trying to write a script to redefine the “Distance” of each WDS partner.
The fact is that with the static routes of the script (shown below) it seems to work.
The issue is when I make power-on to one node all the other nodes, which were already working, hang-off for some tenths of seconds.
Is this the normal behaviour for WDS?
Is there a turn-around for this behaviour?

Thanks.

J.A.R.Militão

#**************************************** 
# /system scheduler add name=Startup on-event=scrMESH start-time=startup interval=0
#/sys scr run test_script_2 
#---------------------------------------
:global scrMESH 1;
:local monLine;
:local number;
:local numbers;
:local gip;
:local dstip;
:local dstmac;
:local dstrssi;
:local distance;
:local MyNet;
:local ThisNet;
:local ThisGw;

:delay 20;

:local netArray  {"192.168.0.0/24";"10.10.10.1"; \
                  "192.168.1.0/24";"10.10.10.1"; \
                  "192.168.2.0/24";"10.10.10.2";   \
                  "192.168.3.0/24";"10.10.10.3";   \
                  "192.168.4.0/24";"10.10.10.4";   \
                  "192.168.5.0/24";"10.10.10.5"   \
				  };

:if ([:len [/ip route  find where gateway="my_bridge"]] >0) do={
 :set $MyNet [/ip route get [find gateway="my_bridge"] dst-address];
 :put ("MyNet ".$MyNet); 

   :for e from 0 to ([len $netArray  ]-1) step 2 do={
    :put ("---".[:pick $netArray   $e]);
    :set $ThisNet [:pick $netArray   $e];
    : set $ThisGw  [:pick $netArray   ($e+1)];

    : if ($MyNet != $ThisNet) do={
      :put ("ThisNet ".$ThisNet." ThisGw ".$ThisGw  );
       /ip route add dst-address=$ThisNet gateway=$ThisGw   distance=127
  }
 }
}


:do {
 :put ("\r\n".[:system clock get date]." " .[:system clock get time]."----");

 :for i from 2 to 3 do={
  :put ("   -----");


  :set $gip ("10.10.10.".$i);

  :if ([:len [/ip route  find where gateway=$gip]] >0) do={


   :local myArray  [/ip route  find where gateway=$gip];
   :for e from 0 to ([len $myArray]-1) do={
    #:put ($e.": ".[:pick $myArray $e]);

    :set $number [:pick $myArray $e];
    #:put (" numbers=".$e." number=".$number); 

    :set $dstip [/ip route get $number dst-address];
    :set $distance [/ip route get $number distance];

    :put ("'ip route' says "." for ".$dstip." gateway: ".$gip." distance=".$distance);

    :if ([:len [/ip arp  find where address=$gip]] >0) do={
     :set $dstmac [/ip arp get [find address=$gip] mac-address];
     #:put ("from 'ip arp' MAC=".$dstmac);

     :if ([:len [/interface wireless registration-table find where mac-address=$dstmac]] >0) do={
      :set $dstrssi [/interface wireless registration-table get [ find mac-address=$dstmac] signal-strength];  
      #:put ("from 'interface wireless registration-table' RSSI=".$dstrssi);


      :set $signal [:pick $dstrssi 0 [:find $dstrssi "@"]];
      :set $speed [:pick $dstrssi ([:find $dstrssi "@"]+1) [:len $dstrssi]];

      :put (" numbers=".$e." number=".$number); 
      :put ("       dst ".$dstip." gw=". $gip." mac=".$dstmac." signal=".$signal." speed=".$speed);

      :local value [:pick $signal 0 ([:find $signal "dBm"])];
      #:put ("   value=".$value);
      #:put (" new dist=".($value*-1));

      :set [/ip route set $number distance= ($value*-1)];

     }
     }
    }
   } 
  }
  :delay 1;
} while=($scrMESH  = 1); 

:if ([:len [/ip route  find where gateway="my_bridge"]] >0) do={
 :set $MyNet [/ip route get [find gateway="my_bridge"] dst-address];
 :put ("MyNet ".$MyNet); 

   :for e from 0 to ([len $netArray  ]-1) step 2 do={
    :put ("---".[:pick $netArray   $e]);
    :set $ThisNet [:pick $netArray   $e];
    : set $ThisGw  [:pick $netArray   ($e+1)];

    : if ($MyNet != $ThisNet) do={
      :put ("ThisNet ".$ThisNet." ThisGw ".$ThisGw  );
       /ip route remove [find dst-address=$ThisNet gateway=$ThisGw]  
  }
 }
}