12.07.2015 Views

PiccSIM Manual.pdf

PiccSIM Manual.pdf

PiccSIM Manual.pdf

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PiccSIM</strong> <strong>Manual</strong><strong>PiccSIM</strong> version 0.81<strong>PiccSIM</strong> Toolchain version 0.2Mikael Pohjola andShekar NethiHelsinki University of TechnologyJune, 20091


Contents1. Introduction ............................................................................................................................................... 31.1. <strong>PiccSIM</strong> Architecture ....................................................................................................................... 32. Installation .................................................................................................................................................. 42.1. Software Requirements ..................................................................................................................... 42.2. Installing <strong>PiccSIM</strong> on Matlab ........................................................................................................... 42.3. Installing ns-2 with <strong>PiccSIM</strong> capabilities .......................................................................................... 52.3.1. Step 1, Installing ns-2 ................................................................................................................ 52.3.2. Step 2, Integration of <strong>PiccSIM</strong> Code into Ns2.29 .................................................................... 52.3.3. Additional Installed ns-2 features .............................................................................................. 63. <strong>PiccSIM</strong> Reference .................................................................................................................................... 73.1. Simulation GUI ................................................................................................................................ 73.2. <strong>PiccSIM</strong> Block Library ...................................................................................................................... 73.2.1. Node Block Configuration ........................................................................................................ 93.2.2. Packet types and node block configuration .............................................................................103.2.3. Notes on Sampling Times ........................................................................................................113.3. Network Settings GUI ......................................................................................................................123.4. Known Problems or Bugs .................................................................................................................144. Examples .................................................................................................................................................. 154.1. Starting <strong>PiccSIM</strong> ..............................................................................................................................154.2. Creating a <strong>PiccSIM</strong> simulation model ............................................................................................154.3. Example 1 – Control with wireless measurements ..........................................................................174.4. Example 2 – Event driven control ...................................................................................................174.5. Example 3 – Event driven control, with triggers .............................................................................175. Remote User Interface ............................................................................................................................. 175.1. How to use the remote interface ......................................................................................................186. Papers on <strong>PiccSIM</strong> ................................................................................................................................... 182


Unzip the zip package into a desired directory, e.g. <strong>PiccSIM</strong>Add the <strong>PiccSIM</strong> path to the Matlab path, e.g. addpath <strong>PiccSIM</strong>2.3. Installing ns-2 with <strong>PiccSIM</strong> capabilitiesInstall first ns-2 (step 1) according to the instructions below, then the <strong>PiccSIM</strong> specific add-ons (step 2).Read also the known problems.2.3.1. Step 1, Installing ns-2Download ns-allinone-2.29.tar.gz into the folder /home/username/Desktop/Ns2/. Replace usernamewith your user name.http://www.isi.edu/nsnam/dist/ns-allinone-2.29.2.tar.gzDownload the ns-2 patch. This Fedora core 5 patch fixes various compatibility issues with new gcc4.x.x, alsoworks fine for Ubuntu.http://autsys.tkk.fi/en/attach/Control/ns2292-gcc410.patch1. Change to ns2 directory cd /home/username/Desktop/Ns2/2. Un-tar the installation files tar -zvxf ns-allinone-2.29.2.tar.gz3. Change to ns-allinone directory cd ns-allinone-2.294. Copy this ns-2 patch to the ns-allinone-2.29 directory5. Apply the patch patch -p1 < ns2292-gcc410.patch6. Install the packages (otcl, tclcl, ns-2 , nam, tcl, tk) ./install7. Change to ns2 directory cd ns-2.29Validate your installation by doing ./validate or ./validate-full, the latter will start simulations forall test scenarios available in the tcl/ex/test/ folder.The next step is to export path variables: Either copy-paste the following commands in your terminal beforerunning ns-2 or update the ~/.bashrc file and avoid re-setting path variable, every time you use a newterminal to run ns-2. If you are logged in as root, then you need to add the path variables at the followinglocation as well: open/create /root/.bashrc,Open /home/username/.bashrc file, and add the following path variablesexport NS_HOME=/home/username/Desktop/Ns2/ns-allinone-2.29export PATH=$NS_HOME/ns-2.29:$NS_HOME/tcl8.4.11/unix:$NS_HOME/tk8.4.11/unix:$NS_HOME/bin:$PATHexport LD_LIBRARY_PATH=$NS_HOME/tcl8.4.11/unix:$NS_HOME/tk8.4.11/unix:\$NS_HOME/otcl-1.11:$NS_HOME/lib:$LD_LIBRARY_PATHexport TCL_LIBRARY=$NS_HOME/tcl8.4.11/libraryMost of the bug reports we are receiving are users facing problems with installing Ns2 (step 1) and this isnot necessarily related to <strong>PiccSIM</strong> installation. If you have problems installing or questions using ns-2,please check the ns-2 support. We do not help in purely ns-2 related issues.http://www.isi.edu/nsnam/ns/ns-problems.html<strong>PiccSIM</strong> should work on Cygwin, Virtual Box with Ubuntu or any other Linux distributions. For now wedo not provide technical support for Cygwin or any Linux distribution other than Ubuntu. We strongly5


