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

Transmit_Protocol_Handler Class Reference

#include <Transmit_Protocol_Handler.h>

Collaboration diagram for Transmit_Protocol_Handler:

Collaboration graph
[legend]
List of all members.

Detailed Description

This pattern provides a framework for implementing a sliding window protocol.

The Transmit Protocol Handler receives a packet from the higher layer and transmits it to the lower layer after assigning a sequence number. The packet is also stored in an internal retransmission buffer. The packet is removed from the retransmission queue if the remote end acknowledges the packet. The Transmit Protocol Handler retransmits the packet if it times out for an acknowledgement.

See also:
Transmit Protocol Handler Design Pattern

Definition at line 24 of file Transmit_Protocol_Handler.h.

Public Member Functions

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

void Handle_Transmit_Request (Datagram *p_Packet)
 Handle the transmission requests from the higher layer.

void Handle_Send_Ack_Request (int new_Receive_Sequence_Number)
 Handle ack transmission requests from the Receive Protocol Handler.

void Handle_Received_Ack_Notification (int acknowledged_Sequence_Number)
 Handle acknowledgements that have been received by the Receive Protocol Handler.


Private Member Functions

void Transmit_Packet (Datagram *p_Packet)
 Transmit a packet to the lower layer.


Private Attributes

int m_next_Transmit_Sequence_Number
 Transmit sequence number for the next packet.

int m_next_Receive_Sequence_Number
 Receive sequence number to be sent in the next packet.

Retransmission_Buffer m_retransmission_Buffer
 Retransmission buffer for storing all packets that have been transmitted and are awaiting an acknowledgement from the other end.

Packet_Queue< Datagram > m_transmit_Queue
 Packets awaiting transmission to the lower layer.

Protocol_Layerm_p_Layer
 Pointer to the parent layer.


Constructor & Destructor Documentation

Transmit_Protocol_Handler::Transmit_Protocol_Handler Protocol_Layerp_Layer  ) [inline]
 

The constructor for the class.

The constructor needs a pointer to the parent layer. The Transmit Protocol Handler will use this pointer to obtain a pointer to the lower layer.

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

Definition at line 94 of file Transmit_Protocol_Handler.h.

00094                                                        :
00095       m_p_Layer(p_Layer), m_retransmission_Buffer(p_Layer)
00096       {
00097       }


Member Function Documentation

void Transmit_Protocol_Handler::Transmit_Packet Datagram * p_Packet  ) [inline, private]
 

Transmit a packet to the lower layer.

This method performs the following steps:

  • Add Layer 2 header and receive sequence number
  • If the packet is not an ack:
    • Store the transmit sequence number
    • Add the packet to the retransmission queue
  • Transmit the packet to the lower layer

Parameters:
p_Packet Pointer to the packet that needs to be transmitted.
See also:
Transmit Protocol Handler Design Pattern

Definition at line 56 of file Transmit_Protocol_Handler.h.

00057     {
00058         // Add header and sequence numbers
00059         p_Packet->Add_Header(L2_HEADER_LENGTH);
00060 
00061         p_Packet->Set_Receive_Sequence_Number(m_next_Receive_Sequence_Number);
00062 
00063         // Fill the transmit sequence number and inform
00064         // retransmission queue if the packet is not
00065         // an acknowledgement packet
00066         if (p_Packet->GetType() != Datagram::ACKNOWLEDGEMENT)
00067         {
00068             p_Packet->Set_Transmit_Sequence_Number(m_next_Transmit_Sequence_Number);
00069             Modulo_Increment(m_next_Transmit_Sequence_Number);
00070             // Inform retransmission queue about the packet
00071             m_retransmission_Buffer.Add_Packet(p_Packet);
00072         }
00073 
00074         // Pass on the message for transmission to the lower layer. A pointer to the lower
00075         // layer is obtained from the parent layer.
00076         Protocol_Layer *p_Lower_Layer = m_p_Layer->Get_Lower_Layer();
00077         if (p_Lower_Layer)
00078         {
00079             p_Lower_Layer->Transmit(p_Packet);
00080         }
00081     }

