close Warning: BrowserModule failed with ConfigurationError: Look in the Trac log for more information.

Changes between Version 28 and Version 29 of OverSimDevelop


Ignore:
Timestamp:
Sep 10, 2009, 1:27:24 PM (15 years ago)
Author:
Ingmar Baumgart
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OverSimDevelop

    v28 v29  
    188188In order to route packets in a realistic way, the "length" parameter of the message should be set to an appropiate value. This is done manually by using the setBitLength(bits) or setByteLength(bytes) function when sending the message. Forgetting to set this value will default the length to a size of 0, potentially making measurements such as latencies less meaningful.
    189189
    190 All messages can encapsulate any other message (just avoid recursivity!) by using the encapsulate() function. To decapsulate the message, use decapsulate(). To peek the encapsulated message without decapsulating it, use getEncapsulatedMsg(). The length of the message is automatically updated.
    191 
    192 Additionaly, each message that is created must be deleted exactly once. Messages that aren't deleted will cause memory leaks, and those that are deleted twice can cause a segmentation fault. It is the responsibility of the programmer to know when a message should be deleted.
     190All messages can encapsulate any other message by using the encapsulate() function. To decapsulate the message, use decapsulate(). To peek the encapsulated message without decapsulating it, use getEncapsulatedMsg(). The length of the message is automatically updated.
     191
     192Additionally, each message that is created must be deleted exactly once. Messages that aren't deleted will cause memory leaks, and those that are deleted twice can cause a segmentation fault. It is the responsibility of the programmer to know when a message should be deleted.
    193193
    194194== 4. Implementing the overlay and application modules ==
     
    196196In 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.
    197197
    198 BaseOverlay:        Template overlay module class. All overlay modules should derive from it.[[BR]]
    199 BaseApp:            Template application module class. All application modules should derive from it.[[BR]]
    200 
    201 OverlayKey:         Class to describe overlay keys. Internally it stores the key as an bit array. [[BR]]
     198* [http://www.oversim.org/chrome/site/doc/neddoc/oversim.common.BaseOverlay.html BaseOverlay]: Template overlay module class. All overlay modules should derive from it.[[BR]]
     199* [http://www.oversim.org/chrome/site/doc/neddoc/oversim.common.BaseOverlay.html BaseApp]: Template application module class. All application modules should derive from it.[[BR]]
     200* [http://www.oversim.org/chrome/site/doc/doxy/classOverlayKey.html OverlayKey]: Class to describe overlay keys. Internally it stores the key as an bit array. [[BR]]
    202201                    Its value can be set in different ways when it's being initialized:[[BR]]
    203202{{{
     
    211210                    OverlayKey operations include equality (==), order (<, >) and range (isBetween(key1, key2)).[[BR]]
    212211
    213 IPvXAddress:        Generic IP address, can contain either an IPv4 address (IPAddress) or an IPv6 address (IPv6Address).[[BR]]
    214 TransportAddress:   A structure containing bot an IPvXAddress (field "ip"), and a port (field "port").[[BR]]
    215 NodeHandle:         A child class of TransportAddress, additionaly contains an OverlayKey (field "key"). In overlay and application modules, the variable "thisNode" contains the NodeHandle value representing the host. However, in application modules the "key" field may not be set.[[BR]]
     212* IPvXAddress:        Generic IP address, can contain either an IPv4 address (IPAddress) or an IPv6 address (IPv6Address).[[BR]]
     213* [http://www.oversim.org/chrome/site/doc/doxy/classTransportAddress.html TransportAddress]:   A structure containing bot an IPvXAddress (field "ip"), and a port (field "port").[[BR]]
     214* [http://www.oversim.org/chrome/site/doc/doxy/classNodeHandle.html NodeHandle]:         A child class of TransportAddress, additionaly contains an OverlayKey (field "key"). In overlay and application modules, the variable "thisNode" contains the NodeHandle value representing the host. However, in application modules the "key" field may not be set.[[BR]]
    216215
    217216Now, let's continue with the implementation.
     
    333332            myMessage->setByteLength(100);                   // set the message length to 100 bytes
    334333
    335             numSent++;                                       // update statistics
     334            RECORDS_STATS(numSent++);                        // update statistics
    336335
    337336            callRoute(randomKey, myMessage); // send it to the overlay
     
    373372
    374373    if (myMsg && myMsg->getType() == MYMSG_PONG) {
    375        numReceived++;
     374       RECORD_STATS(numReceived++);
    376375    }
    377376