ecommend researchers to use the Ubuntu distribution with Ns2.29 and use two different PC for MATLABand ns-2, since these are computationally heavy applications. Also we do not have plans to upgrade<strong>PiccSIM</strong> to latest version of ns-2 (2.31).2.3.2. Step 2, Integration of <strong>PiccSIM</strong> Code into Ns2.29This section assumes that you have successfully installed ns-2 (Step 1). The following extension packagewill now configure ns-2 to have <strong>PiccSIM</strong> capabilities.Download the <strong>PiccSIM</strong> extension package to the ns-2.29 directoryhttp://autsys.tkk.fi/en/attach/Control/<strong>PiccSIM</strong>_ns-2.29_bundle_v1.0.tar.gz.Download the installation scripthttp://autsys.tkk.fi/en/attach/Control/install_piccsim_v1.shDownload the ns-2 server java files to the Desktophttp://autsys.tkk.fi/en/attach/Control/<strong>PiccSIM</strong>-ns2.tar.1. Untar the package tar -zvxf <strong>PiccSIM</strong>_ns-2.29_bundle_v1.0.tar.gz2. Set the permission chmod 755 install_piccsim_v1.sh3. Install <strong>PiccSIM</strong> ./ install_piccsim_v1.shThe <strong>PiccSIM</strong> platform needs a server on the ns-2 computer communicating with the <strong>PiccSIM</strong> GUI forstarting and stopping the network simulation. This is installed by:1. Unpack the package tar -zvxf <strong>PiccSIM</strong>-ns2.tar.gzThe server is started by running sudo java RunNS2Server. An optional argument for the workingdirectory, where the tcl scripts are placed, can be given, e.g. sudo java RunNS2Server ./ScriptsThe server can also be run with the script sudo “Start <strong>PiccSIM</strong> server.sh”, where the PATHvariables are automatically set. Note: The present default directory for the <strong>PiccSIM</strong> network server is/home/ns-2/Desktop/<strong>PiccSIM</strong>/, you can change this, by editing “Start <strong>PiccSIM</strong> server.sh” toyour current working directory and the ns-2 directory.2.3.3. Additional Installed ns-2 featuresThe above <strong>PiccSIM</strong> add-on installs the following additional features to ns-21. LMNR (Localized Multiple Next-hop Routing protocol)2. SIRP (Source Initiated Routing Protocol) Routing over 6LowPAN Networks3. Time-synchronization mechanism between Simulink and ns-2 with new scheduler for ns-2 [P3].4. Node location update mechanism from Simulink to ns-2 for mobile scenarios [P6].5. Channel model for indoor propagation environment (need documentation) [P3].6


