#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "sbuffers.h"
#include "setting.h"
#include "net.h"
#include "errors.h"
Data Structures | |
struct | ext_item |
struct | item |
struct | Tsending_buffers |
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 (char *value) |
ARTP
library for send buffers.
|
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.
|
|
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.
|
|
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.
|
|
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.).
|
|
Get packet dedicated to send. This function returns packet which has to be sent (and its other information if necessary).
|
|
Return packet to resend. This function returns packet which has to be resent (it's taken from the head of structure for retransmissions).
|
|
Return identified send buffer size. This function finds out send buffer size and returns it.
|
|
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).
|
|
Initialize send buffers. This function makes some initial steps - currently it initializes mutex used for retransmit structure.
|
|
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.
|
|
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.
|