Contiki-NG
Loading...
Searching...
No Matches
tsch-types.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, SICS Swedish ICT.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the Institute nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * This file is part of the Contiki operating system.
30 *
31 */
32
33/**
34* \addtogroup tsch
35* @{
36 * \file
37 * TSCH types
38 * \author
39 * Simon Duquennoy <simonduq@sics.se>
40 */
41
42#ifndef TSCH_TYPES_H_
43#define TSCH_TYPES_H_
44
45/********** Includes **********/
46
48#include "lib/list.h"
49#include "lib/ringbufindex.h"
50
51/********** Data types **********/
52
53/** \brief 802.15.4e link types. LINK_TYPE_ADVERTISING_ONLY is an extra one: for EB-only links. */
54enum link_type { LINK_TYPE_NORMAL, LINK_TYPE_ADVERTISING, LINK_TYPE_ADVERTISING_ONLY };
55
56/** \brief An IEEE 802.15.4-2015 TSCH link (also called cell or slot) */
57struct tsch_link {
58 /* Links are stored as a list: "next" must be the first field */
59 struct tsch_link *next;
60 /* Unique identifier */
61 uint16_t handle;
62 /* MAC address of neighbor */
63 linkaddr_t addr;
64 /* Slotframe identifier */
65 uint16_t slotframe_handle;
66 /* Identifier of Slotframe to which this link belongs
67 * Unused. */
68 /* uint8_t handle; */
69 /* Timeslot for this link */
70 uint16_t timeslot;
71 /* Channel offset for this link */
72 uint16_t channel_offset;
73 /* A bit string that defines
74 * b0 = Transmit, b1 = Receive, b2 = Shared, b3 = Timekeeping, b4 = reserved */
75 uint8_t link_options;
76 /* Type of link. NORMAL = 0. ADVERTISING = 1, and indicates
77 the link may be used to send an Enhanced beacon. */
79 /* Any other data for upper layers */
80 void *data;
81};
82
83/** \brief 802.15.4e slotframe (contains links) */
85 /* Slotframes are stored as a list: "next" must be the first field */
86 struct tsch_slotframe *next;
87 /* Unique identifier */
88 uint16_t handle;
89 /* Number of timeslots in the slotframe.
90 * Stored as struct asn_divisor_t because we often need ASN%size */
91 struct tsch_asn_divisor_t size;
92 /* List of links belonging to this slotframe */
93 LIST_STRUCT(links_list);
94};
95
96/** \brief TSCH packet information */
98 struct queuebuf *qb; /* pointer to the queuebuf to be sent */
99 mac_callback_t sent; /* callback for this packet */
100 void *ptr; /* MAC callback parameter */
101 uint8_t transmissions; /* #transmissions performed for this packet */
102 uint8_t max_transmissions; /* maximal number of Tx before dropping the packet */
103 uint8_t ret; /* status -- MAC return code */
104 uint8_t header_len; /* length of header and header IEs (needed for link-layer security) */
105 uint8_t tsch_sync_ie_offset; /* Offset within the frame used for quick update of EB ASN and join priority */
106};
107
108/** \brief TSCH neighbor information */
110 uint8_t is_broadcast; /* is this neighbor a virtual neighbor used for broadcast (of data packets or EBs) */
111 uint8_t is_time_source; /* is this neighbor a time source? */
112 uint8_t backoff_exponent; /* CSMA backoff exponent */
113 uint16_t backoff_window; /* CSMA backoff window (number of slots to skip) */
114 uint8_t tx_links_count; /* How many links do we have to this neighbor? */
115 uint8_t dedicated_tx_links_count; /* How many dedicated links do we have to this neighbor? */
116 /* Array for the ringbuf. Contains pointers to packets.
117 * Its size must be a power of two to allow for atomic put */
118 struct tsch_packet *tx_array[TSCH_QUEUE_NUM_PER_NEIGHBOR];
119 /* Circular buffer of pointers to packet. */
120 struct ringbufindex tx_ringbuf;
121};
122
123/** \brief TSCH timeslot timing elements. Used to index timeslot timing
124 * of different units, such as rtimer tick or micro-second */
126 tsch_ts_cca_offset,
127 tsch_ts_cca,
128 tsch_ts_tx_offset,
129 tsch_ts_rx_offset,
130 tsch_ts_rx_ack_delay,
131 tsch_ts_tx_ack_delay,
132 tsch_ts_rx_wait,
133 tsch_ts_ack_wait,
134 tsch_ts_rx_tx,
135 tsch_ts_max_ack,
136 tsch_ts_max_tx,
137 tsch_ts_timeslot_length,
138 tsch_ts_elements_count, /* Not a timing element */
139};
140
141/** \brief TSCH timeslot timing elements in rtimer ticks */
142typedef rtimer_clock_t tsch_timeslot_timing_ticks[tsch_ts_elements_count];
143
144/** \brief TSCH timeslot timing elements in micro-seconds */
145typedef uint16_t tsch_timeslot_timing_usec[tsch_ts_elements_count];
146
147/** \brief Stores data about an incoming packet */
149 uint8_t payload[TSCH_PACKET_MAX_LEN]; /* Packet payload */
150 struct tsch_asn_t rx_asn; /* ASN when the packet was received */
151 int len; /* Packet len */
152 int16_t rssi; /* RSSI for this packet */
153 uint8_t channel; /* Channel we received the packet on */
154};
155
156#endif /* TSCH_CONF_H_ */
157/** @} */
#define LIST_STRUCT(name)
Declare a linked list inside a structure declaraction.
Definition list.h:112
rtimer_clock_t tsch_timeslot_timing_ticks[tsch_ts_elements_count]
TSCH timeslot timing elements in rtimer ticks.
Definition tsch-types.h:142
tsch_timeslot_timing_elements
TSCH timeslot timing elements.
Definition tsch-types.h:125
link_type
802.15.4e link types.
Definition tsch-types.h:54
uint16_t tsch_timeslot_timing_usec[tsch_ts_elements_count]
TSCH timeslot timing elements in micro-seconds.
Definition tsch-types.h:145
Linked list manipulation routines.
Header file for the ringbufindex library.
Stores data about an incoming packet.
Definition tsch-types.h:148
For quick modulo operation on ASN.
Definition tsch-asn.h:54
The ASN is an absolute slot number over 5 bytes.
Definition tsch-asn.h:48
TSCH neighbor information.
Definition tsch-types.h:109
TSCH packet information.
Definition tsch-types.h:97
802.15.4e slotframe (contains links)
Definition tsch-types.h:84
TSCH 5-Byte Absolute Slot Number (ASN) management.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition uip-nd6.c:107