3. <strong>PiccSIM</strong> Reference3.1. Simulation GUIThe main GUI of the Toolchain, shown in Figure 2, is presented in [P3]. It is used for selecting simulationmodels, accessing the other design tools, such as network configuration, controller tuning and codegeneration, and running simulations.The Simulink model and ns-2 TCL-script are selected with the Browse buttons. The simulated network isconfigured with the ns-2 scriptor (Section 3.3) accessed with the Network Settings button.There are buttons for starting and stopping simulations. They will start the Simulink model and ns-2simultaneously. With the Get ns-2 results button, some simple statistics over packet drops and delay arecalculated from the simulation trace-file. Debug ns-2 will show the text output of ns-2. Get ns-2 trace file willdownload the ns-2 simulation trace-file.Figure 2. <strong>PiccSIM</strong> Toolchain main graphical user interface.Note: some of the features (controller tuning and code generation) are not available in this release.3.2. <strong>PiccSIM</strong> Block LibraryThe <strong>PiccSIM</strong> library, shown in Figure 3, is accessed from the Toolchain GUI by pressing the Open<strong>PiccSIM</strong> library button. The library contains blocks for sending and receiving packets over the simulatednetwork. It also contains the time-synchronization mechanism block, which must exist in all <strong>PiccSIM</strong>simulation models. See Table 1 for a list and explanation of all the blocks.7


TimestampsTimestampsNodeSend to N 1 T 1ID = 0NodeSend to N 1 T 1ID = 0NodeID = 0Data N 1 T 1Data N 1 T 1NodeNode send onlyNode receive onlyNodeID = 0Dummy nodedo { ... } whileSynchronize with Ns -2PositionSend position to ns -2<strong>PiccSIM</strong> library v 0.81Mikael Pohjola , 3/2009Helsinki University of TechnologyTimestampHybrid TriggerTimestampReceive TriggerIn1Out1Radio hybrid triggerRadio event triggerTriggeredSubsystemUtilyTo scopeFigure 3. <strong>PiccSIM</strong> library.Before simulation, the network nodes need to be configured with the source and destination IDs of thecommunicating nodes, and the data types and dimensions of the signals. Configuration is done by doubleclickingthe block and typing the desired values in the node mask, shown in Figure 4. The blocks supportboth event based (with trigger signals) and periodic transmission. See 3.2.1 and the example in 4.3 for howto configure the node blocks.The conversion to UDP packets and back to Simulink signals is done in network node blocks. The previousvalues are kept until a new packet arrives. Since the information transmitted over the network is actuallyincluded in the packet, the choice of data types and information sent is reflected in the packet size, as itwould be in a real system.Table 1. <strong>PiccSIM</strong> library block list.BlockNodeNode send onlyNode receive onlyDummy nodeSynchronize with ns-2UtilSend position to ns-2FunctionNetwork node block for sending and receiving packets over the simulatednetwork.Same as above, but only for sending.Same as above, but only for receiving.Node that does not send or receive data, but may act as a relay. This block isnecessary, because all nodes in the Network settings tool must have acorresponding Simulink block.Block implementing the time-synchronization mechanism between thesimulation models. Must always be included in the simulation model.Contains utility blocks that <strong>PiccSIM</strong> needs.Block for updating node position from Simulink to the ns-2 simulator, for8


simulations with mobile nodes.Radio event trigger Can be used to trigger a subsystem when a packet has arrived to a node block, i.e.event based action. The target subsystem must have an enable port for triggering.Radio hybrid trigger Same as above, but an event is generated also if no packet has arrived for aspecified maximum time.Triggered Subsystem Subsystem to be used with the Radio triggers.To scope Block for displaying signals in the remote user scope. See Chapter 5.3.2.1. Node Block ConfigurationThe network node Simulink block configuration mask shown in Figure 4 defines the communicationsource and destination, packet and data dimensions and types as explained in Table 2. The node receiveandsend only blocks have similar configuration, but only with either the send or receive options. Thedummy node has only the node ID and position.Figure 4. Node configuration mask.9


