cnet's core Application Programming Interface

Descriptions of cnet's core functions are available from here. In each section functions are presented as C prototypes, often with an example of their use.

Most core functions return the integer 0 on success and the integer -1 on failure. The most recent error status is reflected in the global variable cnet_errno. All values of cnet_errno will be instances of the enumerated type CnetError. Functions do not set the value of cnet_errno to ER_OK if their execution was successful.

Note that these functions' names are prefixed with CNET_. Errors may be reported to stderr with CNET_perror() and their error message string accessed from cnet_errstr[(int)cnet_errno].

Application Layer functions

Physical Layer functions

WLAN and mobile node functions

Event handling functions

Checksum and CRC functions

Timer functions

Tracing functions

Node and per-link statistics

Formatting 64-bit integers

Pseudo-random number generation

Miscellaneous functions

API restrictions

  • Calls to the functions:

        CNET_write_application,
        CNET_read_application,
        CNET_enable_application,
        CNET_disable_application and
        CNET_set_handler(EV_APPLICATIONLAYER,...) and
        CNET_set_handler(EV_KEYBOARDREADY,...)
    

    are only valid if called from a node of type NT_HOST or NT_MOBILE.

  • Function calls to either the Application or Physical Layers are invalid when cnet is not running. This can occur when the node is rebooting, when the simulation is running under a windowing system, is paused, and a node's debug button is selected.

  • Calls to the function:

        CNET_set_position

    are only valid if called from a node of node type NT_MOBILE.

  • Calls to the functions:

        CNET_get_wlaninfo,
        CNET_set_wlaninfo
        CNET_wlan_arrival
    

    are only valid for links of type LT_WLAN.

  • Calls to the functions:

        CNET_set_nicaddr
    

    are only valid for links of type LT_LAN or LT_WLAN. Furthermore, you cannot set the attributes of link 0, the LOOPBACK link, nor set a NIC address to either the zero address, 00:00:00:00:00:00, or the broadcast address, ff:ff:ff:ff:ff:ff.


 cnet v3.3.1, written by Chris.McDonald@uwa.edu.au
 Last modified: Thu Apr 10 4:35PM 2014