## 6 Simulation Environment and Results  
### Simulation Environment  
The ns-2 simulation tool is used to evaluate the performance of the service discovery enhancements applied into OLSRv2 in a dynamic _ad hoc_ environment. The ns-2 engine is written as a mixture of Tool Command Language (Tcl) and C++, and the underlying protocols are written almost completely in C++. Protolib [53] is a library that provides a set of simple, cross-platform C/C++ classes that allow the development of network protocols that can run on ns-2 as ns-2 agents. We have used an OLSRv2 implementation in Java [54] and modified it to implement the improvements designed for service discovery. We can run the JOLSR v2 implementation in ns-2 thanks to a tool named AgentJ [55] that allows us to use the Java routing protocol implementations within ns-2 as Java agents without modifying the source code of ns-2. The presented experiments compare the new design of our service discovery protocol made for OLSRv2 with the previous one designed for OLSRv1. We also compare the performance of service discovery described here for the proactive OLSRv2 protocol with the service discovery for the reactive AODV routing protocol. We have modified the extension of AODV for service discovery proposed in [4] and implemented it here [56] to adapt it to our environment in ns-2.34. In the simulation, each mobile node changes its location within the subnet based on the random waypoint model: the node randomly selects a destination and moves towards that destination, at a speed uniformly distributed between 0 m/s and some maximum speed. We limit the maximum speed of a node to 10 m/s. Once the node reaches its destination, it waits for a pause time before choosing a random destination and repeating the process. The pause time is set to 10 s. The mobility pattern is read from the mobility file. In this model, each node is placed randomly in the simulated area (1000 \(\times\) 1000 m\({}^{2}\)). In ns-2, the distributed coordination function (DCF) of IEEE 802.11 for wireless LANs is used as the MAC layer protocol. The transmission range is about 250 m. The signal propagation model combines both a free space propagation model and a two-ray ground reflection model. See Table 1.  
In the simulations, many different scenarios have been considered with different numbers of nodes, in order to simulate different density networks. These nodes enter the network at random times and also leave the network after a random time. Once in the network, each mobile node changes its position based on the random waypoint model. This means that the number of services in the network varies over time, but its mean remains stationary, because new users join the network at the same time rate that they leave it. Random times follow exponential distributions. For simplicity, we assume that only five nodes act as servers. Each server offers just one different service. We measure several significant metrics in order to evaluate the performance of the service discovery mechanism designed for OLSRv2 and its feasibility: (1) the overhead introduced to the network; (2) latency to find a service; (3) the service discovery ratio (the efficiency of the service discovery); and (4) the false service discovery ratio (services discovered that were not available in the network out of the total number of services discovered). For the OLSRv1 and OLSRv2 parameters, we use a set of default parameters specified in both RFCs [6, 7]. For AODV, a SREQ is generated every 5 s. Eighty service requests are made during the simulation interval. The values of service latency calculated are the average over all of the requests. We represent two different scenarios for AODV. In the first one, nodes broadcast their SREQs throughout the entire network. In the second one, the flooding is limited by a flooding scope parameter to two hops.