Table 2. Node configuration options.Option FormatNode ID Integer The ID of the node. Node IDs must be sequential and start from zero.SendheaderDrop downlistChoose between sending a timestamp or a sequence number in the packetheader. The timestamp or sequence number will be outputted in thereceiving block.SendscheduleDrop downlistDetermines how the radio should be triggered. Either a fixed sampling time isused, or radio transmission can be triggered using a trigger inport.SendintervalDouble The send interval of transmission, i.e. the sampling time.SendenableinputSendpacket typesSend datatypesCheck-boxVector ofintegersCell arrayof cell arraySend to ID Check-boxinputSend to ID Cell arrayof vectorsReceive Vector ofpacket types integersReceivedatadimensionsReceivedata typesCell arrayof cell arrayof vectorCell arrayof cell arrayCheck this box to gain access to an input port for enabling or triggeringsending. A packet is sent if this input is nonzero.The block can send different packet types, containing different data types. Forevery packet type and send to ID, there will be a separate input port.The data types in each packet type are declared here. The data types aredefined as a cell array of strings, each string specifying the signal type of thesignal to be sent. The data types must match the data types of the inputtedSimulink signal. The cell array must contain as many cell arrays as there arepacket types.Check this box to gain access to an input port for specifying the destinationnode ID at run-time. Works only when using one packet type.The IDs of nodes to send packet types. There must be as many vectors ofdestination IDs as there are packet types.The block can receive different packet types, containing different data types.For every packet type and receive from ID, there will be a separate outputport.Vectors defining the dimensions for every packet and data type. A cell arrayfor every packet type and data types.The data types in each received packet type are declared here, similarly as forthe Send data types field. The data types must be identical to the send datatypes of the corresponding send block.Vector of source IDs to receive data from. For every ID, there will be aseparate output port.X- and Y- coordinate of the wireless node. Used by the ns-2 scriptor only forwireless networks.Receive Vector offrom nodes integersCoordinates TwoelementvectorNS-2IP String The IP address of the ns-2 network simulator. Can be left as is. The Toolchainwill create the corresponding Matlab variable.On configuration, the block will create the appropriate input and output ports. The signals connected to theinput port (Send to) must have the same data types and dimensions as the ones specified in the block mask.The Timestamp output port is a matrix signal, one element corresponding to the received timestamp orsequence number of a source/packet type combination.3.2.2. Packet types and node block configurationA node block can send packets with different data types, which is reflected in the simulation as packet withdifferent sizes. The packet type is a user selected integer to distinguish between packets containing different10


data. To understand how to configure more complicated and multiple packet types the following examplesare given.Consider sending two doubles from node 0 to node 1 and one double and two bytes to node 2, you shoulddo the following configuration. We call the packet with the two doubles type 0 and the second we give thetype number 1. The required configuration is listed in Table 3. Notice how the two packet types sent bynode 0 are separated into the packet types and data type configurations of node 1 and node 2. Notice that atthe receiving side you also have to specify the dimensions of the receiving signals. On sending this is doneimplicitly based on the signal widths.Table 3. Node configuration, example 1.Node configuration Node 0 Node 1 Node 2Send packet types [0, 1]Send data types{{‘double’},{‘double’, ‘int8’}}Send to ID [1, 2]Receive packet types [0] [1]Receive data dimensions {{[2]}} {{[1], [2]}}Receive data types {{‘double’}} {{‘double’, ‘int8’}}Receive from nodes {[0]} {[0]}In the next example two nodes are transmitting different packet types to one node. Now the same packettypes are transmitted from node 1 and node 2 to node 0. Now the configuration is as the one in Table 4.Notice how the receive data dimensions and receive from nodes fields of node 0 are configured. If node 3 isadded, sending the same packet type as node 1, node 0 would be configured with a Receive from nodes of{[1, 3], [2]}.Table 4. Node configuration, example 2.Node configuration Node 0 Node 1 Node 2Send packet types [0] [1]Send data types {{‘double’}} {{‘double’, ‘int8’}}Send to IDReceive packet types [0, 1]Receive data dimensions {{[2]}, {[1], [2]}}Receive data types {{‘double’},{‘double’, ‘int8’}}Receive from nodes {[1], [2]}3.2.3. Notes on Sampling TimesSince Simulink is a time-driven simulator, asynchronous and event driven simulations are more difficult todo (except when using Stateflow). Here are some notes on the implementation issues of asynchronicwireless systems and how they should be implemented when using the <strong>PiccSIM</strong> simulator. You can checkthe sampling times of your model by selecting Format->Port/Signal Displays-> Sample Time Colors or byusing the Probe block.11


