Changed name of suc module to stunicast

This commit is contained in:
adamdunkels 2008-07-03 21:35:46 +00:00
parent 8a1ed696d9
commit eddf71f534
5 changed files with 71 additions and 72 deletions

View File

@ -1,6 +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
RIME_SINGLEHOP=broadcast.c stbroadcast.c unicast.c suc.c ruc.c abc.c rucb.c polite.c ipolite.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 \
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
RIME_COLLECT = collect.c neighbor.c neighbor-discovery.c

View File

@ -34,7 +34,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ruc.c,v 1.19 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: ruc.c,v 1.20 2008/07/03 21:35:46 adamdunkels Exp $
*/
/**
@ -53,9 +53,6 @@
#define REXMIT_TIME CLOCK_SECOND
#define TYPE_DATA 0
#define TYPE_ACK 1
static const struct rimebuf_attrlist attributes[] =
{
RUC_ATTRIBUTES
@ -72,9 +69,9 @@ static const struct rimebuf_attrlist attributes[] =
/*---------------------------------------------------------------------------*/
static void
sent_by_suc(struct suc_conn *suc)
sent_by_stunicast(struct stunicast_conn *stunicast)
{
struct ruc_conn *c = (struct ruc_conn *)suc;
struct ruc_conn *c = (struct ruc_conn *)stunicast;
if(c->rxmit != 0) {
RIMESTATS_ADD(rexmit);
@ -86,9 +83,9 @@ sent_by_suc(struct suc_conn *suc)
c->rxmit++;
if(c->rxmit >= c->max_rxmit) {
RIMESTATS_ADD(timedout);
suc_cancel(&c->c);
stunicast_cancel(&c->c);
if(c->u->timedout) {
c->u->timedout(c, suc_receiver(&c->c), c->rxmit);
c->u->timedout(c, stunicast_receiver(&c->c), c->rxmit);
}
PRINTF("%d.%d: ruc: packet %d timed out\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
@ -97,17 +94,17 @@ sent_by_suc(struct suc_conn *suc)
int shift;
shift = c->rxmit > 4? 4: c->rxmit;
suc_set_timer(&c->c, (REXMIT_TIME) << shift);
stunicast_set_timer(&c->c, (REXMIT_TIME) << shift);
}
}
/*---------------------------------------------------------------------------*/
static void
recv_from_suc(struct suc_conn *suc, rimeaddr_t *from)
recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
{
struct ruc_conn *c = (struct ruc_conn *)suc;
struct ruc_conn *c = (struct ruc_conn *)stunicast;
/* struct ruc_hdr *hdr = rimebuf_dataptr();*/
PRINTF("%d.%d: ruc: recv_from_suc from %d.%d type %d seqno %d\n",
PRINTF("%d.%d: ruc: 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),
@ -121,9 +118,9 @@ recv_from_suc(struct suc_conn *suc, rimeaddr_t *from)
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);
suc_cancel(&c->c);
stunicast_cancel(&c->c);
if(c->u->sent != NULL) {
c->u->sent(c, suc_receiver(&c->c), c->rxmit);
c->u->sent(c, stunicast_receiver(&c->c), c->rxmit);
}
} else {
PRINTF("%d.%d: ruc: received bad ACK %d for %d\n",
@ -161,7 +158,7 @@ recv_from_suc(struct suc_conn *suc, rimeaddr_t *from)
hdr->seqno = packet_seqno;*/
rimebuf_set_attr(RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_PACKET_TYPE_ACK);
rimebuf_set_attr(RIMEBUF_ATTR_PACKET_ID, packet_seqno);
suc_send(&c->c, from);
stunicast_send(&c->c, from);
RIMESTATS_ADD(acktx);
queuebuf_to_rimebuf(q);
@ -173,13 +170,13 @@ recv_from_suc(struct suc_conn *suc, rimeaddr_t *from)
}
}
/*---------------------------------------------------------------------------*/
static const struct suc_callbacks ruc = {recv_from_suc, sent_by_suc};
static const struct stunicast_callbacks ruc = {recv_from_stunicast, sent_by_stunicast};
/*---------------------------------------------------------------------------*/
void
ruc_open(struct ruc_conn *c, uint16_t channel,
const struct ruc_callbacks *u)
{
suc_open(&c->c, channel, &ruc);
stunicast_open(&c->c, channel, &ruc);
channel_set_attributes(channel, attributes);
c->u = u;
c->rxmit = 0;
@ -189,7 +186,7 @@ ruc_open(struct ruc_conn *c, uint16_t channel,
void
ruc_close(struct ruc_conn *c)
{
suc_close(&c->c);
stunicast_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int
@ -204,7 +201,7 @@ ruc_send(struct ruc_conn *c, rimeaddr_t *receiver, uint8_t max_retransmissions)
PRINTF("%d.%d: ruc: sending packet %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->sndnxt);
return suc_send_stubborn(&c->c, receiver, REXMIT_TIME);
return stunicast_send_stubborn(&c->c, receiver, REXMIT_TIME);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -45,7 +45,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ruc.h,v 1.13 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: ruc.h,v 1.14 2008/07/03 21:35:46 adamdunkels Exp $
*/
/**
@ -58,13 +58,13 @@
#ifndef __RUC_H__
#define __RUC_H__
#include "net/rime/suc.h"
#include "net/rime/stunicast.h"
struct ruc_conn;
#define RUC_ATTRIBUTES { RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_BIT }, \
{ RIMEBUF_ATTR_PACKET_ID, RIMEBUF_ATTR_BIT * 2 }, \
SUC_ATTRIBUTES
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);
@ -72,7 +72,7 @@ struct ruc_callbacks {
};
struct ruc_conn {
struct suc_conn c;
struct stunicast_conn c;
const struct ruc_callbacks *u;
uint8_t sndnxt;
uint8_t rxmit;

View File

@ -1,5 +1,5 @@
/**
* \addtogroup rimesuc
* \addtogroup rimestunicast
* @{
*/
@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: suc.c,v 1.13 2008/06/26 11:19:22 adamdunkels Exp $
* $Id: stunicast.c,v 1.1 2008/07/03 21:35:46 adamdunkels Exp $
*/
/**
@ -43,7 +43,7 @@
* Adam Dunkels <adam@sics.se>
*/
#include "net/rime/suc.h"
#include "net/rime/stunicast.h"
#include "net/rime.h"
#include <string.h>
@ -59,8 +59,8 @@
static void
recv_from_uc(struct unicast_conn *uc, rimeaddr_t *from)
{
register struct suc_conn *c = (struct suc_conn *)uc;
PRINTF("%d.%d: suc: recv_from_uc from %d.%d\n",
register struct stunicast_conn *c = (struct stunicast_conn *)uc;
PRINTF("%d.%d: stunicast: recv_from_uc from %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
from->u8[0], from->u8[1]);
if(c->u->recv != NULL) {
@ -68,18 +68,18 @@ recv_from_uc(struct unicast_conn *uc, rimeaddr_t *from)
}
}
/*---------------------------------------------------------------------------*/
static const struct unicast_callbacks suc = {recv_from_uc};
static const struct unicast_callbacks stunicast = {recv_from_uc};
/*---------------------------------------------------------------------------*/
void
suc_open(struct suc_conn *c, uint16_t channel,
const struct suc_callbacks *u)
stunicast_open(struct stunicast_conn *c, uint16_t channel,
const struct stunicast_callbacks *u)
{
unicast_open(&c->c, channel, &suc);
unicast_open(&c->c, channel, &stunicast);
c->u = u;
}
/*---------------------------------------------------------------------------*/
void
suc_close(struct suc_conn *c)
stunicast_close(struct stunicast_conn *c)
{
unicast_close(&c->c);
ctimer_stop(&c->t);
@ -89,7 +89,7 @@ suc_close(struct suc_conn *c)
}
/*---------------------------------------------------------------------------*/
rimeaddr_t *
suc_receiver(struct suc_conn *c)
stunicast_receiver(struct stunicast_conn *c)
{
return &c->receiver;
}
@ -97,27 +97,27 @@ suc_receiver(struct suc_conn *c)
static void
send(void *ptr)
{
struct suc_conn *c = ptr;
struct stunicast_conn *c = ptr;
PRINTF("%d.%d: suc: resend to %d.%d\n",
PRINTF("%d.%d: stunicast: resend to %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->receiver.u8[0], c->receiver.u8[1]);
queuebuf_to_rimebuf(c->buf);
unicast_send(&c->c, &c->receiver);
suc_set_timer(c, CLOCK_SECOND);
stunicast_set_timer(c, CLOCK_SECOND);
if(c->u->sent != NULL) {
c->u->sent(c);
}
}
/*---------------------------------------------------------------------------*/
void
suc_set_timer(struct suc_conn *c, clock_time_t t)
stunicast_set_timer(struct stunicast_conn *c, clock_time_t t)
{
ctimer_set(&c->t, t, send, c);
}
/*---------------------------------------------------------------------------*/
int
suc_send_stubborn(struct suc_conn *c, rimeaddr_t *receiver,
stunicast_send_stubborn(struct stunicast_conn *c, rimeaddr_t *receiver,
clock_time_t rxmittime)
{
if(c->buf != NULL) {
@ -130,7 +130,7 @@ suc_send_stubborn(struct suc_conn *c, rimeaddr_t *receiver,
rimeaddr_copy(&c->receiver, receiver);
ctimer_set(&c->t, rxmittime, send, c);
PRINTF("%d.%d: suc_send_stubborn to %d.%d\n",
PRINTF("%d.%d: stunicast_send_stubborn to %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->receiver.u8[0],c->receiver.u8[1]);
unicast_send(&c->c, &c->receiver);
@ -143,16 +143,16 @@ suc_send_stubborn(struct suc_conn *c, rimeaddr_t *receiver,
}
/*---------------------------------------------------------------------------*/
int
suc_send(struct suc_conn *c, rimeaddr_t *receiver)
stunicast_send(struct stunicast_conn *c, rimeaddr_t *receiver)
{
PRINTF("%d.%d: suc_send to %d.%d\n",
PRINTF("%d.%d: stunicast_send to %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
receiver->u8[0], receiver->u8[1]);
return unicast_send(&c->c, receiver);
}
/*---------------------------------------------------------------------------*/
void
suc_cancel(struct suc_conn *c)
stunicast_cancel(struct stunicast_conn *c)
{
ctimer_stop(&c->t);
}

View File

@ -4,14 +4,14 @@
*/
/**
* \defgroup rimesuc Stubborn unicast
* \defgroup rimestunicast Stubborn unicast
* @{
*
* The suc module takes one packet and sends it repetedly.
* The stunicast module takes one packet and sends it repetedly.
*
* \section channels Channels
*
* The suc module uses 1 channel.
* The stunicast module uses 1 channel.
*
*/
@ -45,7 +45,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: suc.h,v 1.12 2008/06/26 11:19:22 adamdunkels Exp $
* $Id: stunicast.h,v 1.1 2008/07/03 21:35:46 adamdunkels Exp $
*/
/**
@ -55,44 +55,44 @@
* Adam Dunkels <adam@sics.se>
*/
#ifndef __SUC_H__
#define __SUC_H__
#ifndef __STUNICAST_H__
#define __STUNICAST_H__
#include "net/rime/unicast.h"
#include "net/rime/ctimer.h"
#include "net/rime/queuebuf.h"
struct suc_conn;
struct stunicast_conn;
#define SUC_ATTRIBUTES UNICAST_ATTRIBUTES
#define STUNICAST_ATTRIBUTES UNICAST_ATTRIBUTES
struct suc_callbacks {
void (* recv)(struct suc_conn *c, rimeaddr_t *from);
void (* sent)(struct suc_conn *c);
struct stunicast_callbacks {
void (* recv)(struct stunicast_conn *c, rimeaddr_t *from);
void (* sent)(struct stunicast_conn *c);
};
struct suc_conn {
struct stunicast_conn {
struct unicast_conn c;
struct ctimer t;
struct queuebuf *buf;
const struct suc_callbacks *u;
const struct stunicast_callbacks *u;
rimeaddr_t receiver;
};
void suc_open(struct suc_conn *c, uint16_t channel,
const struct suc_callbacks *u);
void suc_close(struct suc_conn *c);
void stunicast_open(struct stunicast_conn *c, uint16_t channel,
const struct stunicast_callbacks *u);
void stunicast_close(struct stunicast_conn *c);
int suc_send_stubborn(struct suc_conn *c, rimeaddr_t *receiver,
int stunicast_send_stubborn(struct stunicast_conn *c, rimeaddr_t *receiver,
clock_time_t rxmittime);
void suc_cancel(struct suc_conn *c);
void stunicast_cancel(struct stunicast_conn *c);
int suc_send(struct suc_conn *c, rimeaddr_t *receiver);
int stunicast_send(struct stunicast_conn *c, rimeaddr_t *receiver);
void suc_set_timer(struct suc_conn *c, clock_time_t t);
void stunicast_set_timer(struct stunicast_conn *c, clock_time_t t);
rimeaddr_t *suc_receiver(struct suc_conn *c);
rimeaddr_t *stunicast_receiver(struct stunicast_conn *c);
#endif /* __SUC_H__ */
#endif /* __STUNICAST_H__ */
/** @} */
/** @} */