Contiki-NG
|
The IEEE 802.15.4-2015 TimeSlotted Channel Hopping (TSCH) protocol. More...
Files | |
file | tsch-adaptive-timesync.h |
TSCH adaptive time synchronization. | |
file | tsch-asn.h |
TSCH 5-Byte Absolute Slot Number (ASN) management. | |
file | tsch-conf.h |
TSCH configuration. | |
file | tsch-const.h |
TSCH constants. | |
file | tsch-log.h |
TSCH per-slot logging. | |
file | tsch-packet.h |
TSCH packet parsing and creation. | |
file | tsch-queue.h |
TSCH queues. | |
file | tsch-rpl.h |
TSCH-RPL interaction. | |
file | tsch-schedule.h |
TSCH scheduling engine. | |
file | tsch-security.h |
TSCH security. | |
file | tsch-slot-operation.h |
TSCH runtime operation within timeslots. | |
file | tsch-types.h |
TSCH types. | |
file | tsch.h |
Main API declarations for TSCH. | |
Data Structures | |
struct | tsch_asn_t |
The ASN is an absolute slot number over 5 bytes. More... | |
struct | tsch_asn_divisor_t |
For quick modulo operation on ASN. More... | |
struct | tsch_log_t |
Structure for a log. More... | |
struct | tsch_link |
An IEEE 802.15.4-2015 TSCH link (also called cell or slot) More... | |
struct | tsch_slotframe |
802.15.4e slotframe (contains links) More... | |
struct | tsch_packet |
TSCH packet information. More... | |
struct | tsch_neighbor |
TSCH neighbor information. More... | |
struct | input_packet |
Stores data about an incoming packet. More... | |
Macros | |
#define | TSCH_ASN_INIT(asn, ms1b_, ls4b_) |
Initialize ASN. | |
#define | TSCH_ASN_INC(asn, inc) |
Increment an ASN by inc (32 bits) | |
#define | TSCH_ASN_DEC(asn, dec) |
Decrement an ASN by inc (32 bits) | |
#define | TSCH_ASN_DIFF(asn1, asn2) ((asn1).ls4b - (asn2).ls4b) |
Returns the 32-bit diff between asn1 and asn2. | |
#define | TSCH_ASN_DIVISOR_INIT(div, val_) |
Initialize a struct asn_divisor_t. | |
#define | TSCH_ASN_MOD(asn, div) |
Returns the result (16 bits) of a modulo operation on ASN, with divisor being a struct asn_divisor_t. | |
#define | TSCH_LOG_ADD(log_type, init_code) |
Use this macro to add a log to the queue (will be printed out later, after leaving interrupt context) | |
Enumerations |
Functions | |
void | tsch_timesync_update (struct tsch_neighbor *n, uint16_t time_delta_asn, int32_t drift_correction) |
Updates timesync information for a given neighbor. More... | |
int32_t | tsch_timesync_adaptive_compensate (rtimer_clock_t delta_ticks) |
Computes time compensation for a given point in the future. More... | |
long int | tsch_adaptive_timesync_get_drift_ppm (void) |
Gives the estimated clock drift w.r.t. More... | |
struct tsch_log_t * | tsch_log_prepare_add (void) |
Prepare addition of a new log. More... | |
void | tsch_log_commit (void) |
Actually add the previously prepared log. | |
void | tsch_log_init (void) |
Initialize log module. | |
void | tsch_log_process_pending (void) |
Process pending log messages. | |
void | tsch_log_stop (void) |
Stop logging module. | |
int | tsch_packet_create_eack (uint8_t *buf, uint16_t buf_size, const linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack) |
Construct Enhanced ACK packet. More... | |
int | tsch_packet_parse_eack (const uint8_t *buf, int buf_size, uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len) |
Parse enhanced ACK packet. More... | |
int | tsch_packet_create_eb (uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr) |
Create an EB packet directly in packetbuf. More... | |
int | tsch_packet_update_eb (uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset) |
Update ASN in EB packet. More... | |
int | tsch_packet_parse_eb (const uint8_t *buf, int buf_size, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdrlen, int frame_without_mic) |
Parse EB. More... | |
void | tsch_packet_set_frame_pending (uint8_t *buf, int buf_size) |
Set frame pending bit in a packet (whose header was already build) More... | |
int | tsch_packet_get_frame_pending (uint8_t *buf, int buf_size) |
Get frame pending bit from a packet. More... | |
struct tsch_neighbor * | tsch_queue_add_nbr (const linkaddr_t *addr) |
Add a TSCH neighbor queue. More... | |
struct tsch_neighbor * | tsch_queue_get_nbr (const linkaddr_t *addr) |
Get a TSCH neighbor. More... | |
struct tsch_neighbor * | tsch_queue_get_time_source (void) |
Get the TSCH time source (we currently assume there is only one) More... | |
int | tsch_queue_update_time_source (const linkaddr_t *new_addr) |
Update TSCH time source. More... | |
struct tsch_packet * | tsch_queue_add_packet (const linkaddr_t *addr, uint8_t max_transmissions, mac_callback_t sent, void *ptr) |
Add packet to neighbor queue. More... | |
int | tsch_queue_global_packet_count (void) |
Returns the number of packets currently in all TSCH queues. More... | |
int | tsch_queue_packet_count (const linkaddr_t *addr) |
Returns the number of packets currently a given neighbor queue. More... | |
struct tsch_packet * | tsch_queue_remove_packet_from_queue (struct tsch_neighbor *n) |
Remove first packet from a neighbor queue. More... | |
void | tsch_queue_free_packet (struct tsch_packet *p) |
Free a packet. More... | |
int | tsch_queue_packet_sent (struct tsch_neighbor *n, struct tsch_packet *p, struct tsch_link *link, uint8_t mac_tx_status) |
Updates neighbor queue state after a transmission. More... | |
void | tsch_queue_reset (void) |
Reset neighbor queues module. | |
void | tsch_queue_free_unused_neighbors (void) |
Deallocate all neighbors with empty queue. | |
int | tsch_queue_is_empty (const struct tsch_neighbor *n) |
Is the neighbor queue empty? More... | |
struct tsch_packet * | tsch_queue_get_packet_for_nbr (const struct tsch_neighbor *n, struct tsch_link *link) |
Returns the first packet that can be sent from a queue on a given link. More... | |
struct tsch_packet * | tsch_queue_get_packet_for_dest_addr (const linkaddr_t *addr, struct tsch_link *link) |
Returns the first packet that can be sent to a given address on a given link. More... | |
struct tsch_packet * | tsch_queue_get_unicast_packet_for_any (struct tsch_neighbor **n, struct tsch_link *link) |
Gets the head packet of any neighbor queue with zero backoff counter. More... | |
int | tsch_queue_backoff_expired (const struct tsch_neighbor *n) |
Is the neighbor backoff timer expired? More... | |
void | tsch_queue_backoff_reset (struct tsch_neighbor *n) |
Reset neighbor backoff. More... | |
void | tsch_queue_backoff_inc (struct tsch_neighbor *n) |
Increment backoff exponent of a given neighbor queue, pick a new window. More... | |
void | tsch_queue_update_all_backoff_windows (const linkaddr_t *dest_addr) |
Decrement backoff window for the queue(s) able to Tx to a given address. More... | |
void | tsch_queue_init (void) |
Initialize TSCH queue module. | |
void | tsch_rpl_callback_ka_sent (int status, int transmissions) |
Report statiscs from KA packet sent in RPL. More... | |
void | tsch_rpl_callback_joining_network (void) |
Let RPL know that TSCH joined a new network. More... | |
void | tsch_rpl_callback_leaving_network (void) |
Let RPL know that TSCH joined a new network. More... | |
void | tsch_rpl_callback_new_dio_interval (clock_time_t dio_interval) |
Set TSCH EB period based on current RPL DIO period. More... | |
void | tsch_rpl_callback_parent_switch (rpl_parent_t *old, rpl_parent_t *new) |
Set TSCH time source based on current RPL preferred parent. More... | |
struct tsch_slotframe * | tsch_schedule_add_slotframe (uint16_t handle, uint16_t size) |
Creates and adds a new slotframe. More... | |
int | tsch_schedule_remove_all_slotframes (void) |
Removes all slotframes, resulting in an empty schedule. More... | |
int | tsch_schedule_remove_slotframe (struct tsch_slotframe *slotframe) |
Removes a slotframe. More... | |
struct tsch_slotframe * | tsch_schedule_get_slotframe_by_handle (uint16_t handle) |
Looks up a slotframe by handle. More... | |
struct tsch_link * | tsch_schedule_get_link_by_handle (uint16_t handle) |
Looks for a link from a handle. More... | |
struct tsch_link * | tsch_schedule_add_link (struct tsch_slotframe *slotframe, uint8_t link_options, enum link_type link_type, const linkaddr_t *address, uint16_t timeslot, uint16_t channel_offset) |
Adds a link to a slotframe. More... | |
int | tsch_schedule_remove_link (struct tsch_slotframe *slotframe, struct tsch_link *l) |
Removes a link. More... | |
int | tsch_schedule_remove_link_by_timeslot (struct tsch_slotframe *slotframe, uint16_t timeslot) |
Removes a link from a slotframe and timeslot. More... | |
struct tsch_link * | tsch_schedule_get_link_by_timeslot (struct tsch_slotframe *slotframe, uint16_t timeslot) |
Looks within a slotframe for a link with a given timeslot. More... | |
struct tsch_link * | tsch_schedule_get_next_active_link (struct tsch_asn_t *asn, uint16_t *time_offset, struct tsch_link **backup_link) |
Returns the next active link after a given ASN, and a backup link (for the same ASN, with Rx flag) More... | |
int | tsch_schedule_init (void) |
Module initialization, call only once at init. More... | |
void | tsch_schedule_create_minimal (void) |
Create a 6tisch minimal schedule with length TSCH_SCHEDULE_DEFAULT_LENGTH. | |
struct tsch_slotframe * | tsch_schedule_slotframe_head (void) |
Access the first item in the list of slotframes. More... | |
struct tsch_slotframe * | tsch_schedule_slotframe_next (struct tsch_slotframe *sf) |
Access the next item in the list of slotframes. More... | |
void | tsch_schedule_print (void) |
Prints out the current schedule (all slotframes and links) | |
unsigned int | tsch_security_mic_len (const frame802154_t *frame) |
Return MIC length. More... | |
unsigned int | tsch_security_secure_frame (uint8_t *hdr, uint8_t *outbuf, int hdrlen, int datalen, struct tsch_asn_t *asn) |
Protect a frame with encryption and/or MIC. More... | |
unsigned int | tsch_security_parse_frame (const uint8_t *hdr, int hdrlen, int datalen, const frame802154_t *frame, const linkaddr_t *sender, struct tsch_asn_t *asn) |
Parse and check a frame protected with encryption and/or MIC. More... | |
int | tsch_is_locked (void) |
Checks if the TSCH lock is set. More... | |
int | tsch_get_lock (void) |
Takes the TSCH lock. More... | |
void | tsch_release_lock (void) |
Releases the TSCH lock. | |
uint8_t | tsch_calculate_channel (struct tsch_asn_t *asn, uint8_t channel_offset) |
Returns a 802.15.4 channel from an ASN and channel offset. More... | |
static void | tsch_radio_on (enum tsch_radio_state_on_cmd command) |
This function turns on the radio. More... | |
static void | tsch_radio_off (enum tsch_radio_state_off_cmd command) |
This function turns off the radio. More... | |
void | tsch_slot_operation_start (void) |
Start actual slot operation. | |
void | tsch_slot_operation_sync (rtimer_clock_t next_slot_start, struct tsch_asn_t *next_slot_asn) |
Set global time before starting slot operation, with a rtimer time and an ASN. More... | |
void | tsch_set_coordinator (int enable) |
Set the node as PAN coordinator. More... | |
void | tsch_set_pan_secured (int enable) |
Enable/disable security. More... | |
void | tsch_set_join_priority (uint8_t jp) |
Set the TSCH join priority (JP) More... | |
void | tsch_set_ka_timeout (uint32_t timeout) |
Set the desynchronization timeout after which a node sends a unicasst keep-alive (KA) to its time source. More... | |
void | tsch_set_eb_period (uint32_t period) |
Set the period at wich TSCH enhanced beacons (EBs) are sent. More... | |
void | tsch_schedule_keepalive (void) |
Schedule a keep-alive transmission within [timeout*0.9, timeout[. More... | |
void | tsch_schedule_keepalive_immediately (void) |
Schedule a keep-alive immediately. | |
void | tsch_disassociate (void) |
Leave the TSCH network we are currently in. | |
Variables | |
struct tsch_neighbor * | last_timesource_neighbor |
The neighbor last used as our time source. | |
struct tsch_neighbor * | last_timesource_neighbor = NULL |
The neighbor last used as our time source. | |
The IEEE 802.15.4-2015 TimeSlotted Channel Hopping (TSCH) protocol.
Provides scheduled communication on top of a globally-synchronized network. Performs frequency hopping for enhanced reliability.
enum link_type |
802.15.4e link types.
LINK_TYPE_ADVERTISING_ONLY is an extra one: for EB-only links.
Definition at line 54 of file tsch-types.h.
TSCH timeslot timing elements.
Used to index timeslot timing of different units, such as rtimer tick or micro-second
Definition at line 129 of file tsch-types.h.
long int tsch_adaptive_timesync_get_drift_ppm | ( | void | ) |
Gives the estimated clock drift w.r.t.
the time source in PPM (parts per million)
uint8_t tsch_calculate_channel | ( | struct tsch_asn_t * | asn, |
uint8_t | channel_offset | ||
) |
Returns a 802.15.4 channel from an ASN and channel offset.
Basically adds The offset to the ASN and performs a hopping sequence lookup.
asn | A given ASN |
channel_offset | A given channel offset |
Definition at line 249 of file tsch-slot-operation.c.
References TSCH_ASN_MOD.
Referenced by tsch_radio_off().
int tsch_get_lock | ( | void | ) |
Takes the TSCH lock.
When the lock is taken, slot operation will be skipped until release.
Definition at line 197 of file tsch-slot-operation.c.
References RTIMER_NOW, and TSCH_LOG_ADD.
Referenced by tsch_queue_add_nbr(), tsch_queue_update_time_source(), tsch_schedule_add_link(), tsch_schedule_add_slotframe(), tsch_schedule_init(), tsch_schedule_remove_link(), and tsch_schedule_remove_slotframe().
int tsch_is_locked | ( | void | ) |
Checks if the TSCH lock is set.
Accesses to global structures outside of interrupts must be done through the lock, unless the sturcutre has atomic read/write
Definition at line 190 of file tsch-slot-operation.c.
Referenced by tsch_queue_add_packet(), tsch_queue_free_unused_neighbors(), tsch_queue_get_nbr(), tsch_queue_get_packet_for_dest_addr(), tsch_queue_get_packet_for_nbr(), tsch_queue_get_time_source(), tsch_queue_get_unicast_packet_for_any(), tsch_queue_is_empty(), tsch_queue_packet_count(), tsch_queue_remove_packet_from_queue(), tsch_queue_reset(), tsch_queue_update_all_backoff_windows(), tsch_queue_update_time_source(), tsch_schedule_get_link_by_handle(), tsch_schedule_get_link_by_timeslot(), tsch_schedule_get_next_active_link(), tsch_schedule_get_slotframe_by_handle(), and tsch_schedule_print().
struct tsch_log_t* tsch_log_prepare_add | ( | void | ) |
Prepare addition of a new log.
int tsch_packet_create_eack | ( | uint8_t * | buf, |
uint16_t | buf_size, | ||
const linkaddr_t * | dest_addr, | ||
uint8_t | seqno, | ||
int16_t | drift, | ||
int | nack | ||
) |
Construct Enhanced ACK packet.
buf | The buffer where to build the EACK |
buf_size | The buffer size |
dest_addr | The link-layer address of the neighbor we are ACKing |
seqno | The sequence number we are ACKing |
drift | The time offset in usec measured at Rx of the packer we are ACKing |
nack | Value of the NACK bit |
Definition at line 93 of file tsch-packet.c.
References frame802154_t::dest_addr, frame802154_create(), frame802154_hdrlen(), frame80215e_create_ie_header_ack_nack_time_correction(), linkaddr_copy(), linkaddr_node_addr, and frame802154_t::src_addr.
Referenced by tsch_radio_off().
int tsch_packet_create_eb | ( | uint8_t * | hdr_len, |
uint8_t * | tsch_sync_ie_ptr | ||
) |
Create an EB packet directly in packetbuf.
hdr_len | A pointer where to store the length of the created header |
tsch_sync_ie_ptr | A pointer where to store the address of the TSCH synchronization IE |
Definition at line 227 of file tsch-packet.c.
References linkaddr_node_addr, packetbuf_clear(), packetbuf_datalen(), packetbuf_dataptr(), packetbuf_hdralloc(), packetbuf_hdrlen(), packetbuf_hdrptr(), packetbuf_remaininglen(), packetbuf_set_datalen(), packetbuf_totlen(), tsch_schedule_get_link_by_timeslot(), and tsch_schedule_get_slotframe_by_handle().
Referenced by tsch_disassociate().
int tsch_packet_get_frame_pending | ( | uint8_t * | buf, |
int | buf_size | ||
) |
Get frame pending bit from a packet.
buf | The buffer where the packet resides |
buf_size | The buffer size |
Definition at line 474 of file tsch-packet.c.
Referenced by tsch_radio_off().
int tsch_packet_parse_eack | ( | const uint8_t * | buf, |
int | buf_size, | ||
uint8_t | seqno, | ||
frame802154_t * | frame, | ||
struct ieee802154_ies * | ies, | ||
uint8_t * | hdr_len | ||
) |
Parse enhanced ACK packet.
buf | The buffer where to parse the EACK from |
buf_size | The buffer size |
seqno | The sequence number we are expecting |
frame | The frame structure where to store parsed fields |
ies | The IE structure where to store parsed IEs |
hdr_len | A pointer where to store the length of the parsed header |
Definition at line 162 of file tsch-packet.c.
References frame802154_t::fcf, frame802154_parse(), frame802154_fcf_t::ie_list_present, linkaddr_cmp(), linkaddr_node_addr, linkaddr_null, frame802154_t::seq, and tsch_security_mic_len().
Referenced by tsch_radio_off().
int tsch_packet_parse_eb | ( | const uint8_t * | buf, |
int | buf_size, | ||
frame802154_t * | frame, | ||
struct ieee802154_ies * | ies, | ||
uint8_t * | hdrlen, | ||
int | frame_without_mic | ||
) |
Parse EB.
buf | The buffer where to parse the EB from |
buf_size | The buffer sizecting |
frame | The frame structure where to store parsed fields |
ies | The IE structure where to store parsed IEs |
hdrlen | A pointer where to store the length of the parsed header |
frame_without_mic | When set, the security MIC will not be parsed |
Definition at line 401 of file tsch-packet.c.
References frame802154_t::dest_addr, frame802154_t::dest_pid, frame802154_t::fcf, frame802154_parse(), frame802154_fcf_t::frame_type, frame802154_fcf_t::frame_version, frame802154_fcf_t::ie_list_present, frame802154_t::src_addr, frame802154_t::src_pid, and tsch_security_mic_len().
Referenced by tsch_disassociate(), and tsch_schedule_keepalive_immediately().
void tsch_packet_set_frame_pending | ( | uint8_t * | buf, |
int | buf_size | ||
) |
Set frame pending bit in a packet (whose header was already build)
buf | The buffer where the packet resides |
buf_size | The buffer size |
Definition at line 467 of file tsch-packet.c.
Referenced by tsch_radio_off().
int tsch_packet_update_eb | ( | uint8_t * | buf, |
int | buf_size, | ||
uint8_t | tsch_sync_ie_offset | ||
) |
Update ASN in EB packet.
buf | The buffer that contains the EB |
buf_size | The buffer size |
tsch_sync_ie_offset | The offset of the TSCH synchronization IE, in which the ASN is to be written |
Definition at line 391 of file tsch-packet.c.
Referenced by tsch_radio_off().
struct tsch_neighbor * tsch_queue_add_nbr | ( | const linkaddr_t * | addr | ) |
Add a TSCH neighbor queue.
addr | The link-layer address of the neighbor to be added |
Definition at line 80 of file tsch-queue.c.
References linkaddr_cmp(), linkaddr_copy(), list_add(), memb_alloc(), ringbufindex_init(), tsch_get_lock(), tsch_queue_backoff_reset(), tsch_queue_get_nbr(), and tsch_release_lock().
Referenced by tsch_disassociate(), tsch_queue_add_packet(), tsch_queue_init(), tsch_queue_packet_count(), tsch_queue_update_time_source(), tsch_schedule_add_link(), and tsch_schedule_remove_link().
struct tsch_packet * tsch_queue_add_packet | ( | const linkaddr_t * | addr, |
uint8_t | max_transmissions, | ||
mac_callback_t | sent, | ||
void * | ptr | ||
) |
Add packet to neighbor queue.
Use same lockfree implementation as ringbuf.c (put is atomic)
addr | The address of the targetted neighbor, &tsch_broadcast_address for broadcast |
max_transmissions | The number of MAC retries |
sent | The MAC packet sent callback |
ptr | The MAC packet send callback parameter |
Definition at line 228 of file tsch-queue.c.
References MAC_TX_DEFERRED, memb_alloc(), memb_free(), ringbufindex_peek_put(), ringbufindex_put(), tsch_is_locked(), and tsch_queue_add_nbr().
Referenced by tsch_disassociate().
int tsch_queue_backoff_expired | ( | const struct tsch_neighbor * | n | ) |
Is the neighbor backoff timer expired?
n | The neighbor queue |
Definition at line 471 of file tsch-queue.c.
Referenced by tsch_queue_get_packet_for_nbr().
void tsch_queue_backoff_inc | ( | struct tsch_neighbor * | n | ) |
Increment backoff exponent of a given neighbor queue, pick a new window.
n | The neighbor queue |
Definition at line 486 of file tsch-queue.c.
References random_rand().
Referenced by tsch_queue_packet_sent().
void tsch_queue_backoff_reset | ( | struct tsch_neighbor * | n | ) |
Reset neighbor backoff.
n | The neighbor queue |
Definition at line 478 of file tsch-queue.c.
Referenced by tsch_queue_add_nbr(), tsch_queue_packet_sent(), and tsch_queue_reset().
void tsch_queue_free_packet | ( | struct tsch_packet * | p | ) |
Free a packet.
p | The packet to be freed |
Definition at line 310 of file tsch-queue.c.
References memb_free().
Referenced by tsch_queue_update_time_source(), and tsch_schedule_keepalive_immediately().
struct tsch_neighbor * tsch_queue_get_nbr | ( | const linkaddr_t * | addr | ) |
Get a TSCH neighbor.
addr | The link-layer address of the neighbor we are looking for |
Definition at line 108 of file tsch-queue.c.
References linkaddr_cmp(), list_head(), list_item_next(), and tsch_is_locked().
Referenced by tsch_queue_add_nbr(), tsch_queue_get_packet_for_dest_addr(), and tsch_radio_off().
struct tsch_packet * tsch_queue_get_packet_for_dest_addr | ( | const linkaddr_t * | addr, |
struct tsch_link * | link | ||
) |
Returns the first packet that can be sent to a given address on a given link.
addr | The target link-layer address |
link | The link |
Definition at line 436 of file tsch-queue.c.
References tsch_is_locked(), tsch_queue_get_nbr(), and tsch_queue_get_packet_for_nbr().
struct tsch_packet * tsch_queue_get_packet_for_nbr | ( | const struct tsch_neighbor * | n, |
struct tsch_link * | link | ||
) |
Returns the first packet that can be sent from a queue on a given link.
n | The neighbor queue |
link | The link |
Definition at line 408 of file tsch-queue.c.
References ringbufindex_peek_get(), tsch_is_locked(), and tsch_queue_backoff_expired().
Referenced by tsch_queue_get_packet_for_dest_addr(), and tsch_queue_get_unicast_packet_for_any().
struct tsch_neighbor * tsch_queue_get_time_source | ( | void | ) |
Get the TSCH time source (we currently assume there is only one)
Definition at line 124 of file tsch-queue.c.
References list_head(), list_item_next(), and tsch_is_locked().
Referenced by tsch_queue_update_time_source(), tsch_schedule_keepalive_immediately(), and tsch_set_eb_period().
struct tsch_packet * tsch_queue_get_unicast_packet_for_any | ( | struct tsch_neighbor ** | n, |
struct tsch_link * | link | ||
) |
Gets the head packet of any neighbor queue with zero backoff counter.
n | A pointer where to store the neighbor queue to be used for Tx |
link | The link to be used for Tx |
Definition at line 447 of file tsch-queue.c.
References list_head(), list_item_next(), tsch_is_locked(), and tsch_queue_get_packet_for_nbr().
int tsch_queue_global_packet_count | ( | void | ) |
Returns the number of packets currently in all TSCH queues.
Definition at line 271 of file tsch-queue.c.
Referenced by tsch_disassociate().
int tsch_queue_is_empty | ( | const struct tsch_neighbor * | n | ) |
Is the neighbor queue empty?
n | The neighbor queue |
Definition at line 401 of file tsch-queue.c.
References ringbufindex_empty(), and tsch_is_locked().
Referenced by tsch_queue_free_unused_neighbors(), tsch_queue_packet_sent(), and tsch_queue_update_time_source().
int tsch_queue_packet_count | ( | const linkaddr_t * | addr | ) |
Returns the number of packets currently a given neighbor queue.
addr | The link-layer address of the neighbor we are interested in |
Definition at line 278 of file tsch-queue.c.
References ringbufindex_elements(), tsch_is_locked(), and tsch_queue_add_nbr().
Referenced by tsch_disassociate(), and tsch_radio_off().
int tsch_queue_packet_sent | ( | struct tsch_neighbor * | n, |
struct tsch_packet * | p, | ||
struct tsch_link * | link, | ||
uint8_t | mac_tx_status | ||
) |
Updates neighbor queue state after a transmission.
n | The neighbor queue we just sent from |
p | The packet that was just sent |
link | The TSCH link used for Tx |
mac_tx_status | The MAC status (see mac.h) |
Definition at line 320 of file tsch-queue.c.
References MAC_TX_OK, tsch_queue_backoff_inc(), tsch_queue_backoff_reset(), tsch_queue_is_empty(), and tsch_queue_remove_packet_from_queue().
Referenced by tsch_radio_off().
struct tsch_packet * tsch_queue_remove_packet_from_queue | ( | struct tsch_neighbor * | n | ) |
Remove first packet from a neighbor queue.
The packet is stored in a separate dequeued packet list, for later processing.
n | The neighbor queue |
Definition at line 292 of file tsch-queue.c.
References ringbufindex_get(), and tsch_is_locked().
Referenced by tsch_queue_packet_sent(), and tsch_queue_update_time_source().
void tsch_queue_update_all_backoff_windows | ( | const linkaddr_t * | dest_addr | ) |
Decrement backoff window for the queue(s) able to Tx to a given address.
dest_addr | The target address, &tsch_broadcast_address for broadcast |
Definition at line 501 of file tsch-queue.c.
References linkaddr_cmp(), list_head(), list_item_next(), and tsch_is_locked().
Referenced by tsch_radio_off().
int tsch_queue_update_time_source | ( | const linkaddr_t * | new_addr | ) |
Update TSCH time source.
new_addr | The address of the new TSCH time source |
Definition at line 140 of file tsch-queue.c.
References list_remove(), MAC_TX_ERR, memb_free(), tsch_get_lock(), tsch_is_locked(), tsch_queue_add_nbr(), tsch_queue_free_packet(), tsch_queue_get_time_source(), tsch_queue_is_empty(), tsch_queue_remove_packet_from_queue(), tsch_release_lock(), and tsch_set_ka_timeout().
Referenced by tsch_disassociate(), tsch_schedule_keepalive_immediately(), and tsch_set_eb_period().
|
static |
This function turns off the radio.
In the same way as for tsch_radio_on(), it depends on the value of TSCH_RADIO_ON_DURING_TIMESLOT constant:
Definition at line 396 of file tsch-slot-operation.c.
References frame802154_fcf_t::ack_required, frame802154_t::aux_hdr, clock_time(), frame802154_t::fcf, frame802154_parse(), frame802154_fcf_t::frame_type, linkaddr_cmp(), linkaddr_copy(), linkaddr_node_addr, linkaddr_null, MAC_TX_COLLISION, MAC_TX_ERR, MAC_TX_NOACK, MAC_TX_OK, process_poll(), PT_BEGIN, PT_END, PT_SPAWN, PT_THREAD, PT_YIELD, RADIO_RX_MODE_ADDRESS_FILTER, ringbufindex_peek_put(), ringbufindex_put(), RTIMER_NOW, frame802154_aux_hdr_t::security_control, frame802154_scf_t::security_level, frame802154_t::seq, frame802154_t::src_addr, TSCH_ASN_DIFF, TSCH_ASN_INC, tsch_calculate_channel(), tsch_disassociate(), TSCH_LOG_ADD, tsch_packet_create_eack(), tsch_packet_get_frame_pending(), tsch_packet_parse_eack(), tsch_packet_set_frame_pending(), tsch_packet_update_eb(), tsch_queue_get_nbr(), tsch_queue_packet_count(), tsch_queue_packet_sent(), tsch_queue_update_all_backoff_windows(), tsch_radio_on(), tsch_schedule_get_next_active_link(), tsch_schedule_keepalive(), tsch_security_mic_len(), tsch_security_parse_frame(), tsch_security_secure_frame(), tsch_timesync_adaptive_compensate(), and tsch_timesync_update().
|
static |
This function turns on the radio.
Its semantics is dependent on the value of TSCH_RADIO_ON_DURING_TIMESLOT constant:
Definition at line 365 of file tsch-slot-operation.c.
Referenced by tsch_radio_off().
void tsch_rpl_callback_joining_network | ( | void | ) |
Let RPL know that TSCH joined a new network.
To use, set TSCH_CALLBACK_JOINING_NETWORK to tsch_rpl_callback_joining_network
void tsch_rpl_callback_ka_sent | ( | int | status, |
int | transmissions | ||
) |
Report statiscs from KA packet sent in RPL.
To use, set TSCH_CALLBACK_KA_SENT to tsch_rpl_callback_ka_sent
status | The packet sent status |
transmissions | The total number of transmissions |
void tsch_rpl_callback_leaving_network | ( | void | ) |
Let RPL know that TSCH joined a new network.
Triggers a local repair. To use, set TSCH_CALLBACK_LEAVING_NETWORK to tsch_rpl_callback_leaving_network
void tsch_rpl_callback_new_dio_interval | ( | clock_time_t | dio_interval | ) |
Set TSCH EB period based on current RPL DIO period.
To use, set RPL_CALLBACK_NEW_DIO_INTERVAL to tsch_rpl_callback_new_dio_interval
dio_interval | The new DIO interval in clock ticks |
void tsch_rpl_callback_parent_switch | ( | rpl_parent_t * | old, |
rpl_parent_t * | new | ||
) |
Set TSCH time source based on current RPL preferred parent.
To use, set RPL_CALLBACK_PARENT_SWITCH to tsch_rpl_callback_parent_switch
old | The old RPL parent |
new | The new RPL parent |
struct tsch_link* tsch_schedule_add_link | ( | struct tsch_slotframe * | slotframe, |
uint8_t | link_options, | ||
enum link_type | link_type, | ||
const linkaddr_t * | address, | ||
uint16_t | timeslot, | ||
uint16_t | channel_offset | ||
) |
Adds a link to a slotframe.
slotframe | The slotframe that will contain the new link |
link_options | The link options, as a bitfield (LINK_OPTION_* flags) |
link_type | The link type (advertising, normal) |
address | The link address of the intended destination. Use &tsch_broadcast_address for a slot towards any neighbor |
timeslot | The link timeslot within the slotframe |
channel_offset | The link channel offset |
Definition at line 176 of file tsch-schedule.c.
References linkaddr_copy(), linkaddr_null, list_add(), memb_alloc(), tsch_get_lock(), tsch_queue_add_nbr(), tsch_release_lock(), and tsch_schedule_remove_link_by_timeslot().
Referenced by tsch_disassociate(), and tsch_schedule_create_minimal().
struct tsch_slotframe * tsch_schedule_add_slotframe | ( | uint16_t | handle, |
uint16_t | size | ||
) |
Creates and adds a new slotframe.
handle | the slotframe handle |
size | the slotframe size |
Definition at line 72 of file tsch-schedule.c.
References list_add(), LIST_STRUCT_INIT, memb_alloc(), TSCH_ASN_DIVISOR_INIT, tsch_get_lock(), tsch_release_lock(), and tsch_schedule_get_slotframe_by_handle().
Referenced by tsch_disassociate(), and tsch_schedule_create_minimal().
struct tsch_link * tsch_schedule_get_link_by_handle | ( | uint16_t | handle | ) |
Looks for a link from a handle.
handle | The target handle |
Definition at line 155 of file tsch-schedule.c.
References list_head(), list_item_next(), and tsch_is_locked().
struct tsch_link * tsch_schedule_get_link_by_timeslot | ( | struct tsch_slotframe * | slotframe, |
uint16_t | timeslot | ||
) |
Looks within a slotframe for a link with a given timeslot.
slotframe | The desired slotframe |
timeslot | The desired timeslot |
Definition at line 303 of file tsch-schedule.c.
References list_head(), list_item_next(), and tsch_is_locked().
Referenced by tsch_packet_create_eb(), and tsch_schedule_remove_link_by_timeslot().
struct tsch_link * tsch_schedule_get_next_active_link | ( | struct tsch_asn_t * | asn, |
uint16_t * | time_offset, | ||
struct tsch_link ** | backup_link | ||
) |
Returns the next active link after a given ASN, and a backup link (for the same ASN, with Rx flag)
asn | The base ASN, from which we look for the next active link |
time_offset | A pointer to uint16_t where to store the time offset between base ASN and link found |
backup_link | A pointer where to write the address of a backup link, to be executed should the original be no longer active at wakeup |
Definition at line 323 of file tsch-schedule.c.
References list_head(), list_item_next(), TSCH_ASN_MOD, and tsch_is_locked().
Referenced by tsch_radio_off(), and tsch_slot_operation_start().
struct tsch_slotframe * tsch_schedule_get_slotframe_by_handle | ( | uint16_t | handle | ) |
Looks up a slotframe by handle.
handle | the slotframe handle |
Definition at line 139 of file tsch-schedule.c.
References list_head(), list_item_next(), and tsch_is_locked().
Referenced by tsch_packet_create_eb(), and tsch_schedule_add_slotframe().
int tsch_schedule_init | ( | void | ) |
Module initialization, call only once at init.
Definition at line 398 of file tsch-schedule.c.
References list_init(), memb_init(), tsch_get_lock(), and tsch_release_lock().
Referenced by tsch_disassociate().
void tsch_schedule_keepalive | ( | void | ) |
Schedule a keep-alive transmission within [timeout*0.9, timeout[.
Definition at line 314 of file tsch.c.
References ctimer_set(), and random_rand().
Referenced by tsch_disassociate(), tsch_radio_off(), tsch_set_eb_period(), and tsch_set_ka_timeout().
int tsch_schedule_remove_all_slotframes | ( | void | ) |
Removes all slotframes, resulting in an empty schedule.
Definition at line 103 of file tsch-schedule.c.
References list_head(), and tsch_schedule_remove_slotframe().
Referenced by tsch_disassociate(), and tsch_schedule_create_minimal().
int tsch_schedule_remove_link | ( | struct tsch_slotframe * | slotframe, |
struct tsch_link * | l | ||
) |
Removes a link.
slotframe | The slotframe the link belongs to |
l | The link to be removed |
Definition at line 246 of file tsch-schedule.c.
References addr, linkaddr_copy(), list_remove(), memb_free(), tsch_get_lock(), tsch_queue_add_nbr(), and tsch_release_lock().
Referenced by tsch_schedule_remove_link_by_timeslot(), and tsch_schedule_remove_slotframe().
int tsch_schedule_remove_link_by_timeslot | ( | struct tsch_slotframe * | slotframe, |
uint16_t | timeslot | ||
) |
Removes a link from a slotframe and timeslot.
slotframe | The slotframe where to look for the link |
timeslot | The timeslot where to look for the link within the target slotframe |
Definition at line 295 of file tsch-schedule.c.
References tsch_schedule_get_link_by_timeslot(), and tsch_schedule_remove_link().
Referenced by tsch_schedule_add_link().
int tsch_schedule_remove_slotframe | ( | struct tsch_slotframe * | slotframe | ) |
Removes a slotframe.
slotframe | The slotframe to be removed |
Definition at line 116 of file tsch-schedule.c.
References list_head(), list_remove(), memb_free(), tsch_get_lock(), tsch_release_lock(), and tsch_schedule_remove_link().
Referenced by tsch_schedule_remove_all_slotframes().
struct tsch_slotframe * tsch_schedule_slotframe_head | ( | void | ) |
Access the first item in the list of slotframes.
Definition at line 432 of file tsch-schedule.c.
References list_head().
struct tsch_slotframe * tsch_schedule_slotframe_next | ( | struct tsch_slotframe * | sf | ) |
Access the next item in the list of slotframes.
sf | The current slotframe (item in the list) |
Definition at line 438 of file tsch-schedule.c.
References list_item_next().
unsigned int tsch_security_mic_len | ( | const frame802154_t * | frame | ) |
Return MIC length.
Definition at line 122 of file tsch-security.c.
References frame802154_t::aux_hdr, frame802154_t::fcf, frame802154_aux_hdr_t::security_control, frame802154_fcf_t::security_enabled, and frame802154_scf_t::security_level.
Referenced by tsch_disassociate(), tsch_packet_parse_eack(), tsch_packet_parse_eb(), tsch_radio_off(), tsch_security_parse_frame(), and tsch_security_secure_frame().
unsigned int tsch_security_parse_frame | ( | const uint8_t * | hdr, |
int | hdrlen, | ||
int | datalen, | ||
const frame802154_t * | frame, | ||
const linkaddr_t * | sender, | ||
struct tsch_asn_t * | asn | ||
) |
Parse and check a frame protected with encryption and/or MIC.
0 | On error or security check failure (insecure frame) |
1 | On success or no need for security check (good frame) |
Definition at line 203 of file tsch-security.c.
References frame802154_t::aux_hdr, frame802154_t::fcf, frame802154_aux_hdr_t::key_index, frame802154_aux_hdr_t::security_control, frame802154_fcf_t::security_enabled, frame802154_scf_t::security_level, and tsch_security_mic_len().
Referenced by tsch_disassociate(), and tsch_radio_off().
unsigned int tsch_security_secure_frame | ( | uint8_t * | hdr, |
uint8_t * | outbuf, | ||
int | hdrlen, | ||
int | datalen, | ||
struct tsch_asn_t * | asn | ||
) |
Protect a frame with encryption and/or MIC.
Definition at line 132 of file tsch-security.c.
References frame802154_t::aux_hdr, frame802154_t::fcf, frame802154_parse(), frame802154_aux_hdr_t::key_index, linkaddr_node_addr, frame802154_aux_hdr_t::security_control, frame802154_fcf_t::security_enabled, frame802154_scf_t::security_level, and tsch_security_mic_len().
Referenced by tsch_radio_off().
void tsch_set_coordinator | ( | int | enable | ) |
Set the node as PAN coordinator.
enable | 1 to be coordinator, 0 to be a node |
Definition at line 177 of file tsch.c.
References tsch_set_eb_period().
void tsch_set_eb_period | ( | uint32_t | period | ) |
Set the period at wich TSCH enhanced beacons (EBs) are sent.
The period can not be set to exceed TSCH_MAX_EB_PERIOD. Set to 0 to stop sending EBs. Actual transmissions are jittered, spaced by a random number within [period*0.75, period[
period | The period in Clock ticks. |
Definition at line 210 of file tsch.c.
References linkaddr_cmp(), linkaddr_copy(), linkaddr_null, MAC_TX_NOACK, packetbuf_clear(), process_post_synch(), mac_driver::send, TSCH_ASN_INIT, tsch_disassociate(), tsch_queue_free_unused_neighbors(), tsch_queue_get_time_source(), tsch_queue_reset(), tsch_queue_update_time_source(), tsch_schedule_keepalive(), and tsch_schedule_keepalive_immediately().
Referenced by tsch_set_coordinator().
void tsch_set_join_priority | ( | uint8_t | jp | ) |
void tsch_set_ka_timeout | ( | uint32_t | timeout | ) |
Set the desynchronization timeout after which a node sends a unicasst keep-alive (KA) to its time source.
Set to 0 to stop sending KAs. The actual timeout is a random number within [timeout*0.9, timeout[
timeout | The timeout in Clock ticks. |
Definition at line 199 of file tsch.c.
References ctimer_stop(), and tsch_schedule_keepalive().
Referenced by tsch_queue_update_time_source().
void tsch_set_pan_secured | ( | int | enable | ) |
Enable/disable security.
If done at the coordinator, the Information will be included in EBs, and all nodes will adopt the same security level. Enabling requires compilation with LLSEC802154_ENABLED set. Note: when LLSEC802154_ENABLED is set, nodes boot with security enabled.
enable | 1 to enable security, 0 to disable it |
void tsch_slot_operation_sync | ( | rtimer_clock_t | next_slot_start, |
struct tsch_asn_t * | next_slot_asn | ||
) |
Set global time before starting slot operation, with a rtimer time and an ASN.
next_slot_start | the time to the start of the next slot, in rtimer ticks |
next_slot_asn | the ASN of the next slot |
Definition at line 1102 of file tsch-slot-operation.c.
References clock_time().
Referenced by tsch_disassociate(), and tsch_schedule_keepalive_immediately().
int32_t tsch_timesync_adaptive_compensate | ( | rtimer_clock_t | delta_ticks | ) |
Computes time compensation for a given point in the future.
delta_ticks | The number of ticks in the future we want to calculate compensation for |
Definition at line 199 of file tsch-adaptive-timesync.c.
Referenced by tsch_radio_off().
void tsch_timesync_update | ( | struct tsch_neighbor * | n, |
uint16_t | time_delta_asn, | ||
int32_t | drift_correction | ||
) |
Updates timesync information for a given neighbor.
n | The neighbor |
time_delta_asn | ASN time delta since last synchronization, i.e. number of slots elapsed |
drift_correction | The measured drift in ticks since last synchronization |
Definition at line 194 of file tsch-adaptive-timesync.c.
Referenced by tsch_radio_off().