SlideShare uma empresa Scribd logo
1 de 7
Baixar para ler offline
Please do Part A, I'll be really grateful
The main.c is the skeleton code, the content of main.c is given below:
#include
#include
/* a rtpkt is the packet sent from one router to
another*/
struct rtpkt {
int sourceid; /* id of sending router sending this pkt */
int destid; /* id of router to which pkt being sent
(must be an directly connected neighbor) */
int *mincost; /* min cost to all the node */
};
struct distance_table
{
int **costs; // the distance table of curr_node, costs[i][j] is the cost from node i to node j
};
/*****************************************************************
***************** NETWORK EMULATION CODE STARTS BELOW ***********
The code below emulates the layer 2 and below network environment:
- emulates the transmission and delivery (with no loss and no
corruption) between two physically connected nodes
- calls the initializations routine rtinit once before
beginning emulation for each node.
You should read and understand the code below. For Part A, you should fill all parts with
annotation starting with "Todo". For Part B and Part C, you need to add additional routines for
their features.
******************************************************************/
struct event {
float evtime; /* event time */
int evtype; /* event type code */
int eventity; /* entity (node) where event occurs */
struct rtpkt *rtpktptr; /* ptr to packet (if any) assoc w/ this event */
struct event *prev;
struct event *next;
};
struct event *evlist = NULL; /* the event list */
struct distance_table *dts;
int **link_costs; /*This is a 2D matrix stroing the content defined in topo file*/
int num_nodes;
/* possible events: */
/*Note in this lab, we only have one event, namely FROM_LAYER2.It refer to that the packet
will pop out from layer3, you can add more event to emulate other activity for other layers. Like
FROM_LAYER3*/
#define FROM_LAYER2 1
float clocktime = 0.000;
/********************* EVENT HANDLINE ROUTINES *******/
/* The next set of routines handle the event list */
/*****************************************************/
void rtinit(struct distance_table *dt, int node, int *link_costs, int num_nodes)
{
/* Todo: Please write the code here*/
}
void rtupdate(struct distance_table *dt, struct rtpkt recv_pkt)
{
/* Todo: Please write the code here*/
}
void main(int argc, char *argv[])
{
struct event *eventptr;
/* Todo: Please write the code here to process the input.
Given different flag, you have different number of input for part A, B, C.
Please write your own code to parse the input for each part.
Specifically, in part A you need parse the input file and get num_nodes,
and fill in the content of dts and link_costs */
dts = (struct distance_table *) malloc(num_nodes * sizeof(struct distance_table));
link_costs = (int **) malloc(num_nodes * sizeof(int *));
for (int i = 0; i < num_nodes; i++)
{
link_costs[i] = (int *)malloc(num_nodes * sizeof(int));
}
for (int i = 0; i < num_nodes; i++)
{
rtinit(&dts[i], i, link_costs[i], num_nodes);
}
while (1)
{
/* Todo: Please write the code here to handle the update of time slot k (We assume that in one
slot k, the traffic can go through all the routers to reach the destination router)*/
eventptr = evlist; /* get next event to simulate */
if (eventptr==NULL)
goto terminate;
evlist = evlist->next; /* remove this event from event list */
if (evlist!=NULL)
evlist->prev=NULL;
clocktime = eventptr->evtime; /* update time to next event time */
if (eventptr->evtype == FROM_LAYER2 )
{
/* Todo: You need to modify the rtupdate method and add more codes here for Part B and Part
C, since the link costs in these parts are dynamic.*/
rtupdate(&dts[eventptr->eventity], *(eventptr->rtpktptr));
}
else
{
printf("Panic: unknown event typen"); exit(0);
}
if (eventptr->evtype == FROM_LAYER2 )
free(eventptr->rtpktptr); /* free memory for packet, if any */
free(eventptr); /* free memory for event struct */
}
terminate:
printf("nSimulator terminated at t=%f, no packets in mediumn", clocktime);
}
/* jimsrand(): return a float in range [0,1]. The routine below is used to */
/* isolate all random number generation in one location. We assume that the*/
/* system-supplied rand() function return an int in therange [0,mmm] */
float jimsrand()
{
double mmm = 2147483647;
float x;
x = rand()/mmm;
return(x);
}
void insertevent(struct event *p)
{
struct event *q,*qold;
q = evlist; /* q points to header of list in which p struct inserted */
if (q==NULL) { /* list is empty */
evlist=p;
p->next=NULL;
p->prev=NULL;
}
else {
for (qold = q; q !=NULL && p->evtime > q->evtime; q=q->next)
qold=q;
if (q==NULL) { /* end of list */
qold->next = p;
p->prev = qold;
p->next = NULL;
}
else if (q==evlist) { /* front of list */
p->next=evlist;
p->prev=NULL;
p->next->prev=p;
evlist = p;
}
else { /* middle of list */
p->next=q;
p->prev=q->prev;
q->prev->next=p;
q->prev=p;
}
}
}
void printevlist()
{
struct event *q;
printf("--------------nEvent List Follows:n");
for(q = evlist; q!=NULL; q=q->next) {
printf("Event time: %f, type: %d entity: %dn",q->evtime,q->evtype,q->eventity);
}
printf("--------------n");
}
/************************** send update to neighbor (packet.destid)***************/
void send2neighbor(struct rtpkt packet)
{
struct event *evptr, *q;
float jimsrand(),lastime;
int i;
/* be nice: check if source and destination id's are reasonable */
if (packet.sourceid<0 || packet.sourceid >num_nodes) {
printf("WARNING: illegal source id in your packet, ignoring packet!n");
return;
}
if (packet.destid<0 || packet.destid > num_nodes) {
printf("WARNING: illegal dest id in your packet, ignoring packet!n");
return;
}
if (packet.sourceid == packet.destid) {
printf("WARNING: source and destination id's the same, ignoring packet!n");
return;
}
/* create future event for arrival of packet at the other side */
evptr = (struct event *)malloc(sizeof(struct event));
evptr->evtype = FROM_LAYER2; /* packet will pop out from layer3 */
evptr->eventity = packet.destid; /* event occurs at other entity */
evptr->rtpktptr = &packet; /* save ptr to my copy of packet */
/* finally, compute the arrival time of packet at the other end.
medium can not reorder, so make sure packet arrives between 1 and 10
time units after the latest arrival time of packets
currently in the medium on their way to the destination */
lastime = clocktime;
for (q=evlist; q!=NULL ; q = q->next)
if ( (q->evtype==FROM_LAYER2 && q->eventity==evptr->eventity) )
lastime = q->evtime;
evptr->evtime = lastime + 2.*jimsrand();
insertevent(evptr);
}
2.1 Part A: Build A Network Simulator that Supports DV (25 points) In this part, you need to
build an Autonomous System (AS) with N routers (nodes) (assuming N10 ) with a static
topology. Please start with your code from main.c provided in lab2.zip, which gives a network
simulator framework. You need to implement DV routing protocol with a given static topology
in the following steps. 1. Input: Your simulator should read a topology file (say, topo.txt) with a
matrix {Di,j},i,j{0..,N1}. N is the number of nodes (routers) and Di,j is the link cost from node i
to node j. If nodes i and j are same, Di,j=0; If nodes i and j are directly connected (adjacent),
Di,j=e, where e0. Otherwise, nodes i and j are not directly connected and you should assign link
costDi,j=1. You can test your code with the topology shown in Figure 1 (Note that your code
should work with any static topology with N10 ). Evidently, its corresponding topology file is
given as follows (where N=4 ): 010521001151032130 create another network topology with any
number of nodes for testing. (Note that the test cases used for the grading are different). Assume
the simulation starts at slot k=0 for initialization and k1 when updating DVs at each simulation
slot. You need to prit slot. You need to print out the current slot k followed by DVs of all the
nodes in the ascending order at the end of the simulation slots. Please print them out in the first
five slots (k=0,1,2,3,4) and then every 10 slots (k=10,20,30,) until they converge. In this test
case, the expected output should be: k=0i Figure 1: an example of topology and corresponding
link costs. node-0: 01052

