• Protocol 4.14: Determining the (inner) boundary of a region

    PROTOCOL

    Determining the (inner) boundary of a region

    SUMMARY

    The algorithm starts with every mote broadcasting a message to its neighbors stating if it has detected the region. Every time a mote receives a message, it checks the received value with its own. If a mote detects it is within the region and receives a message from a neighbor that is not, it transitions into the BNDY state.

    OPERATION

    • Click the Setup button to generate a network based on communication distance and network size as well as a region of size RegionSize.
    • Click the Go! button to run the algorithm.

    NOTICE

    • The region is green in color, once the algorithm runs, BNDY motes should appear in mid-blue around the edges.
    • Use the MoteLabel list to change the labels to either the mote id or sensed value. This will help show how the algorithm runs. When set to the sensed value, all motes within the region should have a value of 1, with the rest having a value of 0.

    TRY

    • What happens when a smaller netsize value and a small region is used? Do any motes transition into the BNDY state?
    • What happens if the communication distance is too small, making a disconnected network? Change this by adjusting the c slider.
    • Try selecting GG or RNG from the NetworkStructure drop-down box to change the network shape to a Gabriel Graph or Relative Neighborhood Graph. Does this have an effect on the amount of BNDY motes?
    • Try running the algorithm slowly to get a better idea of how the algorithm runs. Change this by adjusting the speed slider.

    LINK TO BOOK

    Protocol 4.14

    CREDITS

    Code designed by Matt Duckham. Additional coding by Alan Both.

    LICENSE

    Copyright 2011, 2012 Matt Duckham

    This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License http://www.gnu.org/licenses/ for more details.

    Protocol 4.14

    The formal specification procedure used for all the protocols on this site is based on the standard distributed systems approach of Nicola Santoro (see Santoro, N. Design and Analysis of Distributed Algorithms. Wiley, Hoboken, NJ. 2007.) For more details on the protocol specification style, please refer to the book accompanying book for this website, Decentralized Spatial Computing: Foundations of Geosensor Networks.

    ;;  Copyright 2011, 2012 Matt Duckham
    ;;
    ;;  This program is free software: you can redistribute it and/or modify
    ;;     it under the terms of the GNU General Public License as published by
    ;;     the Free Software Foundation, either version 3 of the License, or
    ;;     (at your option) any later version.
    ;;
    ;;     This program is distributed in the hope that it will be useful,
    ;;     but WITHOUT ANY WARRANTY; without even the implied warranty of
    ;;     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ;;     GNU General Public License for more details.
    ;;
    ;;     You should have received a copy of the GNU General Public License
    ;;     along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    __includes["../gsn.nls" "../env.nls"]
    ;; Define a new breed of turtle called motes
    breed [motes mote]
    
    ;; Each mote can store the local variable s which is the sensed value.
    motes-own [s]
    
    ;; System setup and initialization
    to initialize
      make-single-region RegionSize ;; Create the region
      if NetworkStructure = "UDG" [create-udg] ;; Create UDG network
      if NetworkStructure = "GG"  [create-udg create-gg] ;; Create GG network
      if NetworkStructure = "RNG" [create-udg create-rng] ;; Create RNG network
      ask motes [
        ifelse [region] of patch-here = ["A"]
          [set s 1] ;; When region detected, s equals 1
          [set s 0] ;; When region not detected, s equals 0
        become "INIT" ;; Set all motes to state INIT
      ]
    end
    
    ;; Runs the boundary algorithm
    to go
      ask motes [ step ]
      mote_labels ;; Changes the labels of the motes based on the MoteLabel dropdown list
      tick
    end
    
    ;;
    ;; Mote protocols
    ;;
    
    ;; Step through the current state
    to step
      if state = "INIT" [ step_INIT stop ]
      if state = "IDLE" [ step_IDLE stop ]
      if state = "BNDY" [ step_BNDY stop ]
    end
    
    ;; Broadcast sensed value to neighbors.
    to step_INIT
      broadcast (list "PING" s) ;; Broadcast PING with sensed value
      become "IDLE"
    end
    
    ;; When a mote receives a message it determines if it's on the boundary of the region.
    to step_IDLE
      if has-message "PING" [ ;; Receiving PING
        let msg received "PING"
        let s' item 1 msg ;; Received sensed value
        if s' != s and s = 1 [ ;; Check if node is in the region, but adjacent to node outside
          become "BNDY"
        ]
        stop
      ]
    end
    
    ;; The BNDY state does not respond to messages.
    to step_BNDY
    end
    
    ;; Changing the labels of the motes based on the MoteLabel dropdown list
    to mote_labels
      ask motes [
        if MoteLabel = "none" [set label ""] ;; Hide the label
        if MoteLabel = "mote id" [set label who] ;; Show mote id
        if MoteLabel = "sensed value" [set label s] ;; Show sensed value
      ]
    end
    

    The NetLogo procedures for this applet can be downloaded directly as: Protocol4.14.nlogo

    All the NetLogo simulation models for this book depend on two library files: gsn.nls and env.nls
    These files should be placed in the parent directory of the .nlogo file (and are common to all the .nlogo models on this website).

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

8,271 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>