It is assumed that the nodes are not time-synchronized. This means that their internal clocks have differentoffsets and the send instants (sampling time) occurs with different offsets compared to each other. This isaccomplished automatically in the node input ports by adding an offset to the sampling time of the Send toports. Thus, the blocks driving an input to the node blocks must inherit their sampling time (i.e. specify asampling time of -1, or use a rate transition with sampling time -1 and uncheck the Ensure deterministicdata transfer option).The output of the node blocks are fixed in minor steps, i.e. the fastest rate of the model. This means thatyou have to insert a rate transition or zero order hold block before e.g. a discrete-time algorithm. You canalso build triggered subsystem and use the ready-made trigger blocks to do event-based processing. Note thatthe resolution of the event-based algorithm is that of the model step size. To circumvent this, the maximumsolver step size in the Simulink model configuration dialog can be reduced, or you can use blocks withshort sampling times, forcing a short simulation step size.The packet transmission can also be enabled with a enable signal to the node Send enable in-port (accessedby checking the Send enable input option). A packet is sent at the sampling time only if the signal value tothis port is nonzero. If multiple destinations and packet types are used, this signal must be a matrix signal,one element for every destination/packet type combination.Transmission can also be trigged by selecting the Send schedule to Triggered. A trigger port becomesavailable. Transmission is triggered at either when the input to this port changes from zero (or negative) topositive or positive to zero (or negative). The time-resolution of the triggering is that of the driving block. Ifa more accurate triggering is needed, the sampling time can be reduced. Both triggering and enabling canbe used.3.3. Network Settings GUIIn the network settings window shown in Figure 5, configuration scripts for the network simulator ns-2 arecreated with a user-friendly GUI, where the user can specify the settings of the ns-2 network simulator,including the node positions, network protocols and simulation parameters, and some <strong>PiccSIM</strong> relatedsimulation settings. This includes the propagation model, routing and MAC protocols, node movementpattern, node connection pattern, etc. It is also possible to create additional simulated traffic.The TCL script is by default saved as default.tcl in the current directory. The main GUI willautomatically use this file. The file can be later edited, or a custom file can be used by browsing it from themain GUI. The network specification script is automatically loaded to the ns-2 computer before eachsimulation, so that the current network configuration is used.12


Figure 5. Network settings GUI.On the right side of the window there are some general options of the network and simulation. The Setenergy model button opens up a small window, where the user can specify an energy model for the wirelessnodes. The <strong>PiccSIM</strong> Settings button opens a window where are settings specific to the <strong>PiccSIM</strong>environment, listed in Table 3. The Generate script button generates the configuration script of ns-2 andsaves it to the file default.tcl.The toolbar on the top of the window has some node buttons. The first button is for moving the location ofnodes in the GUI. The second button is the Edit node button, which opens a window for adding orremoving nodes, or changing the settings of the existing nodes. Note that when opening the networksettings window, all the nodes specified in the Simulink model are automatically added to the networkmodel. The next button, the Node config button, opens a window with general network settings. The firsttab is for wireless nodes and their protocols, layers etc. The second tab is for wireless node movementsettings. The third tab is for setting up LANs for wired nodes.The Link button opens the link configuration. It is for wired nodes only. The Save button saves the linkparameters. The editing of links is done with the Edit button. To remove a link, the source and destinationnode IDs must be given. The last button is the Agent button, which opens the agent configuration. Here theuser can set the agents attached to the nodes and add traffic between them. The agents can be added by13


