SRP or Simple Retransmission Protocol is a protocol which retransmits packets if they have not been confirmed within a predefined time. More...
#include <stdint.h>
#include <stdbool.h>
#include "net/net.h"
Go to the source code of this file.
Data Structures | |
struct | SrpHeader |
Header used by SRP protocol. More... | |
Defines | |
#define | SRP_MAX_SIZE 512 |
Maximum size of one SRP message. | |
#define | SRP_TX_QUEUE_SIZE ( SRP_MAX_SIZE * 4 ) |
Transmit queue buffer size. | |
#define | SRP_TX_MAX_QUEUE 8 |
#define | SRP_RESEND_TIMEOUT 250 |
Timeout in milliseconds. | |
#define | SRP_RESEND_MAX 16 |
Max number of resends. | |
#define | SRP_RX_MAX_CACHE 16 |
Max receive confirms. | |
#define | SRP_FLG_MSG BIT(0) |
Contains message. | |
#define | SRP_FLG_BROADCAST BIT(1) |
Is broadcast (for future usage). | |
#define | SRP_FLG_ACK_SHIFT 4 |
Shift for the number of acks. | |
#define | SRP_FLG_ACK_MASK 0x30 |
Mask for the number of acks. | |
#define | SRP_MAX_PAYLOAD ( SRP_MAX_SIZE - sizeof(SrpHeader) ) |
maximum size of the payload of a SRP message. | |
#define | SRP_MAX_ACKS 2 |
Maximum number of acknowledges. | |
Functions | |
void | _srpUdpTx (SockAddr *txAddr, uint8_t *udpPayload, int len) |
Transmit UDP packet. | |
void | _srpRx (SockAddr *rxAddr, uint8_t *message, int len) |
Process a received SRP packet. | |
void | srpInit () |
Initializes the SRP protocol engine. | |
void | srpUdpRx (SockAddr *rxAddr, uint8_t *udpPayload, int len) |
Invoked by UDP stack for receiving a SRP packet. | |
bool | srpTx (SockAddr *txAddr, uint8_t *message, int len) |
Invoked by application for sending an SRP packet. | |
void | srpProcess () |
Should be called periodically to process any pending requests. |
SRP or Simple Retransmission Protocol is a protocol which retransmits packets if they have not been confirmed within a predefined time.
When a packet is lost, i.e. it has not been confirmed within a certain time, after multiple sends, it will notify the sender that the packet did not make it.
SRP is an asynchronous protocol, multiple packets may be in processing, being send but not confirmed. when replying the acknowledge of the sender may be in the receiving packets.
#define SRP_FLG_BROADCAST BIT(1) |
Is broadcast (for future usage).
#define SRP_MAX_ACKS 2 |
Maximum number of acknowledges.
#define SRP_MAX_SIZE 512 |
Maximum size of one SRP message.
#define SRP_TX_QUEUE_SIZE ( SRP_MAX_SIZE * 4 ) |
Transmit queue buffer size.
void _srpRx | ( | SockAddr * | addr, | |
uint8_t * | message, | |||
int | len | |||
) |
Process a received SRP packet.
Invoked by SRP when a SRP packet has been received.
This is a callback and must be implemented by the protocol stack.
rxAddr | The address of the sender. | |
message | The message to parse. | |
len | The length of the message. |
void _srpUdpTx | ( | SockAddr * | txAddr, | |
uint8_t * | udpPayload, | |||
int | len | |||
) |
Transmit UDP packet.
Invoked by SRP when its done formatting a packet.
This is a callback and must be implemented by the protocol stack.
txAddr | The addresss to send to. | |
udpPayload | The payload to transmit. | |
len | The length of the payload. |
bool srpTx | ( | SockAddr * | txAddr, | |
uint8_t * | message, | |||
int | len | |||
) |
Invoked by application for sending an SRP packet.
txIpAddr | The ip address to send to. | |
message | The message to send. | |
len | The length of the message. |
void srpUdpRx | ( | SockAddr * | rxAddr, | |
uint8_t * | udpPayload, | |||
int | len | |||
) |
Invoked by UDP stack for receiving a SRP packet.
rxAddr | The sender address. | |
udpPayload | The data in the udp packet. | |
len | The lenght of the payload. |