00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __NAM_TRACE_NAM_TRACER_H__
00032 #define __NAM_TRACE_NAM_TRACER_H__
00033
00034 #include "config.h"
00035
00036 #include "pydtn/Tracer.h"
00037 #include "simlpy/Entity.h"
00038 #include "simlpy/Event.h"
00039 #include "dtn/ByteString.h"
00040 #include <map>
00041 #include <set>
00042 #include <ostream>
00043
00046
00047 class NamTracer;
00048
00053 class NamTraceEvent : public Event
00054 {
00055 public :
00061 NamTraceEvent( Entity* source,
00062 NamTracer* destination,
00063 const Time& t ) :
00064 Event( source, t ),
00065 m_destination( destination )
00066 {}
00067
00069 virtual ~NamTraceEvent() {}
00070
00071 bool handle();
00072
00073 private :
00074 NamTracer* m_destination;
00075 };
00076
00078 class NamTracer : public Tracer, public Entity
00079 {
00080 public :
00082 typedef std::map< DTN::ByteString , int > NodeIDMap;
00084 typedef std::set< const WrapNode* > NodeSet;
00086 typedef std::set< const WrapLink* > LinkSet;
00087
00090 NamTracer( std::ostream& s );
00092 virtual ~NamTracer();
00093
00096 void setQueueState( bool q ) { m_queueState = q; }
00097
00100 void node( const WrapNode& wn );
00101
00104 void link( const WrapLink& wl );
00105
00109 void enqueue( const DTN::Bundle& b, const DTN::Node* n );
00110
00114 void dequeue( const DTN::Bundle& b, const DTN::Node* n );
00115
00119 void send( const DTN::Bundle& b, const DTN::Node* n );
00120
00124 void receive( const DTN::Bundle& b, const DTN::Node* n );
00125
00130 void drop( const DTN::Bundle& b,
00131 const DTN::DropCause& c,
00132 const DTN::Node* n );
00133
00135 Entity* create() const { return 0; }
00137 void configure( const ArgList& args ) {}
00139 void emit( const ArgList& args ) {}
00141 bool handler( NamTraceEvent& event );
00143 std::string identifier() const { return "namtrace"; }
00144
00145 protected :
00149 void traceNode( const WrapNode& wn, bool initial = false );
00150
00154 void traceLink( const WrapLink& wl, bool initial = false );
00155
00158 void traceBundle( const DTN::Bundle& b );
00159
00164 int nodeID( const WrapNode& wn );
00165
00170 int nodeID( const DTN::ByteString& addr );
00171
00175 DTN::ByteString vQueue( const WrapNode& wn );
00176
00180 DTN::ByteString vQueue( const DTN::ByteString& addr );
00181
00187 double time( const Time& t );
00188
00195 std::string stringify( const DTN::ByteString& b ) const;
00196
00197 private :
00198 std::ostream& m_stream;
00199 int m_lastNode;
00200 NodeIDMap m_nodes;
00201 bool m_queueState;
00202 bool m_tracing;
00203 bool m_notified;
00204 NodeSet m_nodeSet;
00205 LinkSet m_linkSet;
00206 };
00207
00209
00210 #endif // __NAM_TRACE_NAM_TRACER_H__