specifying the agent type, node ID and then changing the agent parameters as needed and clicking the Savebutton. Finally, the Add agent button adds the agent to the configuration. Traffic can be assigned aftercreating the agents. The sender agent and the receiver agent can be selected by clicking the tree item fromthe right panel. After specifying the traffic type, start and end time, this traffic event can be saved using theConfirm button. The specified traffic is simulated with the rest of the traffic from the Simulink model.In the file menu the user can save the generated script to another name or load a previously generated scriptto the text pane. Loading a script also saves the loaded script to the name default.tcl. Loading a scriptwill not affect the configuration in the GUI.Table 5. <strong>PiccSIM</strong> specific network settings.SettingAutogenerate tapsUpdate positionsUse syncingSimulink IPHello intervalGenerate taps for capturing transmitted packets from Simulink. Keep always checkedif running simulations with <strong>PiccSIM</strong>.For generating a tap for node position update mechanism.Use Simulink synchronized ns-2 scheduler and generate taps for receivingsynchronization messages. Keep always checked if running simulations with<strong>PiccSIM</strong>.The IP address of the Simulink computer.Hello interval in seconds for the AODV routing protocol.3.4. Known Problems or BugsThe following is a list of known problems and bugs:- ns-2 may need to run with administration privileges (super user) to access the network interfaces.Do e.g.sudo bashjava RunNS2Server /home/ns-2/Desktop/<strong>PiccSIM</strong>/- Simulink can have a hard time determining dimensions of signals to send. Add a SignalSpecification block and specify the signal dimension on the signal before the Send to… nodeinput port. When sending multiple signals of the same type, the cell array must contain equallymany elements as the signal dimension, i.e. one per signal in the bus.- The Java program on the ns-2 computer needs the Sun Java virtual machine, not the open sourceimplementation to function properly. Otherwise it will hang on simulation start (differences inimplementation of XML parsing).- For large simulation models, it may take some time to start the Simulink model. The GUI mightthink that the simulation has stalled and will stop the ns-2 simulation. This can be fixed byincreasing the counter limit in Toolchain.m, function updateTime.- The Network Scriptor is not very user friendly, e.g. settings cannot be saved. This will be improvedin future releases.- When using the node position updating mechanism, ns-2 may throw a segmentation fault. Thereason is at the moment still unknown.- When using the example files, remember to change your Simulink IP address in the tcl files,otherwise the simulations will not work (get stuck).14


