root / otg / trunk / src / cpp / packet.h

Revision 1076, 5.3 kB (checked in by sachin, 3 years ago)

Added hw_timestamp measurement to OTR

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#include <string.h>
2#ifndef OTG_PACKET_H
3#define OTG_PACKET_H
4
5/**An auxillary class for binding some measurements with the packet.
6 * Currently, we list all possible TX parameters here
7 */
8class SendParam
9{
10 public:
11   SendParam();
12 private:
13     
14   int txpower_; ///< dbm, rounded to integer     
15   short channel_; ///< wireless channel number in 802.11 a/b/g (optional) (for wireless use)
16   short streamid_;  ///<the stream id
17   long seqnum_;     ///< sequence number attached by the stream
18   double txtime_;  ///<transmit timing in milliseconds     
19   long mactxtime_; ///<this parameter is set by the driver to show when the packet is delivered, in microseconds
20   long tcp_seqno_;  /// the Sequence number in TCP header TCP port's sequence number if TCP Port is used to sent.
21   short txport_;
22   short txrate_;    ///The channel rate used by the sender (optional) (for wireless use)
23   char *senderaddr_; ///IP address of the sender
24   char *sendermac_;  /// MAC address of the sender
25 
26 public:
27   inline short getStreamId(){return streamid_;}
28   inline void setStreamId(short i){streamid_ = i;}
29   inline unsigned long getStreamSequenceNum(){return seqnum_;}
30   inline void setStreamSequenceNum(unsigned long i){seqnum_ = i;}
31   inline void setTxTime(double ms){ txtime_ = ms; }
32   inline double getTxTime(){return txtime_;}
33   inline void setSenderName(char *str){ strcpy(senderaddr_,str); }
34   inline char* getSenderName() {return senderaddr_; } 
35   inline void setSenderMAC(char *str){ strcpy(sendermac_,str); }
36   inline char* getSenderMAC() {return sendermac_; } 
37   inline void setSenderPort(short port) { txport_ = port;}
38   inline short getSenderPort(){ return txport_;}
39   inline void  setPHYXmitRate(short rate){txrate_ = rate;}
40   inline short getPHYXmitRate(){return txrate_;}
41
42};
43
44/**An auxillary class for binding some receiver-specified
45 * measurements with the packet.
46 * Currently, we list all possible RX parameters here
47 */
48
49class ReceiveParam
50{
51 public:
52      ReceiveParam();
53 private:     
54      short rssi_;   ///< RSSI value from Wireless PHY of received pacekt
55      short noise_;  ///< Noise value from Wireless PHY of received packet
56      int mac_timestamp_; ///<MAC timestamp from the driver
57      int flowid_;   ///<Id of The flow which recived the packet.
58      long seqno_;   ///<The sequence number attached by the flow. This value will implicitly tell the flow throughput.
59      long macrxtime_; ///<The timestampe when MAC_RX catches the packet
60      double rxtime_;    /// < The time when the paket is received by the Gate, in milliseconds
61      int rx_size_;   /// The actual size of received packet.
62      char *receiveraddr_;  ///IP address of the receiver
63      short rxport_;   ///<Port number, if applicable.
64 
65 public:
66   inline short getFlowId(){return flowid_;}
67   inline void setFlowId(short i){flowid_ = i;}
68   inline unsigned long getFlowSequenceNum(){return seqno_;}
69   inline void setFlowSequenceNum(unsigned long i){seqno_ = i;}
70   inline void setRxTime(double ms){ rxtime_ = ms; }
71   inline double getRxTime(){return rxtime_;}
72   inline int getReceivedLength() {return rx_size_;}
73   inline void setReceivedLength(int le){rx_size_ = le;}
74   inline void setRSSI(short rssi){rssi_=rssi; }
75   inline void setMacTimestamp(int ts) {mac_timestamp_ = ts;}
76   inline int getMacTimestamp() {return mac_timestamp_;}
77   inline short getRSSI() {return rssi_;}
78};
79
80
81/**
82 * Packet is an entity given by generator.
83 * This packet class only carries
84 * payload information and a sending timestamp, not any socket address information. Also, the packet would carry all measuremnts related to this packet with it.
85 */
86class Packet {
87 
88public:
89  /**
90   *  Default payload size is 512 Bytes
91   */
92  static const int DEFAULT_PAYLOAD_SIZE = 512;
93  Packet();
94  Packet(int buffer_length);
95  int fillPayload(int size, char *inputstream); 
96   /** get a pointer to the payload
97    * @return  a char pointer
98    */
99  inline char* getPayload(){ return payload_;} 
100  void setPayloadSize(int size);
101  /**get the size of packet buffer where payload is stored.
102   *
103   */
104  inline int getBufferSize(){return length_;}
105 /** get the size of the packet
106  * 
107  */
108      inline int getPayloadSize(){ return size_;}
109 /** Fucntion to set the expected sending time of this packet
110  */
111      inline void setTimeStamp(double stamp) {time_ = stamp;}
112 /** Function to get the sending timestamp of this packet.
113  */
114      inline double getTimeStamp()  {return time_; } 
115
116  SendParam *txMeasure_;
117  ReceiveParam *rxMeasure_;
118
119  bool stampLongVal(int offset, unsigned long val); 
120  unsigned long extractLongVal(int offset);
121  bool stampShortVal(int offset, unsigned short val); 
122  unsigned short extractShortVal(int offset);
123  bool stampPktID();
124  void extractPktID();
125
126
127private:     
128      /** Expected Deliver Timestamp.
129       * Expected time to send this paket.absolute time in seconds.
130       * the actual sending  time canot as precise as this double-precision variable.
131       * this is a relevant time, refer to the time when TG is started
132       */
133      double time_; 
134      int size_;  ///< Packet length in Bytes
135      int length_; ///< Maximum allocated Size of Payload buffer. it is no less than the size_
136      char* payload_; ///< Payload Pointer.
137
138     //void StampPayload(sendParam);  //put some libmac info to identify this packet, optional     
139};
140
141
142#endif
Note: See TracBrowser for help on using the browser.