IT++ Logo
selective_repeat.h
Go to the documentation of this file.
1 
29 #ifndef SELECTIVE_REPEAT_H
30 #define SELECTIVE_REPEAT_H
31 
32 #include <itpp/base/vec.h>
33 
34 #if (defined(_MSC_VER) && defined(ITPP_SHARED_LIB) && !(defined(itpp_EXPORTS) || defined(itpp_debug_EXPORTS)))
35 
36 #ifndef ITPP_PROTOCOL_EXCLUDED
37 #define ITPP_PROTOCOL_EXCLUDED
38 #pragma message( "PROTOCOL definitions are not available for MSVC shared builds" )
39 #endif
40 
41 #else
42 
43 #include <itpp/protocol/packet.h>
45 #include <itpp/base/array.h>
46 
47 
48 namespace itpp
49 {
50 
52 
53 
58 {
59 public:
62 
64  Selective_Repeat_ARQ_Sender(const int Seq_no_size, const int Buffer_size_factor, const int Link_packet_size, const Ttype Time_out);
65 
68 
70  void set_parameters(const int Seq_no_size, // # bits in sequence no.
71  const int Buffer_size_factor, // Link-packet buffer size = 2^(Seq_no_size)*Buffer_size_factor.
72  const int Link_packet_size, // Size of the link packets in bytes.
73  const Ttype Time_out); // Idle time before retransmission.
74 
75  // -- Slots -- //
80 
81  // -- Signals -- //
85 
87  int buffer_size();
97  void get_link_packets(const int K, Array<Packet*> &pa);
98 
99 private:
100  void handle_ack_input(Array<Packet*> packet_array); // Take care of incomming ack/nacks.
101  void handle_packet_input(Packet *P); // Take care of incomming packets.
102  void handle_packet_output_request(int K); // Take care of incomming packet requests.
103  void handle_query_nof_ready_packets(void*); // Take care of incomming query for number of packets ready to transmit.
104  void retransmit(int Sequence_number); // Take care of incomming query for number of packets ready to transmit.
105  void remove(const int Sequence_number);
106  void push_packet_on_tx_buffer(Packet *packet);
107  int buffered_non_outstanding();
108  int free_sequence_numbers();
109  int sequence_number_2_buffer_index(const int Sequence_number);
110  void schedule_output(const int Buffer_index, const int Sequence_number, const bool Retransmission);
111  void cancel_output(const int Sequence_number);
112  void fill_output();
113  int feasable_blocks();
114  bool parameters_ok;
115  Front_Drop_Queue ip_pkt_queue;
116  Array<Link_Packet*> input_buffer;
117  int input_buffer_size;
118  int input_next;
119  int input_free_space;
120  int seq_no_size;
121  int seq_no;
122  int seq_no_max;
123  int tx_next;
124  int tx_last;
125  int outstanding;
126  int id;
127  Ttype time_out;
129  ivec output_indexes;
130  ivec retransmission_indexes;
131  int rd_pos;
132  int rt_pos;
133  int scheduled_total;
134  int scheduled_retransmissions;
135  int no_retransmit;
136  int link_packet_size;
137 };
138 
139 
144 {
145 public:
148 
150  Selective_Repeat_ARQ_Receiver(const int Seq_no_size);
151 
154 
155  // -- Slots -- //
157 
158  // -- Signals -- //
161 
163  void set_parameters(const int Seq_no_size); // # bits in sequence no.
164 
165 private:
166  bool greater_modulo_L(const int a, const int b);
167  void handle_packet_input(Array<Packet*>); // Take care of incomming packets.
168  int seq_no_size;
169  int seq_no_max;
170  Array<Link_Packet*> rx_buffer;
171  int Rnext;
172  int id;
173  bool parameters_ok;
174 };
175 
177 
178 } // namespace itpp
179 
180 #endif
181 
182 #endif // #ifndef SELECTIVE_REPEAT_H
183 
SourceForge Logo

Generated on Sat Jul 6 2013 10:54:24 for IT++ by Doxygen 1.8.2