## 3 System Design
### Architecture and Basic Ideas of TinyONet  
In order to realize the conceptual design and satisfy design principles, we designed several components with the Object-Oriented Design (OOD) methodology. As shown in Figure 2, TinyONet consists of many classes; _VirtualSensor_, _SensorPool_, _Slice_, _SyncSlice_, _SliceManager_, _AppManager_, subclasses of _Action_, subclasses of _ActionFactory_, _ActionManager_, _SensorMapper_, _InfoBus_, _Msg_, _Info_, subclasses of _Command_, _TxRx_, and _Property_. **Maintaining Sensing Data of Virtual Sensor**  
To provide the reusability of sensing data, _SensorPool_ component spawns _VirtualSensors_ as the same number of physical sensors on a sensing field. In _SensorPool_, _VirtualSensors_ are running to cache the sensing data reported from their corresponding physical sensors. By using _TxRx_ module, physical sensors communicate with TinyONet. Each _VirtualSensor_ has a Map-based cache where the  
Figure 2: Components of TinyONet. key is a property name and the value is the instance of _Property_ class. According to its application domain, each individual sensor application may require a new kind of data such as sensor's position or residual energy. Since data fields are stored in the Map-based cache, _VirtualSensor_ class can easily adopt new kinds of sensing data without ruining its internal structure. **Message Delivery between Components**  
Usually, it is not easy for external sensor applications to establish TCP/IP sessions with physical sensors because most WSNs use a non-IP protocol. Additionally, maintaining synchronous peer-to-peer sessions between virtual and physical sensors can cause an excessive communication and a computational overhead. For this reason, we designed the simple Message Oriented Middleware (MOM) [17], named _InfoBus_, using the Observer design pattern [18]. Several _SyncSlice_s, _SensorMapper_, and _SensorPool_ exchange sensing data and commands through _InfoBus_ using _Msg_, _Command_ and _Info_ classes. Unlike ordinary session-oriented communication, participants just throw packets into _InfoBus_ instead of direct connection to other parties. Then, these packets are automatically and asynchronously delivered to the target party through _InfoBus_. This architecture simplifies the multiparty communication dramatically and it enables physical sensors and TinyONet components to easily exchange messages without considering the complex session handling. **Providing Customized WSN Services and Dynamic Service Extension**  
Since each _Slice_ is designed as an independent thread, it can provide a customized WSN service to the requesting sensor application without disturbing other _Slice_s. In order to serve the customized WSN services, _SliceManager_ creates a _Slice_ which chooses various _Action_s to manipulate _VirtualSensors_' data depending on the request. Instead of squeezing all functions into TinyONet, it delegates requested functions to external loadable modules, _Action_ subclasses. With this mechanism, TinyONet serves external sensor applications that need various and unique WSN services for their own purposes. _AppManager_ has a main role to communicate with external sensor applications and it delivers the requests from sensor applications to _SliceManager_. It also manipulates a dynamic function loading in cooperation with _ActionFactory_ subclasses. By Using Strategy [19] and Abstract Factory [20] design patterns, _ActionFactory_ can support dynamic addition of new functions which were not installed at deployment time. **Providing Synchronous Access and the Node-Centric Communication**  
Since _Slice_ uses _VirtualSensors_' cached data, it cannot use unreported data residing on physical sensors. In most situations, this may not be critical because a data reported from physical sensors takes only a few seconds and this update can be reported promptly if a proper _Action_ is used. However, if an external sensor application needs to know the physical sensor's current data, TinyONet should provide synchronous access.