4. Examples4.1. Starting <strong>PiccSIM</strong>To start the <strong>PiccSIM</strong> simulator the GUI on the Simulink computer and the ns-2 server on the ns-2computer must be started. On the ns-2 computer run the java program that will communicate with the<strong>PiccSIM</strong> GUI and start and stop the ns-2 network simulation model on command. Execute javaRunNS2Server or use the script “Start <strong>PiccSIM</strong> server.sh” (This may need to be run from a superuser account). To start the <strong>PiccSIM</strong> simulator GUI in Matlab, go to the folder <strong>PiccSIM</strong>\Toolchaindirectory and type Toolchain in the Matlab prompt. This will open the simulation GUI. Select a desiredSimulink model and TCL-file and press Start Simulation to run the simulation.Before simulation, the ns-2 TCL script can be generated with the Network Settings tool and the Simulinkmodel edited. Press the Open <strong>PiccSIM</strong> library button to access the node blocks for sending and receiving ofmessages over the simulated network. See 3.2.1 on the settings for these blocks. Remember also to input thecorrect IP address of the ns-2 computer in the GUI.The examples provided with <strong>PiccSIM</strong> are simple and demonstrate only certain aspects of how to use the<strong>PiccSIM</strong> simulator. The examples are described in the following subsections.4.2. Creating a <strong>PiccSIM</strong> simulation modelThe following steps will guide you on the process of creating a <strong>PiccSIM</strong> NCS simulation model. Anillustration of the tasks is on the next page.1. Create a new Simulink model and save it.2. Change the Matlab current directory to the <strong>PiccSIM</strong>\Toolchain directory.3. Open the <strong>PiccSIM</strong> Toolchain by typing Toolchain in the Matlab prompt.4. Type the IP address of the ns-2 computer in the corresponding field in the main GUI. The addressis exported to a Matlab base workspace variable NS2_IP. This is used by the radio blocks.5. Browse for the created Simulink model with the Browse button. Open the model with the Editbutton.6. Open the <strong>PiccSIM</strong> library by pressing the button in the lower right corner of the main GUI.7. Create the simulation model. The network node blocks can be dragged from the <strong>PiccSIM</strong> library.For node setup configuration see Section 3.2.1.8. Finally add the Synchronize with ns-2 block to the model. This step must always be done to ensuretime-synchronization between the two simulators and correct simulation results.9. Now create the network model. Press the Network Settings button. This will open the ns-2 scriptor.10. Nodes found in the Simulink model are all located at the upper left corner. Drag them to thedesired coordinates. The coordinates are displayed in the lower border of the network window.11. Press the Node config button and set the desired network settings. Other configurations can also bedone, e.g. wired links and traffic with the other buttons.12. The <strong>PiccSIM</strong> specific options can be changed by pressing the <strong>PiccSIM</strong> Settings.13. Press the Generate Script button. This will save the network simulator configuration scriptdefault.tcl.14. Close the scriptor and answer yes to the message box asking if you want to save the node positionsto the Simulink model file.15. Now you can simulate the model by pressing Start Simulation.15


Figure 6. Illustration on how to create a <strong>PiccSIM</strong> simulation model.16


4.3. Example 1 – Control with wireless measurementsA simple example of two control loops with measurements transmitted over a wireless network is located inthe Examples folder. You can open the model example1.mdl in the <strong>PiccSIM</strong> Toolchain and study themodel. It consists of two identical control loops. The corresponding TCL, example1.tcl, script defines awireless network with four nodes. The first control loop (nodes 0 and 1) extends over one hop, whereas theother (nodes 2 and 3) over three hops (the range of the used IEEE 802.15.4 radio is about 15 m). Thenetwork is depicted in Figure 5.In the TCL script, set your IP address of the Simulink computer. Replace the IP address in the followinglines:$bpf($i) filter "src 192.168.2.100 and dst port $p"$bpf($i) filter "src 192.168.2.100 and dst port 23201"with your Simulink computer IP.By running the simulation, one can notice that there is a difference between the responses of the twoidentical control loops, caused by the network.4.4. Example 2 – Event driven controlThe second example (example2.mdl and example2.tcl) demonstrates how to do event driven simulations.The setup is similar to example 1, but the sensor implements a send-on-delta method. The sensor sends anew measurement only if the measurement differs by a certain amount (variable SOD_threshold inMatlab workspace) from the previously sent measurement. This is done to conserve bandwidth and onlycommunicate if there is any change. In the implementation, the send enable signal is used to tell the nodeblock at which sampling times it is allowed to transmit.The controller is event driven: it executes only if it has received a new measurement. It is implemented as aPI controller, where the integral takes into account the time since the last execution step. The controloutput changes thus when the controller has received a measurement from the sensor. Note that the hybridtrigger has a maximum time of 1 s, so the control algorithm will be calculated at least every 1 s, even if nomeasurements are received.4.5. Example 3 – Event driven control, with triggersIn the third example, the same case as in example2 is used, but now the transmission is done based ontriggers. Note that now the sampling time must be specified in the trigger logic (block: example3/Sensorwith send-on-delta/Unit Delay), while it was in example2 inherited from the node block. Now thesampling is done at a fixed interval with no offset (which was previously added by the node block). Thismeans that every node (if we would use more, as in example1) would transmit at exactly the same time,causing collisions. Now the user has to take care of the sampling time offsets between different nodes. SeeSection 3.2.2 for more information.5. Remote User InterfaceFor those who do not have the possibility to setup the <strong>PiccSIM</strong> platform or do not want to, there is thepossibility to use <strong>PiccSIM</strong> remotely. Simulation models can be uploaded through a Java applet interfaceand the simulation results are displayed in a scope. You need only to install the <strong>PiccSIM</strong> Toolchain on acomputer with Matlab.17


