*/
#include <6lowpan.h>
+#ifdef DBG_TRACK_FLOWS
#include "TestDriver.h"
+#endif
configuration UDPEchoC {
PFLAGS+=-DENABLE_SPI0_DMA
-PFLAGS+=-I$(LOWPAN_ROOT)/support/sdk/c/blip/include/
+PFLAGS+=-I$(TOSROOT)/tos/lib/net/
+PFLAGS+=-I$(LOWPAN_ROOT)/support/sdk/c/blip/lib6lowpan/
PFLAGS+=-I$(LOWPAN_ROOT)/support/sdk/c/blip/libtcp/
PFLAGS+=-I$(LOWPAN_ROOT)/tos/lib/net/blip/
PFLAGS+=-I$(LOWPAN_ROOT)/tos/lib/net/blip/interfaces/
typedef uint8_t ip6_addr_t [16];
typedef uint16_t cmpr_ip6_addr_t;
#ifdef PC
+#include "../config.h"
typedef uint16_t ieee154_saddr_t;
typedef uint16_t hw_pan_t;
enum {
};
#ifndef BLIP_L2_RETRIES
-#define BLIP_L2_RETRIES 10
+#define BLIP_L2_RETRIES 5
+#endif
+
+#ifndef BLIP_L2_DELAY
+#define BLIP_L2_DELAY 15
#endif
#endif
// option message.
TLV_TYPE_INSTALL = 0x0b,
TLV_TYPE_FLOW = 0x0c,
+ TLV_TYPE_MCASTSEQ = 0x0d,
};
struct ip6_route {
};
enum {
- IP_NOHEADERS = 1,
+ IP_NOHEADERS = 1 << 0,
+ IP_MCAST = 1 << 1,
};
struct split_ip_msg {
*/
uint8_t linklocal_prefix [] = {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-uint8_t multicast_prefix [] = {0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
struct in6_addr __my_address = {{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65}}};
}
// otherwise we either have an invalid compression, or else it's a
// multicast address
- ip_memcpy(dest, multicast_prefix, 8);
- ip_memclr(dest + 8, 8);
+ // ip_memcpy(dest, multicast_prefix, 8);
+ ip_memclr(dest, 16);
+ dest[0] = 0xff;
+ dest[1] = 0x02;
switch (*s_addr & LOWPAN_IPHC_SHORT_LONG_MASK) {
case LOWPAN_IPHC_HC1_MCAST:
dest[14] = (*s_addr) & ~LOWPAN_IPHC_SHORT_LONG_MASK;
}
nxt_hdr = hdr->nxt_hdr;
- if (hdr->nxt_hdr == IANA_UDP /* or other compressed values... */) {
+ if (hdr->nxt_hdr == IANA_UDP && /* or other compressed values... */
+ msg->headers != NULL) {
// we will add the HCNH encoding at the end of the header
*encoding |= LOWPAN_IPHC_NH_MASK;
} else {
uint16_t ping_seq, ping_n, ping_rcv, ping_ident;
struct in6_addr ping_dest;
-#ifndef SIM
-#define CHECK_NODE_ID
-#else
-#define CHECK_NODE_ID if (TOS_NODE_ID == BASESTATION_ID) return
+#ifdef PRINTFUART_ENABLED
+#undef dbg
+#define dbg(X, fmt, args ...) printfUART(fmt, ## args)
#endif
command uint16_t ICMP.cksum(struct split_ip_msg *msg, uint8_t nxt_hdr) {
command void ICMP.sendSolicitations() {
uint16_t jitter = (call Random.rand16()) % TRICKLE_JITTER;
- CHECK_NODE_ID;
if (call Solicitation.isRunning()) return;
solicitation_period = TRICKLE_PERIOD;
call Solicitation.startOneShot(jitter);
uint16_t jitter = (call Random.rand16()) % TRICKLE_JITTER;
- CHECK_NODE_ID;
if (call Advertisement.isRunning()) return;
advertisement_period = TRICKLE_PERIOD;
call Advertisement.startOneShot(jitter);
if (ipmsg == NULL) return;
- dbg("ICMPResponder", "Solicitation\n");
- //BLIP_STATS_INCR(stats.sol_tx);
+ BLIP_STATS_INCR(stats.sol_tx);
msg->type = ICMP_TYPE_ROUTER_SOL;
msg->code = 0;
}
- dbg("ICMPResponder", " * beacon cost: 0x%x\n", cost);
+ dbg("ICMPResponder", " * beacon cost: 0x%x\n", beacon->metric);
} else {
dbg("ICMPResponder", " * no beacon cost\n");
}
ip_free(ipmsg);
return;
}
+ BLIP_STATS_INCR(stats.adv_tx);
r->type = ICMP_TYPE_ROUTER_ADV;
r->code = 0;
switch (req->type) {
case ICMP_TYPE_ROUTER_ADV:
- handleRouterAdv(payload, len, meta);
- //BLIP_STATS_INCR(stats.adv_rx);
- break;
+ handleRouterAdv(payload, len, meta);
+ BLIP_STATS_INCR(stats.adv_rx);
+ break;
case ICMP_TYPE_ROUTER_SOL:
// only reply to solicitations if we have established a default route.
if (call IPRouting.hasRoute()) {
call ICMP.sendAdvertisements();
}
+ BLIP_STATS_INCR(stats.sol_rx);
break;
case ICMP_TYPE_ECHO_REPLY:
{
p_stat.rtt = (call LocalTime.get()) - (*sendTime);
signal ICMPPing.pingReply[req->ident](&iph->ip6_src, &p_stat);
ping_rcv++;
+ BLIP_STATS_INCR(stats.echo_rx);
}
break;
case ICMP_TYPE_ECHO_REQUEST:
msg.headers = NULL;
msg.data = payload;
msg.data_len = len;
- call IPAddress.getIPAddr(&msg.hdr.ip6_src);
+ if (iph->ip6_src.s6_addr[0] == 0xfe) {
+ call IPAddress.getLLAddr(&msg.hdr.ip6_src);
+ } else {
+ call IPAddress.getIPAddr(&msg.hdr.ip6_src);
+ }
memcpy(&msg.hdr.ip6_dst, &iph->ip6_src, 16);
req->type = ICMP_TYPE_ECHO_REPLY;
// remember, this can't really fail in a way we care about
call IP.send(&msg);
+ BLIP_STATS_INCR(stats.echo_tx);
break;
}
+ default:
+ BLIP_STATS_INCR(stats.unk_rx);
}
}
event void Solicitation.fired() {
sendSolicitation();
- dbg("ICMPResponder", "solicitation period: 0x%x max: 0x%x\n", solicitation_period, TRICKLE_MAX);
+ dbg("ICMPResponder", "solicitation period: 0x%x max: 0x%x seq: %i\n", solicitation_period, TRICKLE_MAX, nd_seqno);
solicitation_period <<= 1;
if (solicitation_period < TRICKLE_MAX) {
call Solicitation.startOneShot(solicitation_period);
command void Statistics.get(icmp_statistics_t *statistics) {
- statistics = &stats;
+ memcpy(statistics, &stats, sizeof(icmp_statistics_t));
}
command void Statistics.clear() {
} implementation {
#ifdef PRINTFUART_ENABLED
-/* #undef dbg */
-/* #define dbg(X, fmt, args...) printfUART(fmt, ## args) */
+// #undef dbg
+// #define dbg(X, fmt, args...) printfUART(fmt, ## args)
#endif
enum {
event void TrafficGenTimer.fired() {
struct split_ip_msg *msg;
if (traffic_sent) goto done;
- traffic_sent = FALSE;
msg = (struct split_ip_msg *)ip_malloc(sizeof(struct split_ip_msg));
- if (msg == NULL) goto done;
+ if (msg == NULL) {
+ printfUART("malloc fail\n");
+ goto done;
+ }
+ traffic_sent = FALSE;
ip_memclr((uint8_t *)&msg->hdr, sizeof(struct ip6_hdr));
inet_pton6("ff05::1", &msg->hdr.ip6_dst);
// me.
struct in6_addr *my_address = call IPAddress.getPublicAddr();
return (((cmpPfx(my_address->s6_addr, hdr->ip6_dst.s6_addr) ||
- cmpPfx(linklocal_prefix, hdr->ip6_dst.s6_addr))
- && cmpPfx(&my_address->s6_addr[8], &hdr->ip6_dst.s6_addr[8]))
- || cmpPfx(multicast_prefix, hdr->ip6_dst.s6_addr));
+ cmpPfx(linklocal_prefix, hdr->ip6_dst.s6_addr)) &&
+ cmpPfx(&my_address->s6_addr[8], &hdr->ip6_dst.s6_addr[8])) ||
+ (hdr->ip6_dst.s6_addr[0] == 0xff &&
+ (hdr->ip6_dst.s6_addr[1] & 0x0f) <= 3))
+;
}
#ifdef CENTRALIZED_ROUTING
struct flow_entry *r = getFlowEntry_Header(hdr);
#endif
prev_hop = 0;
- ret->retries = N_RETRIES;;
- ret->delay = 30;
+ ret->retries = BLIP_L2_RETRIES;
+ ret->delay = (BLIP_L2_DELAY % (call Random.rand16())) + BLIP_L2_DELAY;
ret->current = 0;
ret->nchoices = 0;
ret->dest[0] = ntohs(sh->hops[ROUTE_NENTRIES(sh) - sh->segs_remain]);
ret->nchoices = 1;
- } else if (hdr->ip6_dst.s6_addr16[0] == htons(0xff02)) {
+ } else if (hdr->ip6_dst.s6_addr[0] == 0xff &&
+ (hdr->ip6_dst.s6_addr[1] & 0xf) <= 0x03) {
//hdr->dst_addr[0] == 0xff && (hdr->dst_addr[1] & 0xf) == 0x2) {
// if it's multicast, for now, we send it to the local broadcast
ret->dest[0] = 0xffff;
tlv->len = sizeof(struct tlv_hdr) + sizeof(struct topology_header);
tlv->type = TLV_TYPE_TOPOLOGY;
+ if (iph->ip6_dst.s6_addr[0] == 0xff &&
+ (iph->ip6_dst.s6_addr[1] & 0xf) <= 3) {
+ return NULL;
+ }
+
printfUART("inserting destination options header\n");
// AT: We theoretically only want to attach this topology header if we're
// only attach the topology information if we are. This still isn't
// perfect since somebody further down the tree may have a route and the
// packet might not get to the controller.
- if (iph->nxt_hdr == IANA_UDP || iph->nxt_hdr == IPV6_NONEXT) {
+ if (iph->nxt_hdr == IANA_UDP ||
+ iph->nxt_hdr == IPV6_NONEXT) {
int i,j = 0;
if (iph->ip6_dst.s6_addr16[0] == htons(0xff02)) return NULL;
if (traffic_sent) return NULL;