Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Flooding with packets implementation with ttl and sequence numbers need to get packet from 1 node to another node Node.nc #include #include includes/command.h #include includes/packet.h

Flooding with packets implementation with ttl and sequence numbers need to get packet from 1 node to another node

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);

}

}

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

Students also viewed these Databases questions

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago