Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

sbuffers.h File Reference

#include <netinet/in.h>
#include <sys/socket.h>
#include "types.h"

Go to the source code of this file.

Defines

#define ARTP_SBUFFERS_H   1

Functions

int sbuffers_init (void)
int sbuffers_create (struct sockaddr *receiver)
int sbuffers_destroy (int id_buffer)
int sbuffers_get_size (int id_buffer, unsigned long int *buffer_size)
int sbuffers_add_packet (int id_buffer, struct sockaddr *receiver, SID_TYPE sid, char *value, int size, SEQ_TYPE seq)
int sbuffers_get_packet (int id_buffer, char **value, int *size, struct sockaddr **receiver)
int sbuffers_send_event (int id_buffer, char *bitstream, int size, double sent_time, double time_to_resend)
int sbuffers_resend_event (double time_to_resend)
int sbuffers_ack_event (int id_buffer, struct sockaddr *sender, SID_TYPE sid, SEQ_TYPE seq, int *size, double *time)
double sbuffers_get_top_rsnd_time (void)
int sbuffers_get_rsnd_packet (char **value, int *size, struct sockaddr **receiver, double *first_send_time)
int sbuffers_ignore_first_rsnd ()


Detailed Description

ARTP library for send buffers.
Author:
Tomas Rebok
Date:
2004

Function Documentation

int sbuffers_ack_event int    id_buffer,
struct sockaddr *    sender,
SID_TYPE    sid,
SEQ_TYPE    seq,
int *    size,
double *    time
 

Delete packet from sent packets buffer. This function deletes packet from sent buffer after incoming acknowledgement packet. Packet is searched depending on its sequence number (for established sessions) or depending on its sequence number, sender and session identifier (for non-established sessions). It's deleted from structure for retransmissions, too. If deleted packet wasn't resent, its sent time is returned, too (for computing round trip time). Its size is returned, too.

Parameters:
id_buffer  the identification number of send buffer.
sender  the pointer to the place where sender's address is stored.
sid  the session identification number which this packet belongs to.
seq  packet sequence number.
size  the pointer to the place where deleted packet size will be stored.
time  the pointer to the place where deleted packet sent time could be stored.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_add_packet int    id_buffer,
struct sockaddr *    receiver,
SID_TYPE    sid,
char *    value,
int    size,
SEQ_TYPE    seq
 

Add packet to send. This function adds packet which has to be sent. This adding is a bit complicated because of slipper (this is made for mutual exclusion of reading and adding threads). First of all new item is inserted to the end of complete buffer (after slipper) and its signed as a new slipper. Then all necessary information is copied to the old slipper and then it's signed (the old slipper) as a new valid item.

Parameters:
id_buffer  the identification number of send buffer.
receiver  the pointer to the place where the packet's receiver is stored. It's used for non-established sessions only. Otherwise it could be NULL.
sid  the session identification number. It's used for non-established sessions only. Otherwise it could be any value.
value  the pointer to the place where the packet value is stored.
size  the size of packet payload.
seq  the packet sequence number.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_create struct sockaddr *    receiver
 

Create send buffer. At the beginning this function searches first free space for creating new buffer in the array of pointers to all allocated buffers. If there's any, it's used. If there isn't, the array is resized and last pointer is used. Then all slippers are made and all buffer's parameters are set to its default values.

Parameters:
receiver  the pointer to the place where session receiver is stored.
Returns:
above or equal zero success. Creating buffer identification number is returned.
Returns:
below zero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_destroy int    id_buffer
 

Destroy send buffers. This function destroys relevant send buffer. It unallocates place used by that buffer and makes some other clearing steps (deletes all sent and unsent packets, destroys all its help structures and semaphores, etc.).

Parameters:
id_buffer  the identification number of destroying buffer.
Returns:
zero success
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_get_packet int    id_buffer,
char **    value,
int *    size,
struct sockaddr **    receiver
 

Get packet dedicated to send. This function returns packet which has to be sent (and its other information if necessary).

Parameters:
id_buffer  the identification number of send buffer.
value  the relevant pointer which will be moved to the place where the packet payload will be saved.
size  the pointer to the place where the packet size will be stored.
receiver  the relevant pointer which will be moved to the place where the packet receiver is stored.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_get_rsnd_packet char **    value,
int *    size,
struct sockaddr **    receiver,
double *    first_send_time
 

Return packet to resend. This function returns packet which has to be resent (it's taken from the head of structure for retransmissions).

Parameters:
value  the relevant pointer which will be moved to the place where the packet payload will be saved.
size  the pointer to the place where the packet size will be stored.
receiver  the relevant pointer which will be moved to the place where the packet's receiver is stored.
first_send_time  the pointer to the place where the packet's first send time could be stored (used for detecting connection errors).
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_get_size int    id_buffer,
unsigned long int *    buffer_size
 

Return identified send buffer size. This function finds out send buffer size and returns it.

Parameters:
id_buffer  the identification number of send buffer.
buffer_size  the pointer to the place where buffer size could be stored.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

double sbuffers_get_top_rsnd_time void   
 

Return the smallest time to resend. This function looks to the head of structure for retransmissions and returns the minimal time when some packet has to be resend (if any).

Returns:
above zero the minimal packet resend time.
Returns:
below zero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_ignore_first_rsnd  
 

Skip the top packet in structure for retransmissions. This function skips the leading packet in structure for retransmissions. It's used when connection fail is detected - no other packets which belongs to that connection are retransmitted any more.

Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_init void   
 

Initialize send buffers. This function makes some initial steps - currently it initializes mutex used for retransmit structure.

Returns:
zero success
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_resend_event double    time_to_resend
 

Move last resend packet to its new position in retransmit structure. This function has to be called after retransmitting some packet. It moves that packet to its new position (depending on its next time to resend) in structure for retransmissions.

Parameters:
time_to_resend  time when was this packet should be resend next.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int sbuffers_send_event int    id_buffer,
char *    bitstream,
int    size,
double    sent_time,
double    time_to_resend
 

Move packet from send packets buffer to sent packets buffer. This function moves defined acket from send packets buffer to sent packets buffer. This function has to be called after packet sending. If the packet is different from the one stored in buffer, it won't do any steps (this situation may appear when two threads sent the same packet simultaneously). The adding is a bit complicated again (because of threads mutual exclusion). The moved packet is inserted at the end of sent packets buffer (after the old slipper) and is signed as a slipper, too. All its values are copied to the old one (pointers are moved only). Now we have to insert this new packet into the structure for retransmissions (it's sorted by packet next retransmission time). Then the moved packet is signed as a valid item.

Parameters:
id_buffer  the identification number of send buffer.
bitstream  the pointer to the place where the moved packet value is stored.
size  the size of moved packet payload.
sent_time  the time when moved packet was sent.
time_to_resend  the time when this packet should be resent (if no acknowledge will come).
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).


Generated on Fri May 21 07:50:25 2004 for Active Router Transport Protocol (ARTP) by doxygen1.2.15