The cnet network simulator - layers and functions
Keywords: network simulator simulation protocol undergraduate teaching

### cnet's layers and functions

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

Most library 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`. Errors may be reported to `stderr` with `cnet_perror()` and their error message string accessed by indexing `*cnet_errstr[]` with `(int)cnet_errno`.

- Application Layer functions.
  - CNET_read_application
  - CNET_write_application
  - CNET_enable_application
  - CNET_disable_application
- Physical Layer functions.
  - CNET_write_physical
  - CNET_write_physical_reliable
  - CNET_write_direct
  - CNET_read_physical
- Timer functions.
  - CNET_start_timer
  - CNET_stop_timer
  - CNET_timer_data
- Event handling and tracing functions.
  - CNET_set_handler
  - CNET_get_handler
  - CNET_trace
  - CNET_trace_name
  - CNET_set_trace
  - CNET_get_trace
- Checksum and miscellaneous functions.
  - checksum_internet
  - checksum_ccitt
  - checksum_crc16
  - checksum_crc32
  - CNET_read_keyboard
  - CNET_set_debug_string
  - CNET_set_time_of_day
- Function restrictions.

### Function restrictions

Note that 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 node type `NT_HOST`. Function calls to either the Application or Physical Layers are invalid when cnet is not running (this can occur when the simulation is running under a windowing system, is paused, and a node's debug button is selected).

cnet was written and is maintained by Chris McDonald (chris@cs.uwa.edu.au)