EventHelix.com: CASE Tools; Real-time and Embedded System Design; Object Oriented Design EventStudio 2.0: System Engineering CASE ToolEventStudio 2.5
Sequence diagram based system design and modeling
Home   What's New   EventStudio 2.5   Real-time Mantra   Thought Projects   Contact Us
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Retransmission_Buffer Class Reference

#include <Retransmission_Buffer.h>

Collaboration diagram for Retransmission_Buffer:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Retransmission Buffer object manages buffers until an acknowledgement is received from the other end.

The messages are retransmitted If no ack is received.

The interactions of this object are listed below:

See also:
Transmit Protocol Handler Design Pattern

Definition at line 30 of file Retransmission_Buffer.h.

Public Member Functions

 Retransmission_Buffer (Protocol_Layer *p_Layer)
 The constructor for the class.

void Add_Packet (const Datagram *p_Packet)
 Store a packet for possible retransmission in the future.

void Handle_Received_Ack_Notification (int new_Acknowledged_Sequence_Number)
 Handle the acknowledgement received from the remote end.

int Get_Window_Room () const
 Obtain the total free room available in the window.

void Handle_Await_Ack_Timeout ()
 This method is invoked when the protocol times out for an acknowlegement from the remote end.


Constructor & Destructor Documentation

Retransmission_Buffer::Retransmission_Buffer Protocol_Layerp_Layer  ) [inline]
 

The constructor for the class.

The constructor needs a pointer to the parent layer. The Retransmission Buffer will use this pointer to obtain a pointer to the lower layer.

Parameters:
p_Layer Pointer to the parent layer.
See also:
Transmit Protocol Handler Design Pattern

Definition at line 52 of file Retransmission_Buffer.h.

00052                                                    : m_p_Layer(p_Layer)
00053     {
00054     }


Member Function Documentation

void Retransmission_Buffer::Add_Packet const Datagram * p_Packet  ) [inline]
 

Store a packet for possible retransmission in the future.

This method takes the following actions:

  • Obtain the transmit sequence number of the packet.
  • Make a copy of the packet for the retransmission buffer
  • Save the packet according to the transmit sequence number.
  • Retart the ack timer.

Parameters:
p_Packet Packet that needs to be saved for possible retransmission in the future.
See also:
Transmit Protocol Handler Design Pattern

Definition at line 67 of file Retransmission_Buffer.h.

00068     {
00069     
00070        m_last_Transmitted_Sequence_Number = p_Packet->Get_Transmit_Sequence_Number();
00071        
00072        // Make a copy of the packet for the retransmission buffer
00073        m_p_Pending_Packets[m_last_Transmitted_Sequence_Number] = new Datagram(p_Packet);
00074 
00075        // Restart the ack timer. Timer is started if its not running
00076        Restart_Await_Ack_Timer();       
00077     }

void Retransmission_Buffer::Handle_Received_Ack_Notification int new_Acknowledged_Sequence_Number  ) [inline]
 

Handle the acknowledgement received from the remote end.

The following actions are taken on receiving an ack:

  • Run a loop from the last acknowledged sequence number to the new acknowledged sequence number
    • In each iteraction, delete the buffer corresponding to that sequence number. (As the message has been acknowledged and will not be retransmitted)
  • Record the new acknowledged sequence number as the last acknowledged sequence number.
  • Stop the ack timer if no packets are pending retransmission.

Parameters:
new_Acknowledged_Sequence_Number The transmit sequence number that has been acknowledged by the remote end.
See also:
Transmit Protocol Handler Design Pattern

Definition at line 91 of file Retransmission_Buffer.h.

00092     {
00093         // Delete the buffers allocted to retransmission buffers 
00094         // for all allocated packets.
00095         for (int i=m_last_Acknowledged_Sequence_Number; i != new_Acknowledged_Sequence_Number; 
00096                                                      Modulo_Increment(i))
00097         {
00098            delete m_p_Pending_Packets[i];
00099            m_p_Pending_Packets[i] = NULL; 
00100         }
00101         
00102         // Save the new sequence number as the last acknowledged seq num
00103         m_last_Acknowledged_Sequence_Number = new_Acknowledged_Sequence_Number;
00104         
00105         // If all packets have been acknowledged, stop timer
00106         if (m_last_Transmitted_Sequence_Number == m_last_Acknowledged_Sequence_Number)
00107         {
00108            Stop_Await_Ack_Timer();
00109         } 
00110     }

int Retransmission_Buffer::Get_Window_Room  ) const [inline]
 

Obtain the total free room available in the window.

Return the room in window by determining the current count of messages awaiting acknowledgement.

Return values:
int Number of free entries available before the window will be full.
See also:
Transmit Protocol Handler Design Pattern

Definition at line 120 of file Retransmission_Buffer.h.

00121     {
00122        // Return the room in window by determining the current count of messages
00123        // awaiting acknowledgement
00124        return (WINDOW_SIZE - 
00125            Modulo_Difference(m_last_Transmitted_Sequence_Number, m_last_Acknowledged_Sequence_Number));
00126     }

void Retransmission_Buffer::Handle_Await_Ack_Timeout  ) [inline]
 

This method is invoked when the protocol times out for an acknowlegement from the remote end.

This method will retransmit all the packets that are pending acknowledgement. The sequence of actions is:

  • Initiate retransmission of all unacknowledged packets by looping from the last unacknowledged sequence number to the sequence number of the last transmitted message.
  • Restart the await ack timer to keep track of acknowlegements to these as well as previous transmissions.

See also:
Transmit Protocol Handler Design Pattern

Definition at line 137 of file Retransmission_Buffer.h.

00138     {       
00139         Datagram *p_Packet;
00140 
00141         // Initiate retransmission of all unacknowledged packets by 
00142         // looping from the last unacknowledged sequence number to 
00143         // the sequence number of the last transmitted message
00144         for (int i=Modulo_Add(m_last_Acknowledged_Sequence_Number, 1); 
00145              i != m_last_Transmitted_Sequence_Number; Modulo_Increment(i))
00146         { 
00147 
00148            // Get the packet corresponding to the sequence number i
00149            p_Packet = m_p_Pending_Packets[i];
00150 
00151            // Pass on the message for transmission on the serial port
00152            (m_p_Layer->Get_Lower_Layer())->Transmit(p_Packet);                
00153         }
00154         
00155         // Now restart the timer
00156         Restart_Await_Ack_Timer();
00157     }


The documentation for this class was generated from the following file:
Generated on Sun Feb 13 21:30:37 2005 for Object Oriented Design Examples by doxygen 1.3.4
 Home   What's New   EventStudio 2.5   Real-time Mantra   Thought Projects   Contact Us
Copyright © 2000-2005 EventHelix.com Inc. All Rights Reserved.