Question: Flooding and Neighbor Discovery Node.nc______________________________________ #include #include includes/command.h #include includes/packet.h #include includes/CommandMsg.h #include includes/sendInfo.h #include includes/channels.h module Node{ uses interface Boot; uses interface SplitControl as
Flooding and Neighbor Discovery




Node.nc______________________________________
#include
#include "includes/command.h"
#include "includes/packet.h"
#include "includes/CommandMsg.h"
#include "includes/sendInfo.h"
#include "includes/channels.h"
module Node{
uses interface Boot;
uses interface SplitControl as AMControl;
uses interface Receive;
uses interface SimpleSend as Sender;
uses interface CommandHandler;
}
implementation{
pack sendPackage;
// Prototypes
void makePack(pack *Package, uint16_t src, uint16_t dest, uint16_t TTL, uint16_t Protocol, uint16_t seq, uint8_t *payload, uint8_t length);
event void Boot.booted(){
call AMControl.start();
dbg(GENERAL_CHANNEL, "Booted ");
}
event void AMControl.startDone(error_t err){
if(err == SUCCESS){
dbg(GENERAL_CHANNEL, "Radio On ");
}else{
//Retry until successful
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err){}
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len){
dbg(GENERAL_CHANNEL, "Packet Received ");
if(len==sizeof(pack)){
pack* myMsg=(pack*) payload;
dbg(GENERAL_CHANNEL, "Package Payload: %s ", myMsg->payload);
return msg;
}
dbg(GENERAL_CHANNEL, "Unknown Packet Type %d ", len);
return msg;
}
event void CommandHandler.ping(uint16_t destination, uint8_t *payload){
dbg(GENERAL_CHANNEL, "PING EVENT ");
makePack(&sendPackage, TOS_NODE_ID, destination, 0, 0, 0, payload, PACKET_MAX_PAYLOAD_SIZE);
call Sender.send(sendPackage, destination);
}
event void CommandHandler.printNeighbors(){}
event void CommandHandler.printRouteTable(){}
event void CommandHandler.printLinkState(){}
event void CommandHandler.printDistanceVector(){}
event void CommandHandler.setTestServer(){}
event void CommandHandler.setTestClient(){}
event void CommandHandler.setAppServer(){}
event void CommandHandler.setAppClient(){}
void makePack(pack *Package, uint16_t src, uint16_t dest, uint16_t TTL, uint16_t protocol, uint16_t seq, uint8_t* payload, uint8_t length){
Package->src = src;
Package->dest = dest;
Package->TTL = TTL;
Package->seq = seq;
Package->protocol = protocol;
memcpy(Package->payload, payload, length);
}
}
NodeC.nc____________________________________________
#include
#include "includes/CommandMsg.h"
#include "includes/packet.h"
configuration NodeC{
}
implementation {
components MainC;
components Node;
components new AMReceiverC(AM_PACK) as GeneralReceive;
Node -> MainC.Boot;
Node.Receive -> GeneralReceive;
components ActiveMessageC;
Node.AMControl -> ActiveMessageC;
components new SimpleSendC(AM_PACK);
Node.Sender -> SimpleSendC;
components CommandHandlerC;
Node.CommandHandler -> CommandHandlerC;
}
Project 1: Flooding and Neighbor Discovery ntroductio In this assignment, you are to develop an application in TinyOS to send message between nodes through flooding. Also you will implement neighbor discovery. Obiec tives and Goals There are two main objectives to this project: Flooding Each node floods a packet to all it neighbor nodes. These packets continue to flood until it reaches it's final destination. Must work as pings and ping replies. Onlv use information accessible from the packet and it's headers Neighbor Discovery Each node should be able to discover all of it's neighbors. Accomplish this without using a new packet type than what is provided. Account for neighbors that drop out of the network. Project 1: Flooding and Neighbor Discovery ntroductio In this assignment, you are to develop an application in TinyOS to send message between nodes through flooding. Also you will implement neighbor discovery. Obiec tives and Goals There are two main objectives to this project: Flooding Each node floods a packet to all it neighbor nodes. These packets continue to flood until it reaches it's final destination. Must work as pings and ping replies. Onlv use information accessible from the packet and it's headers Neighbor Discovery Each node should be able to discover all of it's neighbors. Accomplish this without using a new packet type than what is provided. Account for neighbors that drop out of the network
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
