00001 #ifndef D__Traffic 00002 #define D__Traffic 00003 00004 #include <awds/UnicastPacket.h> 00005 #include <gea/Time.h> 00006 #include <gea/Blocker.h> 00007 #include <awds/NodeId.h> 00008 #include <awds/NodeDescr.h> 00009 #include <awds/Topology.h> 00010 #include <gea/ObjRepository.h> 00011 #include <gea/Blocker.h> 00012 #include <gea/API.h> 00013 00014 #include <awds/packettypes.h> 00015 #include <awds/TraceUcPacket.h> 00016 #include <awds/AwdsRouting.h> 00017 #include <awds/ext/Shell.h> 00018 #include <awds/toArray.h> 00019 00020 #include <awds/Flood.h> 00021 00022 namespace awds { 00023 class Traffic { 00024 private: 00025 Traffic() {} 00026 public: 00027 enum Type {src,sink}; 00028 Type type; 00029 Routing *routing; 00030 bool debug; 00031 00032 int packetCount,packetSize; 00033 int count,lastcount; 00034 NodeId dest; 00035 gea::AbsTime start,end; 00036 gea::Blocker blocker; 00037 00038 Traffic(Type t,Routing *r); 00039 virtual ~Traffic() {} 00040 00041 virtual void send(int pCount,int pSize,NodeId d); 00042 void send_reply(NodeId dest); 00043 00044 static void recv_packet(BasePacket *p,void *data); 00045 void on_recv(BasePacket *p); 00046 00047 static void wait(gea::Handle *h,gea::AbsTime t,void *data); 00048 void on_wait(gea::Handle *h,gea::AbsTime t); 00049 }; 00050 class TrafficPacket : public UnicastPacket { 00051 public: 00052 enum Type {fromsrc,fromsink}; 00053 static const size_t OffsetSeq = UnicastPacket::UnicastPacketEnd; 00054 static const size_t OffsetType = OffsetSeq+sizeof(unsigned int); 00055 static const size_t TrafficHeaderEnd = OffsetType+sizeof(size_t); 00056 TrafficPacket(BasePacket &p):UnicastPacket(p) { 00057 packet.size = TrafficHeaderEnd; 00058 } 00059 void setSeq(unsigned int s) { 00060 *((unsigned int*)&packet.buffer[OffsetSeq]) = s; 00061 } 00062 unsigned int getSeq() { 00063 return *((unsigned int*)&packet.buffer[OffsetSeq]); 00064 } 00065 void setType(Type t) { 00066 packet.buffer[OffsetType] = t; 00067 } 00068 Type getType() { 00069 return static_cast<Type>(packet.buffer[OffsetType]); 00070 } 00071 }; 00072 } 00073 00074 #endif // D__Traffic