next up previous contents index
Next: 21.4 Trace File Format Up: 21. Trace and Monitoring Previous: 21.2 Library support and

   
21.3 The C++ Trace Class

Underlying C++ objects are created in support of the interface specified in Section 21.3 and are linked into the network topology as network elements. The single C++ Trace class is used to implement the OTcl classes Trace/Hop, Trace/Enque, Trace/Deque, and Trace/Drop. The type
_
field is used to differentiate among the various types of traces any particular Trace object might implement. Currently, this field may contain one of the following symbolic characters: + for enque, - for deque, h for hop, and d for drop. The overall class is defined as follows in trace.cc:

        class Trace : public Connector {
         protected:
                int type_;
                nsaddr_t src_;
                nsaddr_t dst_;
                Tcl_Channel channel_;
                int callback_;
                char wrk_[256];
                void format(int tt, int s, int d, Packet* p);
                void annotate(const char* s);
                int show_tcphdr_;  // bool flags; backward compat
         public:
                Trace(int type);
                ~Trace();
                int command(int argc, const char*const* argv);
                void recv(Packet* p, Handler*);
                void dump();
                inline char* buffer() { return (wrk_); }
        };
The src
_
, and dst
_
internal state is used to label trace output and is independent of the corresponding field names in packet headers. The main []recv method is defined as follows:
        void Trace::recv(Packet* p, Handler* h)
        {
                format(type_, src_, dst_, p);
                dump();
                /* hack: if trace object not attached to anything free packet */
                if (target_ == 0)
                        Packet::free(p);
                else
                        send(p, h); /* \fcn[]{Connector::send} */
        }
The function merely formats a trace entry using the source, destination, and particular trace type character. The dump function writes the formatted entry out to the I/O handle associated with channel
_
. The format function, in effect, dictates the trace file format.


next up previous contents index
Next: 21.4 Trace File Format Up: 21. Trace and Monitoring Previous: 21.2 Library support and

2000-08-24