IT++ Logo

selective_repeat.h

Go to the documentation of this file.
00001 
00030 #ifndef SELECTIVE_REPEAT_H
00031 #define SELECTIVE_REPEAT_H
00032 
00033 #include <itpp/protocol/packet.h>
00034 #include <itpp/protocol/front_drop_queue.h>
00035 #include <itpp/base/vec.h>
00036 #include <itpp/base/array.h>
00037 
00038 
00039 namespace itpp
00040 {
00041 
00043 
00044 
00048 class Selective_Repeat_ARQ_Sender
00049 {
00050 public:
00052   Selective_Repeat_ARQ_Sender();
00053 
00055   Selective_Repeat_ARQ_Sender(const int Seq_no_size, const int Buffer_size_factor, const int Link_packet_size, const Ttype Time_out);
00056 
00058   ~Selective_Repeat_ARQ_Sender();
00059 
00061   void set_parameters(const int Seq_no_size,        // # bits in sequence no.
00062                       const int Buffer_size_factor, // Link-packet buffer size = 2^(Seq_no_size)*Buffer_size_factor.
00063                       const int Link_packet_size,    // Size of the link packets in bytes.
00064                       const Ttype Time_out);        // Idle time before retransmission.
00065 
00066   // -- Slots -- //
00067   Slot<Selective_Repeat_ARQ_Sender, Packet*> packet_input; 
00068   Slot<Selective_Repeat_ARQ_Sender, Array<Packet*> > ack_input; 
00069   Slot<Selective_Repeat_ARQ_Sender, void*> query_nof_ready_packets; 
00070   Slot<Selective_Repeat_ARQ_Sender, int> packet_output_request; 
00071 
00072   // -- Signals -- //
00073   Signal<Array<Packet*> > packet_output; 
00074   Signal<int> nof_ready_packets;         
00075   Signal<int> buffer_overflow;           
00076 
00078   int buffer_size();
00080   int link_packets_buffered();
00082   int nof_ready_link_packets();
00084   int link_packets_queued_waiting_for_transmission();
00086   Ttype link_packets_max_queuing_time();
00088   void get_link_packets(const int K, Array<Packet*> &pa);
00089 
00090 private:
00091   void handle_ack_input(Array<Packet*> packet_array); // Take care of incomming ack/nacks.
00092   void handle_packet_input(Packet *P);          // Take care of incomming packets.
00093   void handle_packet_output_request(int K);     // Take care of incomming packet requests.
00094   void handle_query_nof_ready_packets(void*);   // Take care of incomming query for number of packets ready to transmit.
00095   void retransmit(int Sequence_number);    // Take care of incomming query for number of packets ready to transmit.
00096   void remove(const int Sequence_number);
00097   void push_packet_on_tx_buffer(Packet *packet);
00098   int buffered_non_outstanding();
00099   int free_sequence_numbers();
00100   int sequence_number_2_buffer_index(const int Sequence_number);
00101   void schedule_output(const int Buffer_index, const int Sequence_number, const bool Retransmission);
00102   void cancel_output(const int Sequence_number);
00103   void fill_output();
00104   int feasable_blocks();
00105   bool parameters_ok;
00106   Front_Drop_Queue ip_pkt_queue;
00107   Array<Link_Packet*> input_buffer;
00108   int input_buffer_size;
00109   int input_next;
00110   int input_free_space;
00111   int seq_no_size;
00112   int seq_no;
00113   int seq_no_max;
00114   int tx_next;
00115   int tx_last;
00116   int outstanding;
00117   int id;
00118   Ttype time_out;
00119   Array<ATimer<Selective_Repeat_ARQ_Sender, int> > timer;
00120   ivec output_indexes;
00121   ivec retransmission_indexes;
00122   int rd_pos;
00123   int rt_pos;
00124   int scheduled_total;
00125   int scheduled_retransmissions;
00126   int no_retransmit;
00127   int link_packet_size;
00128 };
00129 
00130 
00134 class Selective_Repeat_ARQ_Receiver
00135 {
00136 public:
00138   Selective_Repeat_ARQ_Receiver();
00139 
00141   Selective_Repeat_ARQ_Receiver(const int Seq_no_size);
00142 
00144   ~Selective_Repeat_ARQ_Receiver();
00145 
00146   // -- Slots -- //
00147   Slot<Selective_Repeat_ARQ_Receiver, Array<Packet*> > packet_input; 
00148 
00149   // -- Signals -- //
00150   Signal<Array<Packet*> > ack_output; 
00151   Signal<Packet*> packet_output;      
00152 
00154   void set_parameters(const int Seq_no_size); // # bits in sequence no.
00155 
00156 private:
00157   bool greater_modulo_L(const int a, const int b);
00158   void handle_packet_input(Array<Packet*>); // Take care of incomming packets.
00159   int seq_no_size;
00160   int seq_no_max;
00161   Array<Link_Packet*> rx_buffer;
00162   int Rnext;
00163   int id;
00164   bool parameters_ok;
00165 };
00166 
00168 
00169 } // namespace itpp
00170 
00171 #endif // #ifndef SELECTIVE_REPEAT_H
00172 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Wed Feb 9 2011 13:47:24 for IT++ by Doxygen 1.7.3