Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What is a concept test?

Answered: 1 week ago