00001 /********************************************************** 00002 * Filename: source.h 00003 * 00004 * Description: This file contains declarations for 00005 * class Trace 00006 * 00007 * Author: Glen Kramer (kramer@cs.ucdavis.edu) 00008 * University of California @ Davis 00009 *********************************************************/ 00010 00011 #if !defined(_TRACE_H_INCLUDED_) 00012 #define _TRACE_H_INCLUDED_ 00013 00014 #include "_types.h" 00015 #include "_rand_MT.h" 00016 #include <ostream> 00017 00018 typedef int16s pct_size_t; 00019 typedef DOUBLE bytestamp_t; 00020 00021 /* dafault values */ 00022 const int16s BYTE_SIZE = 8; 00023 const int16s PREAMBLE = 8; 00024 00025 const int16s MIN_PCT = 64; 00026 const int16s MAX_PCT = 1518; 00027 00028 const int8u PRIOR_L0 = 0; /* lowest priority */ 00029 const int8u PRIOR_L1 = 1; 00030 const int8u PRIOR_L2 = 2; 00031 const int8u PRIOR_L3 = 3; /* highest priority */ 00032 00034 00035 class Trace 00036 { 00037 public: 00038 int16s SourceID : 10; 00039 int16s QueueID : 6; 00040 bytestamp_t ByteStamp; 00041 pct_size_t PacketSize; 00042 00043 Trace( int16s sid = 0, int16s qid = PRIOR_L0, bytestamp_t bs = 0.0, pct_size_t ps = 0 ) 00044 { 00045 SourceID = sid; 00046 QueueID = qid; 00047 ByteStamp = bs; 00048 PacketSize = ps; 00049 } 00050 ~Trace() {} 00052 // FUNCTION: Append( bytestamp_t prev_end ) 00053 // DESCRIPTION: Updates bytestamp of the current packet to account for the 00054 // waiting time in buffer. This happens when several sources 00055 // have overlaping (in time) packets 00056 // NOTES: free_stamp - bytestamp when channel becomes free 00058 inline bytestamp_t Append( bytestamp_t free_stamp ) 00059 { 00060 //ev<<"ByteStamp: "<<ByteStamp<<endl; 00061 ByteStamp = MAX( ByteStamp, free_stamp + PacketSize ); 00062 //ev<<"ByteStamp despues de Append: "<<ByteStamp<<endl; 00063 return ByteStamp; 00064 } 00065 }; 00066 00068 // FUNCTION: ostream& operator<< ( ostream& os, const Trace& trc ) 00069 // DESCRIPTION: Insert operator for the class Trace 00070 // NOTES: 00072 /*inline ostream& operator<< ( ostream& os, const Trace& trc ) 00073 { 00074 return ( os << trc.SourceID << " " 00075 << trc.QueueID << " " 00076 << trc.ByteStamp << " " 00077 << trc.PacketSize ); 00078 }*/ 00079 00080 00081 #endif /* _TRACE_H_INCLUDED_ */