Mais conteúdo relacionado

Semelhante a Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf

operating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdfoperating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdfaquazac
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfabdulrahamanbags
 
complete the following functions in c++ singleRotation putNo.pdf
complete the following functions in c++ singleRotation putNo.pdfcomplete the following functions in c++ singleRotation putNo.pdf
complete the following functions in c++ singleRotation putNo.pdfabbecindia
 
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docxMARRY7
 
Complete in JavaCardApp.javapublic class CardApp { private.pdf
Complete in JavaCardApp.javapublic class CardApp {   private.pdfComplete in JavaCardApp.javapublic class CardApp {   private.pdf
Complete in JavaCardApp.javapublic class CardApp { private.pdfMAYANKBANSAL1981
 
The following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdfThe following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdf4babies2010
 
import java.util.Scanner;public class Fraction {   instan.pdf
import java.util.Scanner;public class Fraction {    instan.pdfimport java.util.Scanner;public class Fraction {    instan.pdf
import java.util.Scanner;public class Fraction {   instan.pdfapleathers
 
CC++ echo serverThis assignment is designed to introduce network .pdf
CC++ echo serverThis assignment is designed to introduce network .pdfCC++ echo serverThis assignment is designed to introduce network .pdf
CC++ echo serverThis assignment is designed to introduce network .pdfsecunderbadtirumalgi
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfjyothimuppasani1
 
operating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfoperating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfaptcomputerzone
 
Radix 2 code
Radix 2 codeRadix 2 code
Radix 2 codepradipakv
 
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docxprog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docxwkyra78
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelDivye Kapoor
 
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfMerge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfmdameer02
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfshanki7
 
BUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docxBUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docxhartrobert670
 
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdfInterfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdfsutharbharat59
 
Geep networking stack-linuxkernel
Geep networking stack-linuxkernelGeep networking stack-linuxkernel
Geep networking stack-linuxkernelKiran Divekar
 
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfCountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfAggarwalelectronic18
 

Semelhante a Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf (20)

operating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdfoperating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdf
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
 
complete the following functions in c++ singleRotation putNo.pdf
complete the following functions in c++ singleRotation putNo.pdfcomplete the following functions in c++ singleRotation putNo.pdf
complete the following functions in c++ singleRotation putNo.pdf
 
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 
Complete in JavaCardApp.javapublic class CardApp { private.pdf
Complete in JavaCardApp.javapublic class CardApp {   private.pdfComplete in JavaCardApp.javapublic class CardApp {   private.pdf
Complete in JavaCardApp.javapublic class CardApp { private.pdf
 
The following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdfThe following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdf
 
import java.util.Scanner;public class Fraction {   instan.pdf
import java.util.Scanner;public class Fraction {    instan.pdfimport java.util.Scanner;public class Fraction {    instan.pdf
import java.util.Scanner;public class Fraction {   instan.pdf
 
CC++ echo serverThis assignment is designed to introduce network .pdf
CC++ echo serverThis assignment is designed to introduce network .pdfCC++ echo serverThis assignment is designed to introduce network .pdf
CC++ echo serverThis assignment is designed to introduce network .pdf
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdf
 
operating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfoperating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdf
 
Radix 2 code
Radix 2 codeRadix 2 code
Radix 2 code
 
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docxprog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfMerge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdf
 
BUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docxBUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docx
 
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdfInterfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
 
Geep networking stack-linuxkernel
Geep networking stack-linuxkernelGeep networking stack-linuxkernel
Geep networking stack-linuxkernel
 
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfCountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
 

Mais de aioils

Please help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdfPlease help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdfaioils
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfaioils
 
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating  a) A wheel has 37 numbers 0.pdfPlease help me i will give good rating  a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating a) A wheel has 37 numbers 0.pdfaioils
 
Please help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdfPlease help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdfaioils
 
PLEASE HELP IN C++For this test, you will need to create the follo.pdf
PLEASE HELP IN C++For this test, you will need to create the follo.pdfPLEASE HELP IN C++For this test, you will need to create the follo.pdf
PLEASE HELP IN C++For this test, you will need to create the follo.pdfaioils
 
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdfplease help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdfaioils
 
PLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdfPLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdfaioils
 
please explain these topics if possible How companies account for.pdf
please explain these topics if possible  How companies account for.pdfplease explain these topics if possible  How companies account for.pdf
please explain these topics if possible How companies account for.pdfaioils
 
Pls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdfPls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdfaioils
 
please! 1. Match and pair the following basic genetic conce.pdf
please!  1. Match and pair the following basic genetic conce.pdfplease!  1. Match and pair the following basic genetic conce.pdf
please! 1. Match and pair the following basic genetic conce.pdfaioils
 
Please write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdfPlease write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdfaioils
 
Please write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdfPlease write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdfaioils
 
Please Use The Code Provided below. Thanks Study the Python code .pdf
Please Use The Code Provided below. Thanks  Study the Python code .pdfPlease Use The Code Provided below. Thanks  Study the Python code .pdf
Please Use The Code Provided below. Thanks Study the Python code .pdfaioils
 
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks  Visit LL Queue ; add.pdfPlease Use the Code Provided below. Thanks  Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdfaioils
 
Please this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdfPlease this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdfaioils
 
Please solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdfPlease solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdfaioils
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfaioils
 
Please do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdfPlease do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdfaioils
 
Please show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdfPlease show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdfaioils
 
Please show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdfPlease show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdfaioils
 

Mais de aioils (20)

Please help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdfPlease help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdf
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdf
 
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating  a) A wheel has 37 numbers 0.pdfPlease help me i will give good rating  a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
 
Please help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdfPlease help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdf
 
PLEASE HELP IN C++For this test, you will need to create the follo.pdf
PLEASE HELP IN C++For this test, you will need to create the follo.pdfPLEASE HELP IN C++For this test, you will need to create the follo.pdf
PLEASE HELP IN C++For this test, you will need to create the follo.pdf
 
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdfplease help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
 
PLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdfPLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdf
 
please explain these topics if possible How companies account for.pdf
please explain these topics if possible  How companies account for.pdfplease explain these topics if possible  How companies account for.pdf
please explain these topics if possible How companies account for.pdf
 
Pls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdfPls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdf
 
please! 1. Match and pair the following basic genetic conce.pdf
please!  1. Match and pair the following basic genetic conce.pdfplease!  1. Match and pair the following basic genetic conce.pdf
please! 1. Match and pair the following basic genetic conce.pdf
 
Please write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdfPlease write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdf
 
Please write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdfPlease write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdf
 
Please Use The Code Provided below. Thanks Study the Python code .pdf
Please Use The Code Provided below. Thanks  Study the Python code .pdfPlease Use The Code Provided below. Thanks  Study the Python code .pdf
Please Use The Code Provided below. Thanks Study the Python code .pdf
 
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks  Visit LL Queue ; add.pdfPlease Use the Code Provided below. Thanks  Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
 
Please this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdfPlease this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdf
 
Please solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdfPlease solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdf
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
 
Please do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdfPlease do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdf
 
Please show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdfPlease show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdf
 
Please show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdfPlease show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdf
 

Último

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 

Último (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 

Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf

  • 1. Please do Part A, I'll be really grateful The main.c is the skeleton code, the content of main.c is given below: #include #include /* a rtpkt is the packet sent from one router to another*/ struct rtpkt { int sourceid; /* id of sending router sending this pkt */ int destid; /* id of router to which pkt being sent (must be an directly connected neighbor) */ int *mincost; /* min cost to all the node */ }; struct distance_table { int **costs; // the distance table of curr_node, costs[i][j] is the cost from node i to node j }; /***************************************************************** ***************** NETWORK EMULATION CODE STARTS BELOW *********** The code below emulates the layer 2 and below network environment: - emulates the transmission and delivery (with no loss and no corruption) between two physically connected nodes - calls the initializations routine rtinit once before beginning emulation for each node. You should read and understand the code below. For Part A, you should fill all parts with annotation starting with "Todo". For Part B and Part C, you need to add additional routines for their features.
  • 2. ******************************************************************/ struct event { float evtime; /* event time */ int evtype; /* event type code */ int eventity; /* entity (node) where event occurs */ struct rtpkt *rtpktptr; /* ptr to packet (if any) assoc w/ this event */ struct event *prev; struct event *next; }; struct event *evlist = NULL; /* the event list */ struct distance_table *dts; int **link_costs; /*This is a 2D matrix stroing the content defined in topo file*/ int num_nodes; /* possible events: */ /*Note in this lab, we only have one event, namely FROM_LAYER2.It refer to that the packet will pop out from layer3, you can add more event to emulate other activity for other layers. Like FROM_LAYER3*/ #define FROM_LAYER2 1 float clocktime = 0.000; /********************* EVENT HANDLINE ROUTINES *******/ /* The next set of routines handle the event list */ /*****************************************************/ void rtinit(struct distance_table *dt, int node, int *link_costs, int num_nodes) { /* Todo: Please write the code here*/ }
  • 3. void rtupdate(struct distance_table *dt, struct rtpkt recv_pkt) { /* Todo: Please write the code here*/ } void main(int argc, char *argv[]) { struct event *eventptr; /* Todo: Please write the code here to process the input. Given different flag, you have different number of input for part A, B, C. Please write your own code to parse the input for each part. Specifically, in part A you need parse the input file and get num_nodes, and fill in the content of dts and link_costs */ dts = (struct distance_table *) malloc(num_nodes * sizeof(struct distance_table)); link_costs = (int **) malloc(num_nodes * sizeof(int *)); for (int i = 0; i < num_nodes; i++) { link_costs[i] = (int *)malloc(num_nodes * sizeof(int)); } for (int i = 0; i < num_nodes; i++) { rtinit(&dts[i], i, link_costs[i], num_nodes); } while (1) { /* Todo: Please write the code here to handle the update of time slot k (We assume that in one slot k, the traffic can go through all the routers to reach the destination router)*/
  • 4. eventptr = evlist; /* get next event to simulate */ if (eventptr==NULL) goto terminate; evlist = evlist->next; /* remove this event from event list */ if (evlist!=NULL) evlist->prev=NULL; clocktime = eventptr->evtime; /* update time to next event time */ if (eventptr->evtype == FROM_LAYER2 ) { /* Todo: You need to modify the rtupdate method and add more codes here for Part B and Part C, since the link costs in these parts are dynamic.*/ rtupdate(&dts[eventptr->eventity], *(eventptr->rtpktptr)); } else { printf("Panic: unknown event typen"); exit(0); } if (eventptr->evtype == FROM_LAYER2 ) free(eventptr->rtpktptr); /* free memory for packet, if any */ free(eventptr); /* free memory for event struct */ } terminate: printf("nSimulator terminated at t=%f, no packets in mediumn", clocktime); } /* jimsrand(): return a float in range [0,1]. The routine below is used to */ /* isolate all random number generation in one location. We assume that the*/ /* system-supplied rand() function return an int in therange [0,mmm] */ float jimsrand() { double mmm = 2147483647; float x;
  • 5. x = rand()/mmm; return(x); } void insertevent(struct event *p) { struct event *q,*qold; q = evlist; /* q points to header of list in which p struct inserted */ if (q==NULL) { /* list is empty */ evlist=p; p->next=NULL; p->prev=NULL; } else { for (qold = q; q !=NULL && p->evtime > q->evtime; q=q->next) qold=q; if (q==NULL) { /* end of list */ qold->next = p; p->prev = qold; p->next = NULL; } else if (q==evlist) { /* front of list */ p->next=evlist; p->prev=NULL; p->next->prev=p; evlist = p; } else { /* middle of list */ p->next=q; p->prev=q->prev; q->prev->next=p; q->prev=p; }
  • 6. } } void printevlist() { struct event *q; printf("--------------nEvent List Follows:n"); for(q = evlist; q!=NULL; q=q->next) { printf("Event time: %f, type: %d entity: %dn",q->evtime,q->evtype,q->eventity); } printf("--------------n"); } /************************** send update to neighbor (packet.destid)***************/ void send2neighbor(struct rtpkt packet) { struct event *evptr, *q; float jimsrand(),lastime; int i; /* be nice: check if source and destination id's are reasonable */ if (packet.sourceid<0 || packet.sourceid >num_nodes) { printf("WARNING: illegal source id in your packet, ignoring packet!n"); return; } if (packet.destid<0 || packet.destid > num_nodes) { printf("WARNING: illegal dest id in your packet, ignoring packet!n"); return; } if (packet.sourceid == packet.destid) { printf("WARNING: source and destination id's the same, ignoring packet!n"); return; } /* create future event for arrival of packet at the other side */
  • 7. evptr = (struct event *)malloc(sizeof(struct event)); evptr->evtype = FROM_LAYER2; /* packet will pop out from layer3 */ evptr->eventity = packet.destid; /* event occurs at other entity */ evptr->rtpktptr = &packet; /* save ptr to my copy of packet */ /* finally, compute the arrival time of packet at the other end. medium can not reorder, so make sure packet arrives between 1 and 10 time units after the latest arrival time of packets currently in the medium on their way to the destination */ lastime = clocktime; for (q=evlist; q!=NULL ; q = q->next) if ( (q->evtype==FROM_LAYER2 && q->eventity==evptr->eventity) ) lastime = q->evtime; evptr->evtime = lastime + 2.*jimsrand(); insertevent(evptr); } 2.1 Part A: Build A Network Simulator that Supports DV (25 points) In this part, you need to build an Autonomous System (AS) with N routers (nodes) (assuming N10 ) with a static topology. Please start with your code from main.c provided in lab2.zip, which gives a network simulator framework. You need to implement DV routing protocol with a given static topology in the following steps. 1. Input: Your simulator should read a topology file (say, topo.txt) with a matrix {Di,j},i,j{0..,N1}. N is the number of nodes (routers) and Di,j is the link cost from node i to node j. If nodes i and j are same, Di,j=0; If nodes i and j are directly connected (adjacent), Di,j=e, where e0. Otherwise, nodes i and j are not directly connected and you should assign link costDi,j=1. You can test your code with the topology shown in Figure 1 (Note that your code should work with any static topology with N10 ). Evidently, its corresponding topology file is given as follows (where N=4 ): 010521001151032130 create another network topology with any number of nodes for testing. (Note that the test cases used for the grading are different). Assume the simulation starts at slot k=0 for initialization and k1 when updating DVs at each simulation slot. You need to prit slot. You need to print out the current slot k followed by DVs of all the nodes in the ascending order at the end of the simulation slots. Please print them out in the first five slots (k=0,1,2,3,4) and then every 10 slots (k=10,20,30,) until they converge. In this test case, the expected output should be: k=0i Figure 1: an example of topology and corresponding link costs. node-0: 01052