Changed name of Rime module ruc to unicast

This commit is contained in:
adamdunkels 2008-07-03 21:52:25 +00:00
parent eddf71f534
commit c2c3835110
12 changed files with 108 additions and 105 deletions

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rime.h,v 1.17 2008/06/30 20:00:53 adamdunkels Exp $
* $Id: rime.h,v 1.18 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -62,7 +62,7 @@
#include "net/rime/rmh.h"
#include "net/rime/route-discovery.h"
#include "net/rime/route.h"
#include "net/rime/ruc.h"
#include "net/rime/runicast.h"
#include "net/rime/rucb.h"
#include "net/rime/timesynch.h"
#include "net/rime/trickle.h"

View file

@ -1,7 +1,8 @@
RIME_CHAMELEON = chameleon.c channel.c chameleon-raw.c chameleon-bitopt.c
RIME_BASE = rimebuf.c queuebuf.c rimeaddr.c ctimer.c rime.c timesynch.c \
rimestats.c #announcement.c polite-announcement.c
RIME_SINGLEHOP = broadcast.c stbroadcast.c unicast.c stunicast.c ruc.c abc.c \
RIME_SINGLEHOP = broadcast.c stbroadcast.c unicast.c stunicast.c \
runicast.c abc.c \
rucb.c polite.c ipolite.c
RIME_MULTIHOP = nf.c mh.c rmh.c trickle.c
RIME_MESH = mesh.c route.c route-discovery.c

View file

