This paper presents a programming experiment of a complex network
routing protocol for mobile ad hoc networks within the ReactiveML language.
Mobile ad hoc networks are highly dynamic networks characterized by
the absence of physical infrastructure. In such networks, nodes are
able to move, evolve concurrently and synchronize continuously with
their neighbors. Due to mobility, connections in the network can
change dynamically and nodes can be added or removed at any time. All
these characteristics -- concurrency with many communications and the
need of complex data-structure -- combined to our routing protocol
specifications make the use of standard simulation tools (e.g., NS,
OPNET) inadequate and network protocols appear to be very hard to
program efficiently in conventional programming languages.
In this paper, we show that the synchronous reactive model, as
introduced in the pioneering work of Boussinot, matters for
programming such systems. This model provides adequate programming
constructs -- namely synchronous parallel composition, broadcast
communication and dynamic creation -- which allow for a natural
implementation of the hard part of the simulation.
The implementation has been done in ReactiveML, an embedding of the reactive
model inside a statically typed, strict functional language. ReactiveML
provides reactive programming constructions with most of the features
of OCaml. Moreover, it provides an efficient execution scheme for
reactive constructs which made the simulation of real-size examples
feasible. Experimental results show that the ReactiveML implementation is
two orders of magnitude faster than the original C version; it was
able to simulate more than 1000 nodes where the original C version
failed (after 200 nodes) and compares favorably with the version programmed
in NAB.