close
Warning:
BrowserModule failed with ConfigurationError: Look in the Trac log for more information.
- Timestamp:
-
Apr 28, 2009, 1:44:09 PM (16 years ago)
- Author:
-
heep
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v19
|
v20
|
|
192 | 192 | == 4. Implementing the overlay and application modules == |
193 | 193 | |
194 | | In this section, we'll implement our overlay and application. But first, let's do a introduction about some of the important variable types used in OverSim. |
| 194 | In this section, we'll implement our overlay and application. But first, let's do a introduction about some of the important variable types used in !OverSim. |
195 | 195 | |
196 | 196 | BaseOverlay: Template overlay module class. All overlay modules should derive from it.[[BR]] |
… |
… |
|
201 | 201 | {{{ |
202 | 202 | #!cpp |
203 | | OverlayKey(); // initializes the key as UNSPECIFIED. While in this value, most of the key operations are invalid! |
| 203 | OverlayKey(); // initializes the key as UNSPECIFIED. |
| 204 | // While in this value, most of the key operations are invalid! |
204 | 205 | OverlayKey(5); // initializes the value as an 32-bit integer. |
205 | 206 | OverlayKey(buffer, 32); // initializes the value from the first 32 bytes of buffer. |
… |
… |
|
401 | 402 | |
402 | 403 | // overlay routines |
403 | | void initializeOverlay(int stage); // called when the overlay is being initialized |
404 | | void setOwnNodeID(); // (optional) called to set the key of this node (random otherwise) |
405 | | void joinOverlay(); // called when the node is ready to join the overlay |
406 | | void finalizeOverlay(); // called when the module is about to be destroyed |
| 404 | void initializeOverlay(int stage); // called when the overlay is being initialized |
| 405 | void setOwnNodeID(); // (optional) called to set the key of this node (random otherwise) |
| 406 | void joinOverlay(); // called when the node is ready to join the overlay |
| 407 | void finalizeOverlay(); // called when the module is about to be destroyed |
407 | 408 | |
408 | 409 | // obligatory: called when we need the next hop to route a packet to the given key |
409 | | NodeVector* findNode(const OverlayKey& key, // key to route to |
| 410 | NodeVector* findNode(const OverlayKey& key, // key to route to |
410 | 411 | int numRedundantNodes, // next hop candidates to return if we're not responsible for "key" |
411 | 412 | int numSiblings, // how many siblings to return if we're responsible for "key" |
… |
… |
|
414 | 415 | // obligatory: In general, called when we need to know whether "node" is amongst numSiblings closest nodes to "key". |
415 | 416 | // But normally it is called with "node" set to "thisNode", and asking whether we are responsible for "key" |
416 | | bool isSiblingFor(const NodeHandle& node, // which node (usually thisNode) we're referring to |
417 | | const OverlayKey& key, // key in question |
418 | | int numSiblings, // how many siblings we're querying about |
419 | | bool* err); // set to false when we couldn't determine the range |
| 417 | bool isSiblingFor(const NodeHandle& node, // which node (usually thisNode) we're referring to |
| 418 | const OverlayKey& key, // key in question |
| 419 | int numSiblings, // how many siblings we're querying about |
| 420 | bool* err); // set to false when we couldn't determine the range |
420 | 421 | |
421 | 422 | // obligatory: Set the maximum number of siblings that can be queried about in isSiblingFor(usually 1) |
… |
… |
|
541 | 542 | == 5. Configuring the Simulation == |
542 | 543 | |
543 | | Now that the overlay module is implemented, we still need to set up a network in order to run that overlay. To do that, we need to edit the omnetpp.ini file, or set up a custom configuration file. The configuration file should be located in the <OverSim>/simulation folder. |
| 544 | Now that the overlay module is implemented, we still need to set up a network in order to run that overlay. To do that, we need to edit the omnetpp.ini file, or set up a custom configuration file. The configuration file should be located in the !OverSim/simulation folder. |
544 | 545 | |
545 | 546 | == 5.1 Setting Parameters == |
546 | 547 | |
547 | | The user can set custom values for module parameters in the file omnetpp.ini (or whichever configuration file you use), or in default.ini for general default values, located in the <OverSim>/simulation folder. Parameters are hierarchic, separated by a dot for each layer. For example, setting a parameter for a specific overlay module in a node can be done as follows: |
| 548 | The user can set custom values for module parameters in the file omnetpp.ini (or whichever configuration file you use), or in default.ini for general default values, located in the !OverSim/simulation folder. Parameters are hierarchic, separated by a dot for each layer. For example, setting a parameter for a specific overlay module in a node can be done as follows: |
548 | 549 | |
549 | 550 | {{{ |
… |
… |
|
566 | 567 | Should a module parameter not be set in either configuration file, or match any wildcard, !OverSim will prompt the user to enter a value for each instance of the module. For simulations with a big amount of nodes, setting each parameter individually quickly becomes overwhelming. Therefore, it is recommended that every module parameter be assigned a default value in default.ini. |
567 | 568 | |
568 | | Notice that these are parameter paths, not to be confused with module paths from NED declarations (see Section 2.1). In this case, the parameter paths describe a set of modules and submodules to follow to reach the inner parameter we want. On the other hand, the module paths describe the folder under <OverSim>/src/ in which the declaration of the NED module will be found. |
| 569 | Notice that these are parameter paths, not to be confused with module paths from NED declarations (see Section 2.1). In this case, the parameter paths describe a set of modules and submodules to follow to reach the inner parameter we want. On the other hand, the module paths describe the folder under !OverSim/src/ in which the declaration of the NED module will be found. |
569 | 570 | |
570 | 571 | == 5.2 Creating our Configuration File == |
571 | 572 | |
572 | | Let's create a configuration file in <OverSim>/simulations called mysim.ini. |
| 573 | Let's create a configuration file in !OverSim/simulations called mysim.ini. |
573 | 574 | |
574 | 575 | The default.ini file contains the default values for many overlay parameters, and therefore it's highly useful to include it in our file. Since the simulator will use the first value it sees, the default value should go at the end. |
… |
… |
|
587 | 588 | #!cpp |
588 | 589 | [General] |
589 | | sim-time-limit = 1000s // set all simulations to last 1000 seconds |
590 | | network = "oversim.underlay.simpleunderlay.SimpleUnderlayNetwork" // this is a module path! do not confuse with parameter paths. |
| 590 | // set all simulations to last 1000 seconds |
| 591 | sim-time-limit = 1000s |
| 592 | |
| 593 | // this is a module path! do not confuse with parameter paths. |
| 594 | network = "oversim.underlay.simpleunderlay.SimpleUnderlayNetwork" |
591 | 595 | }}} |
592 | 596 | |
… |
… |
|
597 | 601 | Now, once the network type has been set, we can set the parameter values that we'll need. For example, let's create a configuration called "Example". There are two basic parts that should be configured: the churn type, and the node parameters. |
598 | 602 | |
599 | | The churn type tells OverSim how often it should add or delete nodes from the network. There are many churn types (e.g. NoChurn for a static network, LifetimeChurn for creating nodes with a given lifetime distribution, and so on); for a complete list see the ned files in <OverSim>/src/common. In our example, we'll use the less interesting NoChurn, which disables churn in our network. There are plenty of examples in <OverSim>/simulations/omnetpp.ini for all churns. |
| 603 | The churn type tells OverSim how often it should add or delete nodes from the network. There are many churn types (e.g. NoChurn for a static network, LifetimeChurn for creating nodes with a given lifetime distribution, and so on); for a complete list see the ned files in !OverSim/src/common. In our example, we'll use the less interesting NoChurn, which disables churn in our network. There are plenty of examples in !OverSim/simulations/omnetpp.ini for all churns. |
600 | 604 | |
601 | 605 | The second part are the node parameters. Two node parameters are obligatory: tier1Type (to specify the application module), and overlayType (for the overlay module). Further parameters can be specified for these application and overlay modules. For this example, we'll use the module !MyOverlayModules, which we declared in a previous chapter. |
… |
… |
|
688 | 692 | In order to run it, you need to setup your configuration in omnetpp.ini as explained in Section 4. Make sure that you selected default values for all parameters in default.ini, or you'll be prompted for a value when the simulation begins (for each module that uses that parameter!). |
689 | 693 | |
690 | | There are two ways to start !OverSim: by using the GUI (Tkenv) or through the command line (Cmdenv). To run !OverSim, enter the directory <OverSim>/simulations and run : |
| 694 | There are two ways to start !OverSim: by using the GUI (Tkenv) or through the command line (Cmdenv). To run !OverSim, enter the directory !OverSim/simulations and run : |
691 | 695 | |
692 | 696 | {{{ |