@ -36,7 +36,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: collect.c,v 1.11 2008/06/30 09:15:22 adamdunkels Exp $
* $Id: collect.c,v 1.12 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -144,10 +144,10 @@ update_rtmetric(struct collect_conn *tc)
}
/*---------------------------------------------------------------------------*/
static void
node_packet_received(struct ruc_conn *c, rimeaddr_t *from, uint8_t seqno)
node_packet_received(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
{
struct collect_conn *tc = (struct collect_conn *)
((char *)c - offsetof(struct collect_conn, ruc_conn));
((char *)c - offsetof(struct collect_conn, runicast_conn));
struct neighbor *n;
int i;
@ -207,7 +207,7 @@ node_packet_received(struct ruc_conn *c, rimeaddr_t *from, uint8_t seqno)
#if NETSIM
ether_set_line(n->addr.u8[0], n->addr.u8[1]);
#endif /* NETSIM */
ruc_send(c, &n->addr, rimebuf_attr(RIMEBUF_ATTR_MAX_REXMIT));
runicast_send(c, &n->addr, rimebuf_attr(RIMEBUF_ATTR_MAX_REXMIT));
}
return;
} else {
@ -221,10 +221,11 @@ node_packet_received(struct ruc_conn *c, rimeaddr_t *from, uint8_t seqno)
}
/*---------------------------------------------------------------------------*/
static void
node_packet_sent(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions)
node_packet_sent(struct runicast_conn *c, rimeaddr_t *to,
uint8_t retransmissions)
{
struct collect_conn *tc = (struct collect_conn *)
((char *)c - offsetof(struct collect_conn, ruc_conn));
((char *)c - offsetof(struct collect_conn, runicast_conn));
tc->forwarding = 0;
neighbor_update_etx(neighbor_find(to), retransmissions);
@ -232,10 +233,11 @@ node_packet_sent(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions)
}
/*---------------------------------------------------------------------------*/
static void
node_packet_timedout(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions)
node_packet_timedout(struct runicast_conn *c, rimeaddr_t *to,
uint8_t retransmissions)
{
struct collect_conn *tc = (struct collect_conn *)
((char *)c - offsetof(struct collect_conn, ruc_conn));
((char *)c - offsetof(struct collect_conn, runicast_conn));
tc->forwarding = 0;
neighbor_timedout_etx(neighbor_find(to), retransmissions);
@ -264,7 +266,7 @@ adv_received(struct neighbor_discovery_conn *c, rimeaddr_t *from, uint16_t rtmet
update_rtmetric(tc);
}
/*---------------------------------------------------------------------------*/
static const struct ruc_callbacks ruc_callbacks = {node_packet_received,
static const struct runicast_callbacks runicast_callbacks = {node_packet_received,
node_packet_sent,
node_packet_timedout};
static const struct neighbor_discovery_callbacks neighbor_discovery_callbacks =
@ -279,7 +281,7 @@ collect_open(struct collect_conn *tc, uint16_t channels,
CLOCK_SECOND * 10,
CLOCK_SECOND * 60,
&neighbor_discovery_callbacks);
ruc_open(&tc->ruc_conn, channels + 1, &ruc_callbacks);
runicast_open(&tc->runicast_conn, channels + 1, &runicast_callbacks);
channel_set_attributes(channels + 1, attributes);
tc->rtmetric = RTMETRIC_MAX;
tc->cb = cb;
@ -290,7 +292,7 @@ void
collect_close(struct collect_conn *tc)
{
neighbor_discovery_close(&tc->neighbor_discovery_conn);
ruc_close(&tc->ruc_conn);
runicast_close(&tc->runicast_conn);
}
/*---------------------------------------------------------------------------*/
void
@ -330,7 +332,7 @@ collect_send(struct collect_conn *tc, int rexmits)
#if NETSIM
ether_set_line(n->addr.u8[0], n->addr.u8[1]);
#endif /* NETSIM */
return ruc_send(&tc->ruc_conn, &n->addr, rexmits);
return runicast_send(&tc->runicast_conn, &n->addr, rexmits);
} else {
/* printf("Didn't find any neighbor\n");*/
PRINTF("%d.%d: did not find any neighbor to send to\n",

View file

@ -47,7 +47,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: collect.h,v 1.7 2008/07/03 17:58:10 adamdunkels Exp $
* $Id: collect.h,v 1.8 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -61,7 +61,7 @@
#define __COLLECT_H__
#include "net/rime/ipolite.h"
#include "net/rime/ruc.h"
#include "net/rime/runicast.h"
#include "net/rime/neighbor-discovery.h"
#define COLLECT_ATTRIBUTES { RIMEBUF_ADDR_ESENDER, RIMEBUF_ADDRSIZE }, \
@ -69,7 +69,7 @@
{ RIMEBUF_ATTR_TTL, RIMEBUF_ATTR_BIT * 4 }, \
{ RIMEBUF_ATTR_HOPS, RIMEBUF_ATTR_BIT * 4 }, \
{ RIMEBUF_ATTR_MAX_REXMIT, RIMEBUF_ATTR_BIT * 3 }, \
RUC_ATTRIBUTES
RUNICAST_ATTRIBUTES
struct collect_callbacks {
void (* recv)(const rimeaddr_t *originator, uint8_t seqno,
@ -78,7 +78,7 @@ struct collect_callbacks {
struct collect_conn {
struct neighbor_discovery_conn neighbor_discovery_conn;
struct ruc_conn ruc_conn;
struct runicast_conn runicast_conn;
const struct collect_callbacks *cb;
struct ctimer t;
uint16_t rtmetric;

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rmh.c,v 1.6 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: rmh.c,v 1.7 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -64,7 +64,7 @@ struct data_hdr {
/*---------------------------------------------------------------------------*/
static void
received(struct ruc_conn *uc, rimeaddr_t *from, uint8_t seqno)
received(struct runicast_conn *uc, rimeaddr_t *from, uint8_t seqno)
{
struct rmh_conn *c = (struct rmh_conn *)uc;
struct data_hdr *msg = rimebuf_dataptr();
@ -89,24 +89,24 @@ received(struct ruc_conn *uc, rimeaddr_t *from, uint8_t seqno)
if(nexthop) {
PRINTF("forwarding to %d\n", rt->nexthop.u16[0]);
msg->hops++;
ruc_send(&c->c, nexthop, c->num_rexmit);
runicast_send(&c->c, nexthop, c->num_rexmit);
}
}
}
/*---------------------------------------------------------------------------*/
static void
sent(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions)
sent(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
{
}
/*---------------------------------------------------------------------------*/
static void
timedout(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions)
timedout(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
{
}
/*---------------------------------------------------------------------------*/
static const struct ruc_callbacks data_callbacks = { received ,
static const struct runicast_callbacks data_callbacks = { received ,
sent,
timedout};
/*---------------------------------------------------------------------------*/
@ -114,14 +114,14 @@ void
rmh_open(struct rmh_conn *c, uint16_t channel,
const struct rmh_callbacks *callbacks)
{
ruc_open(&c->c, channel, &data_callbacks);
runicast_open(&c->c, channel, &data_callbacks);
c->cb = callbacks;
}
/*---------------------------------------------------------------------------*/
void
rmh_close(struct rmh_conn *c)
{
ruc_close(&c->c);
runicast_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int
@ -150,7 +150,7 @@ rmh_send(struct rmh_conn *c, rimeaddr_t *to, uint8_t num_rexmit, uint8_t max_hop
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
hdr->hops = 1;
hdr->max_rexmits = num_rexmit;
ruc_send(&c->c, nexthop, num_rexmit);
runicast_send(&c->c, nexthop, num_rexmit);
}
return 1;
}

View file

@ -48,7 +48,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rmh.h,v 1.4 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: rmh.h,v 1.5 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -61,7 +61,7 @@
#ifndef __RMH_H__
#define __RMH_H__
#include "net/rime/ruc.h"
#include "net/rime/runicast.h"
#include "net/rime/rimeaddr.h"
struct rmh_conn;
@ -76,7 +76,7 @@ struct rmh_callbacks {
};
struct rmh_conn {
struct ruc_conn c;
struct runicast_conn c;
const struct rmh_callbacks *cb;
uint8_t num_rexmit;
};

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rucb.c,v 1.7 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: rucb.c,v 1.8 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -69,14 +69,14 @@ read_data(struct rucb_conn *c)
}
/*---------------------------------------------------------------------------*/
static void
acked(struct ruc_conn *ruc, rimeaddr_t *to, uint8_t retransmissions)
acked(struct runicast_conn *ruc, rimeaddr_t *to, uint8_t retransmissions)
{
struct rucb_conn *c = (struct rucb_conn *)ruc;
PRINTF("%d.%d: rucb acked\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
c->chunk++;
if(read_data(c) > 0) {
ruc_send(&c->c, &c->receiver, MAX_TRANSMISSIONS);
runicast_send(&c->c, &c->receiver, MAX_TRANSMISSIONS);
/* {
extern struct timetable cc2420_timetable;
timetable_print(&cc2420_timetable);
@ -85,7 +85,7 @@ acked(struct ruc_conn *ruc, rimeaddr_t *to, uint8_t retransmissions)
}
/*---------------------------------------------------------------------------*/
static void
timedout(struct ruc_conn *ruc, rimeaddr_t *to, uint8_t retransmissions)
timedout(struct runicast_conn *ruc, rimeaddr_t *to, uint8_t retransmissions)
{
struct rucb_conn *c = (struct rucb_conn *)ruc;
PRINTF("%d.%d: rucb timedout\n",
@ -96,7 +96,7 @@ timedout(struct ruc_conn *ruc, rimeaddr_t *to, uint8_t retransmissions)
}
/*---------------------------------------------------------------------------*/
static void
recv(struct ruc_conn *ruc, rimeaddr_t *from, uint8_t seqno)
recv(struct runicast_conn *ruc, rimeaddr_t *from, uint8_t seqno)
{
struct rucb_conn *c = (struct rucb_conn *)ruc;
@ -137,13 +137,13 @@ recv(struct ruc_conn *ruc, rimeaddr_t *from, uint8_t seqno)
}
}
/*---------------------------------------------------------------------------*/
static const struct ruc_callbacks ruc = {recv, acked, timedout};
static const struct runicast_callbacks ruc = {recv, acked, timedout};
/*---------------------------------------------------------------------------*/
void
rucb_open(struct rucb_conn *c, uint16_t channel,
const struct rucb_callbacks *u)
{
ruc_open(&c->c, channel, &ruc);
runicast_open(&c->c, channel, &ruc);
c->u = u;
c->last_seqno = -1;
}
@ -151,7 +151,7 @@ rucb_open(struct rucb_conn *c, uint16_t channel,
void
rucb_close(struct rucb_conn *c)
{
ruc_close(&c->c);
runicast_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int
@ -160,7 +160,7 @@ rucb_send(struct rucb_conn *c, rimeaddr_t *receiver)
read_data(c);
rimeaddr_copy(&c->receiver, receiver);
rimeaddr_copy(&c->sender, &rimeaddr_node_addr);
ruc_send(&c->c, receiver, MAX_TRANSMISSIONS);
runicast_send(&c->c, receiver, MAX_TRANSMISSIONS);
return 0;
}
/*---------------------------------------------------------------------------*/

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rucb.h,v 1.2 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: rucb.h,v 1.3 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -41,7 +41,7 @@
#ifndef __RUCB_H__
#define __RUCB_H__
#include "net/rime/ruc.h"
#include "net/rime/runicast.h"
struct rucb_conn;
@ -62,7 +62,7 @@ struct rucb_callbacks {
#define RUCB_DATASIZE 64
struct rucb_conn {
struct ruc_conn c;
struct runicast_conn c;
const struct rucb_callbacks *u;
rimeaddr_t receiver, sender;
uint16_t chunk;

View file

@ -1,5 +1,5 @@
/**
* \addtogroup rimeruc
* \addtogroup rimerunicast
* @{
*/
@ -34,7 +34,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ruc.c,v 1.20 2008/07/03 21:35:46 adamdunkels Exp $
* $Id: runicast.c,v 1.1 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -44,18 +44,18 @@
* Adam Dunkels <adam@sics.se>
*/
#include "net/rime/ruc.h"
#include "net/rime/runicast.h"
#include "net/rime/neighbor.h"
#include "net/rime.h"
#include <string.h>
#define RUC_PACKET_ID_BITS 2
#define RUNICAST_PACKET_ID_BITS 2
#define REXMIT_TIME CLOCK_SECOND
static const struct rimebuf_attrlist attributes[] =
{
RUC_ATTRIBUTES
RUNICAST_ATTRIBUTES
RIMEBUF_ATTR_LAST
};
@ -71,11 +71,11 @@ static const struct rimebuf_attrlist attributes[] =
static void
sent_by_stunicast(struct stunicast_conn *stunicast)
{
struct ruc_conn *c = (struct ruc_conn *)stunicast;
struct runicast_conn *c = (struct runicast_conn *)stunicast;
if(c->rxmit != 0) {
RIMESTATS_ADD(rexmit);
PRINTF("%d.%d: ruc: packet %u resent %u\n",
PRINTF("%d.%d: runicast: packet %u resent %u\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID), c->rxmit);
}
@ -87,7 +87,7 @@ sent_by_stunicast(struct stunicast_conn *stunicast)
if(c->u->timedout) {
c->u->timedout(c, stunicast_receiver(&c->c), c->rxmit);
}
PRINTF("%d.%d: ruc: packet %d timed out\n",
PRINTF("%d.%d: runicast: packet %d timed out\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->sndnxt);
} else {
@ -101,10 +101,10 @@ sent_by_stunicast(struct stunicast_conn *stunicast)
static void
recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
{
struct ruc_conn *c = (struct ruc_conn *)stunicast;
/* struct ruc_hdr *hdr = rimebuf_dataptr();*/
struct runicast_conn *c = (struct runicast_conn *)stunicast;
/* struct runicast_hdr *hdr = rimebuf_dataptr();*/
PRINTF("%d.%d: ruc: recv_from_stunicast from %d.%d type %d seqno %d\n",
PRINTF("%d.%d: runicast: recv_from_stunicast from %d.%d type %d seqno %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
from->u8[0], from->u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_TYPE),
@ -114,16 +114,16 @@ recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
RIMEBUF_ATTR_PACKET_TYPE_ACK) {
if(rimebuf_attr(RIMEBUF_ATTR_PACKET_ID) == c->sndnxt) {
RIMESTATS_ADD(ackrx);
PRINTF("%d.%d: ruc: ACKed %d\n",
PRINTF("%d.%d: runicast: ACKed %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID));
c->sndnxt = (c->sndnxt + 1) % (1 << RUC_PACKET_ID_BITS);
c->sndnxt = (c->sndnxt + 1) % (1 << RUNICAST_PACKET_ID_BITS);
stunicast_cancel(&c->c);
if(c->u->sent != NULL) {
c->u->sent(c, stunicast_receiver(&c->c), c->rxmit);
}
} else {
PRINTF("%d.%d: ruc: received bad ACK %d for %d\n",
PRINTF("%d.%d: runicast: received bad ACK %d for %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID),
c->sndnxt);
@ -137,22 +137,22 @@ recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
RIMESTATS_ADD(reliablerx);
PRINTF("%d.%d: ruc: got packet %d\n",
PRINTF("%d.%d: runicast: got packet %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID));
packet_seqno = rimebuf_attr(RIMEBUF_ATTR_PACKET_ID);
/* rimebuf_hdrreduce(sizeof(struct ruc_hdr));*/
/* rimebuf_hdrreduce(sizeof(struct runicast_hdr));*/
q = queuebuf_new_from_rimebuf();
PRINTF("%d.%d: ruc: Sending ACK to %d.%d for %d\n",
PRINTF("%d.%d: runicast: Sending ACK to %d.%d for %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
from->u8[0], from->u8[1],
packet_seqno);
rimebuf_clear();
/* rimebuf_hdralloc(sizeof(struct ruc_hdr));
/* rimebuf_hdralloc(sizeof(struct runicast_hdr));
hdr = rimebuf_hdrptr();
hdr->type = TYPE_ACK;
hdr->seqno = packet_seqno;*/
@ -170,13 +170,13 @@ recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
}
}
/*---------------------------------------------------------------------------*/
static const struct stunicast_callbacks ruc = {recv_from_stunicast, sent_by_stunicast};
static const struct stunicast_callbacks runicast = {recv_from_stunicast, sent_by_stunicast};
/*---------------------------------------------------------------------------*/
void
ruc_open(struct ruc_conn *c, uint16_t channel,
const struct ruc_callbacks *u)
runicast_open(struct runicast_conn *c, uint16_t channel,
const struct runicast_callbacks *u)
{
stunicast_open(&c->c, channel, &ruc);
stunicast_open(&c->c, channel, &runicast);
channel_set_attributes(channel, attributes);
c->u = u;
c->rxmit = 0;
@ -184,13 +184,13 @@ ruc_open(struct ruc_conn *c, uint16_t channel,
}
/*---------------------------------------------------------------------------*/
void
ruc_close(struct ruc_conn *c)
runicast_close(struct runicast_conn *c)
{
stunicast_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int
ruc_send(struct ruc_conn *c, rimeaddr_t *receiver, uint8_t max_retransmissions)
runicast_send(struct runicast_conn *c, rimeaddr_t *receiver, uint8_t max_retransmissions)
{
rimebuf_set_attr(RIMEBUF_ATTR_RELIABLE, 1);
rimebuf_set_attr(RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_PACKET_TYPE_DATA);
@ -198,7 +198,7 @@ ruc_send(struct ruc_conn *c, rimeaddr_t *receiver, uint8_t max_retransmissions)
c->max_rxmit = max_retransmissions;
c->rxmit = 0;
RIMESTATS_ADD(reliabletx);
PRINTF("%d.%d: ruc: sending packet %d\n",
PRINTF("%d.%d: runicast: sending packet %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->sndnxt);
return stunicast_send_stubborn(&c->c, receiver, REXMIT_TIME);

View file

@ -4,14 +4,14 @@
*/
/**
* \defgroup rimeruc Single-hop reliable unicast
* \defgroup rimerunicast Single-hop reliable unicast
* @{
*
* The ruc module implements a single-hop reliable unicast mechanism.
* The runicast module implements a single-hop reliable unicast mechanism.
*
* \section channels Channels
*
* The ruc module uses 1 channel.
* The runicast module uses 1 channel.
*
*/
@ -45,7 +45,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ruc.h,v 1.14 2008/07/03 21:35:46 adamdunkels Exp $
* $Id: runicast.h,v 1.1 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -55,36 +55,36 @@
* Adam Dunkels <adam@sics.se>
*/
#ifndef __RUC_H__
#define __RUC_H__
#ifndef __RUNICAST_H__
#define __RUNICAST_H__
#include "net/rime/stunicast.h"
struct ruc_conn;
struct runicast_conn;
#define RUC_ATTRIBUTES { RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_BIT }, \
#define RUNICAST_ATTRIBUTES { RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_BIT }, \
{ RIMEBUF_ATTR_PACKET_ID, RIMEBUF_ATTR_BIT * 2 }, \
STUNICAST_ATTRIBUTES
struct ruc_callbacks {
void (* recv)(struct ruc_conn *c, rimeaddr_t *from, uint8_t seqno);
void (* sent)(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions);
void (* timedout)(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions);
struct runicast_callbacks {
void (* recv)(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno);
void (* sent)(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions);
void (* timedout)(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions);
};
struct ruc_conn {
struct runicast_conn {
struct stunicast_conn c;
const struct ruc_callbacks *u;
const struct runicast_callbacks *u;
uint8_t sndnxt;
uint8_t rxmit;
uint8_t max_rxmit;
};
void ruc_open(struct ruc_conn *c, uint16_t channel,
const struct ruc_callbacks *u);
void ruc_close(struct ruc_conn *c);
void runicast_open(struct runicast_conn *c, uint16_t channel,
const struct runicast_callbacks *u);
void runicast_close(struct runicast_conn *c);
int ruc_send(struct ruc_conn *c, rimeaddr_t *receiver, uint8_t max_retransmissions);
int runicast_send(struct runicast_conn *c, rimeaddr_t *receiver, uint8_t max_retransmissions);
#endif /* __RUC_H__ */
#endif /* __RUNICAST_H__ */
/** @} */
/** @} */

View file

@ -4,6 +4,6 @@ TARGET=netsim
endif
all: example-abc example-mesh example-collect example-trickle example-polite \
example-rudolph0 example-rudolph1 example-rudolph2 example-rucb \
example-ruc example-unicast
example-runicast example-unicast
include $(CONTIKI)/Makefile.include

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: example-ruc.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $
* $Id: example-runicast.c,v 1.1 2008/07/03 21:52:25 adamdunkels Exp $
*/
/**
@ -50,39 +50,39 @@
#define MAX_RETRANSMISSIONS 4
/*---------------------------------------------------------------------------*/
PROCESS(test_ruc_process, "ruc test");
AUTOSTART_PROCESSES(&test_ruc_process);
PROCESS(test_runicast_process, "runicast test");
AUTOSTART_PROCESSES(&test_runicast_process);
/*---------------------------------------------------------------------------*/
static void
recv_ruc(struct ruc_conn *c, rimeaddr_t *from, uint8_t seqno)
recv_runicast(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
{
printf("ruc message received from %d.%d, seqno %d\n",
printf("runicast message received from %d.%d, seqno %d\n",
from->u8[0], from->u8[1], seqno);
}
static void
sent_ruc(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions)
sent_runicast(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
{
printf("ruc message sent to %d.%d, retransmissions %d\n",
printf("runicast message sent to %d.%d, retransmissions %d\n",
to->u8[0], to->u8[1], retransmissions);
}
static void
timedout_ruc(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions)
timedout_runicast(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
{
printf("ruc message timed out when sending to %d.%d, retransmissions %d\n",
printf("runicast message timed out when sending to %d.%d, retransmissions %d\n",
to->u8[0], to->u8[1], retransmissions);
}
static const struct ruc_callbacks ruc_callbacks = {recv_ruc,
sent_ruc,
timedout_ruc};
static struct ruc_conn ruc;
static const struct runicast_callbacks runicast_callbacks = {recv_runicast,
sent_runicast,
timedout_runicast};
static struct runicast_conn runicast;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_ruc_process, ev, data)
PROCESS_THREAD(test_runicast_process, ev, data)
{
PROCESS_EXITHANDLER(ruc_close(&ruc);)
PROCESS_EXITHANDLER(runicast_close(&runicast);)
PROCESS_BEGIN();
ruc_open(&ruc, 128, &ruc_callbacks);
runicast_open(&runicast, 128, &runicast_callbacks);
while(1) {
static struct etimer et;
@ -95,7 +95,7 @@ PROCESS_THREAD(test_ruc_process, ev, data)
rimebuf_copyfrom("Hello", 5);
addr.u8[0] = 41;
addr.u8[1] = 41;
ruc_send(&ruc, &addr, MAX_RETRANSMISSIONS);
runicast_send(&runicast, &addr, MAX_RETRANSMISSIONS);
}