removed apps
[luayats.git] / src / user / stdred.h
blob0d7dede23ab28c4d7b74240ea5c2ac37ca1329ca
1 #ifndef _STDRED_H_
2 #define _STDRED_H_
4 #include "inxout.h"
5 #include "queue.h"
7 ///////////////////////////////////////////////////////////////
8 // class stdred
9 ///////////////////////////////////////////////////////////////
10 class stdred : public inxout
12 typedef inxout baseclass;
14 public:
16 enum {keyPIR = 1, keyStatTimer = 2};
18 stdred() : evtPIR(this, keyPIR), evtStatTimer(this, keyStatTimer)
20 TimeSendNextPIR = 0;
21 alarmed_late = FALSE; // not alarmed
22 alarmed_early = FALSE;
24 } // Constructor
26 struct inpstruct
28 data *pdata;
29 int inp;
32 int ninp; // number of inputs
33 int max_flow; // number of Flows
34 int maxbuff_packet; // max buffer size (packets)
35 int buff_packet; // buffer fill level (packets)
36 int maxbuff_byte; // max buffer size (byte)
37 int buff_byte; // buffer fill level (byte)
38 double slot_per_minpacket; // the slots for a packet of minimum size
41 event evtPIR; // Event to call the output with PCR
42 event evtStatTimer; // Statistics Timer (for providing fairness)
43 uqueue q; // the queue with the packets
45 int use_red; // determines whether RED is used or not
47 // RED parameters
48 int red_min_th;
49 int red_max_th;
50 double red_pmax;
51 double red_w_q;
53 // RED variables
54 double red_avg;
55 double red_count;
56 int red_q_time; // the time when the queue became empty
57 double pa, pb;
60 // statistics
61 int dropped_packets;
62 int forced_drops;
63 int unforced_drops;
64 int sent_packets;
65 int sent_bytes; // probably to short!
66 int arrived_packets;
67 double throughput;
68 double utilisation;
70 int StatTimerInterval; // length of Timer-Interval in slots
71 double TimerIntervalSeconds; // Timer interval in seconds
73 int alarmed_late; // alarmed for late phase?
74 int alarmed_early; // alarmed for elary phase?
76 double TimeSendNextPIR; // when to send the next packet according to PIR
77 double SlotLength; // Length of 1 Slot in seconds
78 double PIR; // PIR of the connection (bit/s)
79 double actual_rate; // the actual rate
81 enum {SucData = 0};
82 inpstruct *inp_buff; // buffer for cells arriving in the early slot phase
83 inpstruct *inp_ptr; //current position in inp_buff
85 // Methods
86 void init(void);
87 rec_typ REC(data*,int);
88 void late(event*);
89 void early(event *);
90 int export(exp_typ *);
91 int command(char *,tok_typ *);
92 void connect(void);
93 inline double SlotToTime(int t){return t*SlotLength;};
94 inline int TimeToSlot(double t){return((int) (t/SlotLength));};
95 double uniform(){return my_rand() / 32767.0;}
96 }; // class stdred
99 #endif // _STDRED_H_