00001 00033 #ifndef SELECTIVE_REPEAT_H 00034 #define SELECTIVE_REPEAT_H 00035 00036 #include <itpp/protocol/packet.h> 00037 #include <itpp/protocol/front_drop_queue.h> 00038 #include <itpp/base/vec.h> 00039 #include <itpp/base/array.h> 00040 00041 00042 namespace itpp { 00043 00047 class Selective_Repeat_ARQ_Sender { 00048 public: 00049 Selective_Repeat_ARQ_Sender(); 00050 00051 Selective_Repeat_ARQ_Sender(const int Seq_no_size, const int Buffer_size_factor, const int Link_packet_size, const Ttype Time_out); 00052 00053 ~Selective_Repeat_ARQ_Sender(); 00054 00055 void set_parameters(const int Seq_no_size, // # bits in sequence no. 00056 const int Buffer_size_factor, // Link-packet buffer size = 2^(Seq_no_size)*Buffer_size_factor. 00057 const int Link_packet_size, // Size of the link packets in bytes. 00058 const Ttype Time_out); // Idle time before retransmission. 00059 00060 // -- Slots -- // 00061 Slot<Selective_Repeat_ARQ_Sender, Packet*> packet_input; // Receives incoming packets. 00062 Slot<Selective_Repeat_ARQ_Sender, Array<Packet*> > ack_input; // Receives incoming ack/nacks. 00063 Slot<Selective_Repeat_ARQ_Sender, void*> query_nof_ready_packets; // Receives incoming query for number of packets ready to transmit. 00064 Slot<Selective_Repeat_ARQ_Sender, int> packet_output_request; // Receives incoming packet output requests. 00065 00066 // -- Signals -- // 00067 Signal<Array<Packet*> > packet_output; // Delivers transmitted packets. 00068 Signal<int> nof_ready_packets; // Delivers no ready packets. 00069 Signal<int> buffer_overflow; // Signals buffer overflows. 00070 00071 int buffer_size(); 00072 int link_packets_buffered(); 00073 int nof_ready_link_packets(); 00074 int link_packets_queued_waiting_for_transmission(); 00075 Ttype link_packets_max_queuing_time(); 00076 void get_link_packets(const int K, Array<Packet*> &pa); 00077 00078 private: 00079 void handle_ack_input(Array<Packet*> packet_array); // Take care of incomming ack/nacks. 00080 void handle_packet_input(Packet *P); // Take care of incomming packets. 00081 void handle_packet_output_request(int K); // Take care of incomming packet requests. 00082 void handle_query_nof_ready_packets(void*); // Take care of incomming query for number of packets ready to transmit. 00083 void retransmit(int Sequence_number); // Take care of incomming query for number of packets ready to transmit. 00084 void remove(const int Sequence_number); 00085 void push_packet_on_tx_buffer(Packet *packet); 00086 int buffered_non_outstanding(); 00087 int free_sequence_numbers(); 00088 int sequence_number_2_buffer_index(const int Sequence_number); 00089 void schedule_output(const int Buffer_index, const int Sequence_number, const bool Retransmission); 00090 void cancel_output(const int Sequence_number); 00091 void fill_output(); 00092 int feasable_blocks(); 00093 bool parameters_ok; 00094 Front_Drop_Queue ip_pkt_queue; 00095 Array<Link_Packet*> input_buffer; 00096 int input_buffer_size; 00097 int input_next; 00098 int input_free_space; 00099 int seq_no_size; 00100 int seq_no; 00101 int seq_no_max; 00102 int tx_next; 00103 int tx_last; 00104 int outstanding; 00105 int id; 00106 Ttype time_out; 00107 Array<ATimer<Selective_Repeat_ARQ_Sender, int> > timer; 00108 ivec output_indexes; 00109 ivec retransmission_indexes; 00110 int rd_pos; 00111 int rt_pos; 00112 int scheduled_total; 00113 int scheduled_retransmissions; 00114 int no_retransmit; 00115 int link_packet_size; 00116 }; 00117 00118 00122 class Selective_Repeat_ARQ_Receiver { 00123 public: 00124 Selective_Repeat_ARQ_Receiver(); 00125 00126 Selective_Repeat_ARQ_Receiver(const int Seq_no_size); 00127 00128 ~Selective_Repeat_ARQ_Receiver(); 00129 00130 // -- Slots -- // 00131 Slot<Selective_Repeat_ARQ_Receiver, Array<Packet*> > packet_input; // Receives incoming packets. 00132 00133 // -- Signals -- // 00134 Signal<Array<Packet*> > ack_output; // Delivers ack. 00135 Signal<Packet*> packet_output; // Delivers received packets. 00136 00137 void set_parameters(const int Seq_no_size); // # bits in sequence no. 00138 00139 private: 00140 bool greater_modulo_L(const int a, const int b); 00141 void handle_packet_input(Array<Packet*>); // Take care of incomming packets. 00142 int seq_no_size; 00143 int seq_no_max; 00144 Array<Link_Packet*> rx_buffer; 00145 int Rnext; 00146 int id; 00147 bool parameters_ok; 00148 }; 00149 00150 00151 } // namespace itpp 00152 00153 #endif // #ifndef SELECTIVE_REPEAT_H 00154
Generated on Thu Apr 19 14:19:55 2007 for IT++ by Doxygen 1.4.6