KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
srp.h File Reference

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...
 

Macros

#define SRP_MAX_SIZE   1028
 Maximum size of one SRP message. More...
 
#define SRP_TX_QUEUE_SIZE   ( SRP_MAX_SIZE * 3 )
 Transmit queue buffer size. More...
 
#define SRP_TX_MAX_QUEUE   32
 Allow up to 32 items on the TX queue.
 
#define SRP_RESEND_TIMEOUT   200
 Resend time-out in ms.
 
#define SRP_RESEND_MAX   6
 Max number of resends.
 
#define SRP_RX_MAX_CACHE   48
 Max receive confirms.
 
#define SRP_FLG_MSG   BIT(0)
 Contains message.
 
#define SRP_FLG_DONTACK   BIT(1)
 No ack required.
 
#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. More...
 

Functions

void srpDumpStatus ()
 Outputs SRP status information.
 
void _srpUdpTx (SockAddr *txAddr, uint8_t *udpPayload, int len)
 Transmit UDP packet. More...
 
void _srpRx (SockAddr *rxAddr, uint8_t *message, int len)
 Process a received SRP packet. More...
 
void _srpLost (SockAddr *addr, uint8_t msgId)
 Stub, invoked when an SRP message is lost. More...
 
void srpInit ()
 Initializes the SRP protocol engine. More...
 
void srpUdpRx (SockAddr *rxAddr, uint8_t *udpPayload, int len)
 Invoked by UDP stack for receiving a SRP packet. More...
 
bool srpTx (SockAddr *txAddr, uint8_t *message, int len)
 Invoked by application for sending an SRP packet. More...
 
void srpProcess ()
 Should be called periodically to process any pending requests.
 

Detailed Description

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.

Definition in file srp.h.

Macro Definition Documentation

#define SRP_MAX_ACKS   2

Maximum number of acknowledges.

Definition at line 46 of file srp.h.

#define SRP_MAX_SIZE   1028

Maximum size of one SRP message.

Definition at line 30 of file srp.h.

#define SRP_TX_QUEUE_SIZE   ( SRP_MAX_SIZE * 3 )

Transmit queue buffer size.

Definition at line 31 of file srp.h.

Function Documentation

void _srpLost ( SockAddr addr,
uint8_t  msgId 
)

Stub, invoked when an SRP message is lost.

Parameters
addrThe socket address
msgIdThe message ID

Definition at line 657 of file network.c.

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.

Note
Implementors should take care not to do too much in this call. Executing long running processes will stall SRP processing. Complecated tasks should be executed outside of this function.
Parameters
rxAddrThe address of the sender.
messageThe message to parse.
lenThe length of the message.

Process a received SRP packet.

Definition at line 605 of file network.c.

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.

Parameters
txAddrThe addresss to send to.
udpPayloadThe payload to transmit.
lenThe length of the payload.

Transmit UDP packet.

Definition at line 393 of file network.c.

void srpInit ( )

Initializes the SRP protocol engine.

Initializes the SRP protocol engine.

Definition at line 648 of file srp.c.

bool srpTx ( SockAddr txAddr,
uint8_t *  message,
int  len 
)

Invoked by application for sending an SRP packet.

Note
SRP packets may be no longer than SRP_MAX_PAYLOAD.
Parameters
txIpAddrThe ip address to send to.
messageThe message to send.
lenThe length of the message.

Invoked by application for sending an SRP packet.

Definition at line 586 of file srp.c.

void srpUdpRx ( SockAddr rxAddr,
uint8_t *  udpPayload,
int  len 
)

Invoked by UDP stack for receiving a SRP packet.

Parameters
rxAddrThe sender address.
udpPayloadThe data in the udp packet.
lenThe lenght of the payload.

Invoked by UDP stack for receiving a SRP packet.

Definition at line 408 of file srp.c.