There is the additional benefit, that all the simulation runs are stored in a database for later retrieval. Theremote user interface is based on the MoCoNet platform. The remote researchers interface is available athttp://www.control.hut.fi/dev/MoCoNet/<strong>PiccSIM</strong>.html.5.1. How to use the remote interfaceIn order to do simulations with the remote interface, you need to build a <strong>PiccSIM</strong> simulation model as inthe previous examples of Chapter 4. To observe the simulation results, add the To scope block to the modeland connect the signals you wish to observe. These signals will be shown in the user scope of the remoteinterface.You can use a mux block to record several signals with one To scope block, but only the first four signals aresaved in the database. Double click the block and define the sampling time of the signal (this is theobservation sampling time, can be different from the actual sampling times of the signals). Signal namesmust be specified for every signal. Separate the signal names with semicolon “;”.In the Researcher’s interface, select the simulation model and possible additional files that the simulationmodel needs. Select NS-2 network and add your TCL-script to the list of network configuration files. PressStart simulation.Hint: To ensure that the model has all the variables accessible at the remote simulator, you can save yourworkspace to a mat-file and add it asan additional file. Remember to load the file on model init: ModelProperties->Callbacks->InitFcn: load Your_init_file.mat.To reload old simulation results, press Load old experiment to open the dialog, where your previoussimulations are displayed. Notice that old runs may be purged from the database. You can save the resultsfrom the scope to a txt-file, which can be imported into Matlab.6. Papers on <strong>PiccSIM</strong>[P1] S. Nethi, M. Pohjola, L. Eriksson, R. Jäntti. Platform for Emulating Networked ControlSystems in Laboratory Environments. The 8th International Symposium on a World ofWireless, Mobile and Multimedia Networks, WoWMoM 2007. Helsinki, Finland. June 18-21, 2007.[P2] S. Nethi, M. Pohjola, L. Eriksson, R. Jäntti. Simulation case studies of wireless networkedcontrol systems. In Proc. 10 th ACM/IEEE International Symposium on Modelling, Analysisand Simulation of Wireless and Mobile Systems (ACM/IEEE MSWiM 2007). Crete,Greece, Oct 22-26, 2007.[P3] T. Kohtamäki, M. Pohjola, J. Brand and L.M. Eriksson. <strong>PiccSIM</strong> Toolchain – Design,Simulation and Automatic Implementation of Wireless Networked Control Systems. IEEEInternational Conference on Networking, Sensing and Control, Okayama City, Japan,March 26-29, 2009.[P4] M. Pohjola, Adaptive Control Speed Based on Network Quality of Service, to be publishedin 17th Mediterranean Conference on Control and Automation, June 24-26, 2009,Makedonia Palace, Thessaloniki, Greece.[P5] M. Pohjola. Adaptive Jitter Margin PID Controller. 4 th IEEE Conference on AutomationScience and Engineering. Washington, D.C., USA. August 23-26, 2008.18


[P6] M. Pohjola, S. Nethi, R. Jäntti. Wireless Control of Mobile Robot Squad with Link Failure.In Proc. First Workshop on Wireless Multihop Communications in Networked Robotics.Berlin, Germany. 4 th of April 2008.[P7] M. Pohjola, S. Nethi, R. Jäntti. Wireless Control of Multihop Mobile Robot Squad. IEEEWireless Communications, Special Issue on Wireless Communications in NetworkedRobotic February, 2009.19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!