void Transmit_Protocol_Handler::Handle_Transmit_Request Datagram * p_Packet  ) [inline]
 

Handle the transmission requests from the higher layer.

If the window is open, the packet is formed and transmitted to the lower layer. The packet is enqueued if the window is full.

Parameters:
p_Packet Pointer to the packet that needs to be transmitted.
See also:
Transmit Protocol Handler Design Pattern

Definition at line 107 of file Transmit_Protocol_Handler.h.

00108       {
00109           // Check for space in window
00110           if (m_retransmission_Buffer.Get_Window_Room() == 0)
00111           {
00112               // No space, window is full. The message waits
00113               // in the queue
00114               m_transmit_Queue.Add(p_Packet);
00115           }
00116           else
00117           {
00118               // If the window is open, transmit packet immediately
00119               Transmit_Packet(p_Packet);
00120           } 
00121       }

void Transmit_Protocol_Handler::Handle_Send_Ack_Request int new_Receive_Sequence_Number  ) [inline]
 

Handle ack transmission requests from the Receive Protocol Handler.

The Receive Protocol Handler specifies the sequence number that needs to be acknowledged. This method takes the following actions:

  • Save the sequence number that is being acknowledged.
  • Transmit a standalone ack if no packets are pending for transmission.
  • Wait for piggy backing of the ack if packets are pending for transmission.

Parameters:
new_Receive_Sequence_Number The updated receive sequence number that needs to be passed to the remote end.
See also:
Transmit Protocol Handler Design Pattern

Definition at line 134 of file Transmit_Protocol_Handler.h.

00135       {
00136           // Copy the new receive sequence number
00137           // to acknowledge a packet
00138           m_next_Receive_Sequence_Number = new_Receive_Sequence_Number;
00139 
00140           // If there are no more pending messages,
00141           // send an explicit acknowledgement message. If messages
00142           // are pending, ack can be piggy backed.
00143           if (m_transmit_Queue.Get_Length() == 0)
00144           {
00145               // No messages are pending transmission.
00146               // Send explicit ack
00147               Transmit_Packet(new Datagram(Datagram::ACKNOWLEDGEMENT));
00148           }
00149       }

void Transmit_Protocol_Handler::Handle_Received_Ack_Notification int acknowledged_Sequence_Number  ) [inline]
 

Handle acknowledgements that have been received by the Receive Protocol Handler.

The Receive_Protocol_Handler passes the acknowledged sequence number in the message. This method takes the following actions:

  • Pass the acknowledged sequence number to the Retransmission Buffer object.
  • The Retransmission Buffer processes the ack, updates the window and returns.
  • This acknowledegement might have opened the window. Initiate transmissions if there are pending transmissions and the window has room.

Parameters:
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 164 of file Transmit_Protocol_Handler.h.

00165       {
00166           Datagram *p_Packet;
00167 
00168           // Delegate ack processing to Retransmission Buffer
00169           m_retransmission_Buffer.Handle_Received_Ack_Notification(acknowledged_Sequence_Number);
00170 
00171           // Check if the transmit window has opened up. If there is is room in
00172           // the window, transmit packets waiting in the transmit queue
00173           int windowRoom = m_retransmission_Buffer.Get_Window_Room();
00174           for (int i=0; i < windowRoom && m_transmit_Queue.Get_Length(); i++)
00175           {
00176               p_Packet = m_transmit_Queue.Remove();
00177               Transmit_Packet(p_Packet);
00178           }
00179       }


Member Data Documentation

int Transmit_Protocol_Handler::m_next_Receive_Sequence_Number [private]
 

Receive sequence number to be sent in the next packet.

This acknowledges packets sent by the other end

Definition at line 33 of file Transmit_Protocol_Handler.h.


The documentation for this class was generated from the following file:
Generated on Sun Feb 13 21:30:38 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.