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

Revision 575, 2.1 kB (checked in by zhibinwu, 3 years ago)

implement clone for address, fix a bug in genTimestamp reporting, remove flow.cpp from Makefile

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#ifndef FLOW_H
2#define FLOW_H
3
4//#include "unixtime.h"
5//#include "packet.h"
6#include "address.h"
7//#include <string.h>
8
9#define MAX_PKT_PER_FLOW  65536*65536
10
11
12/**
13 * Flow class is used by the receiver to post-processing incoming packets,
14 * including classifying them from differnt source IP/Port..
15 * It is used and controled by the Gate.
16 * Flows are orginized as "link list" --- a double-link table structure.
17 * Each flow has two pointers pointing
18 * to the previous and next object in the list respectively.
19 */
20
21class Flow {
22  friend class Gate;
23  friend class Packet;
24public:
25  inline Flow(int flowid):flowid_(flowid){seqno_ = 0;}
26 //Packet *packetcache_;   ///< cache a packet here , only one packet pointer, not point to an array or queue.
27 // Sink * sin_;    ///< each flow connects to a next-step processing entity, usually a sink.
28 Flow *prev_;    ///< previous flow   
29 Flow *next_;    ///< next flow
30protected:
31 Address *addrId_; ///< Pointer to an  address to identify this stream, distinguish this stream from others
32 unsigned long seqno_;  ///< number of packets received by this flow   
33 int flowid_; ///< used to identify the flow object, more like a "process tag". If an packet is tagged with the flow id, it means having been processed by this flow object. The file descriptor to receving a flow,also acting as like a flowid, useful for TCP gate. 
34 //UnixTime flowclock_;
35public: 
36 /**
37  * Function to getID
38  */
39 inline int getID(){return flowid_;}
40 /**
41  * Function to Increment Seq No.
42  */
43 inline void incSeq(){
44          seqno_++; 
45          if(seqno_ > MAX_PKT_PER_FLOW )seqno_= 0; //FIX ME or OK??
46 } 
47 /**
48  * Function to get the address of this stream.
49  */
50inline Address* getAddr(){ return addrId_;} 
51inline void setAddress(Address* src){addrId_ = src->clone();}
52/**
53 * Function to get the packet pointer of this stream
54 *///
55 //inline Packet* getPacket(){ return packetcache_;}
56/**
57 * Function to get the current sequence number of this stream
58 */   
59inline unsigned long getSeqno(){return seqno_;}
60//inline void bindSink(Sink *si){ sin_ = si; }               
61
62
63}; 
64 
65#endif
Note: See TracBrowser for help on using the browser.