Using Logging

Certain objects in the simulation (TcpSrc, Queue, etc.) may have an associated logger. This logger is specified when the object is created. Whenever the object undergoes a significant event, it notifies the logger.

Each different type of simulation object speaks to a different type of logger—since each simulation object has its own different significant events. For example, a Queue speaks to a QueueLogger with the routine

QueueLogger::logQueue(Queue& queue, QueueEvent ev, Packet& pkt)
See below for a full list.

Depending on how you want to record these events, you will use a different implementation of the logger. For example, QueueLoggerSimple makes a record for every packet that arrives or departs the queue, whereas QueueLoggerAveraging takes periodic snapshots of the queue (useful for keeping the logfile small). The currently implemented loggers are listed in loggers.

The loggers do not actually write their output directly; they call a Logfile object which actually does the writing.

                      +-------------------+
+------------+        | logger interfaces |        +-----------------+         +----------+
| simulation |  --->  | e.g. QueueLogger  |  --->  | logger          |  --->   | logfile  |
+------------+        | in loggertypes.h  |        | implementations |         +----------+
                      +-------------------+        +-----------------+

Preparing the logger

Logfile logfile("output.dat");
logfile.setStartTime(timeFromSec(40));
QueueLoggerSimple logQueue1; 
logfile.addLogger(logQueue1);
// set up a simulation... including e.g.
EventList eventlist;
Queue queue1(SERVICE, BUFFER, eventlist, logQueue1);
It can be helpful to assign memorable names to the items in the simulator. Many items derive from a class Logged, which simply keeps track of a unique ID and a memorable name. The Logfile can be told to keep track of which names go with which IDs.
queue1.setName("mybottleneckqueue");
logfile.writeName(queue1);
It can be helpful to record extra information in the logfile, e.g. describing the simulation setup.
logfile.write("numflows = 723");

Calling a logger from within the simulation

The simulator may notify a logger of these events.
logger interface argument meaning
TrafficLogger::logTraffic, invoked by most simulation objects when they receive or send a packet Packet& pkt, the packet which has moved
Logged& location, where the packet is moving
TrafficEvent ev PKT_ARRIVE, the packet arrived here
PKT_DEPART, the packet left here
PKT_CREATESENT, the packet was created here then sent on
PKT_DROP, the packet was dropped here
PKT_RCVDESTROY, the packet arrived here and was disposed of
QueueLogger::logQueue, invoked by a Queue whenever it receives a packet or completes a service Queue& queue, the queue of interest
QueueEvent ev PKT_ENQUEUE, an arriving packet was enqueued
PKT_DROP, an arriving packet was dropped
PKT_SERVICE, a packet completed its service
Packet& pkt, the packet in question
TcpLogger::logTcp, invoked by a TCP source whenever it updates its state TcpSrc& src, the TCP source
TcpEvent ev TCP_RCV
TCP_RCV_FR_END
TCP_RCV_FR
TCP_RCV_DUP_FR
TCP_RCV_DUP
TCP_RCV_3DUPNOFR
TCP_RCV_DUP_FASTXMIT
TCP_TIMEOUT

Modifying/extending the logging system

Analysing logs

We provide an import routine for reading logs into R.