The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.
powered by NetLogo
view/download model file: batV2.nlogo
This is a simulation of a Mobile Ad-Hoc Network. Each turtle is a wireless router/transmiter (xmiter). When any two xmiters are close enough they will establish a link (simulating a TCP/IP connection).
Each turtle has a halo around it showing it’s xmiter’s effective range. Each xmiter checks to see if any other xmiters are within range of it’s transmitter. If another xmiter is within range, it will create a link with it. If the distance between xmiters becomes greater than the transmission range, the link will be killed.
A “setup” button sets up the initial variables, and sets up the xmiters and their halos. The number of xmiters is variable by use of the “number-of-xmiters” slider.
The “go” button starts the random movement of all xmiters except one that is stationary near the bottom center.
The “xmiter-strength” slider varies the strength of the transmiter, and the size of the halo.
As the number of possible connections between each xmiter and all the others is a factorial function, the speed suffers with large numbers of xmiters. In an actual Ad-Hoc network this is not as much a problem because each router will be doing only itself.
This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
The next evolution of this would be to have it simulate a partial B.A.T.M.A.N network. (Better Approach To Mobile Ad-hoc Networking) by having t non mobile xmiters and a bunch of mobile ones. The goal would be to always have the network self configue to give the shortest path between the two stationary routers.
This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
This section could contain a reference to the model’s URL on the web if it has one, as well as any other necessary credits or references.
;;This program is to simulate a partial BATMAN (Better Approach To Mobile Ad-hoc Networking)
;;Version1--Starts with manV3.nlogo. Now bounded area and choise of halo or not
;;version2--Adds walkers
breed [halos halo]
breed [xmiters xmiter]
globals[ xg
yg
xx1
xy1
tempwho
]
to setup
;; (for this model to work with NetLogo's new plotting features,
;; __clear-all-and-reset-ticks should be replaced with clear-all at
;; the beginning of your setup procedure and reset-ticks at the end
;; of the procedure.)
__clear-all-and-reset-ticks
set-default-shape halos "circle 2"
set-default-shape xmiters "box"
create-xmiters num-xmiters
[ set-start-posi
]
ask xmiter 0 [
setxy 0 min-pycor + 5
set color red
make-halo
]
ask xmiter 1 [
setxy -10 max-pycor - 5
set color red
make-halo
]
ask xmiters [
if halos-off? = true
[
make-halo
]
]
end
to go
ask xmiters [
if (who > 1)[
rt random 20
left random 20
fd .1
if (xcor > max-pxcor - 2) or (xcor < min-pxcor + 2) or (ycor > max-pycor - 6) or (ycor < min-pycor + 6)
[
rt 180
]
]
set tempwho who
;;each xmiter must measure distance to each other and link if how-far < xmiter-strength
set xg xcor ;;xcor of main xmiter
set yg ycor
ask xmiters [ ;;starts a loop to find distance of every xmiter to the main one
if (who != tempwho) [
set xx1 xcor
set xy1 ycor
ifelse (how-far xg yg xx1 xy1 < xmiter-strength)
[
create-link-with xmiter tempwho
[set color red
set thickness .7 ]
]
[
if is-link? link-with xmiter tempwho
[
ask link-with xmiter tempwho [ die ]
]
]
] ;; end of who != tempwho
] ;;end of second ask xmiters
] ;;end ask xmiters
tick
end
to make-halo
hatch-halos 1
[set size xmiter-strength
set color lput 40 extract-rgb color
create-link-with myself
[tie
]
]
end
;;This is to make the inital position of the xmiters within the allowed boundry
to set-start-posi
setxy random-xcor random-ycor
if (xcor > max-pxcor - 2) or (xcor < min-pxcor + 2) or (ycor > max-pycor - 6) or (ycor < min-pycor + 6)
[set-start-posi]
end
;;Fromother program to figure distance
to-report how-far [x y x1 y1]
;; reports the distance between points (x,y) and (x1,y1)
report sqrt ((x1 - x) ^ 2 + (y1 - y) ^ 2)
end