SlideShare a Scribd company logo
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

More Related Content

Similar to 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 .pdf
aquazac
 
-- 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
Adamq0DJonese
 
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
abdulrahamanbags
 
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
abbecindia
 
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
MARRY7
 
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
MAYANKBANSAL1981
 
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
4babies2010
 
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
apleathers
 
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
secunderbadtirumalgi
 
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
jyothimuppasani1
 
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
aptcomputerzone
 
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.docx
wkyra78
 
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
Divye 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.pdf
mdameer02
 
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
shanki7
 
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
hartrobert670
 
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdfInterfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
sutharbharat59
 
Geep networking stack-linuxkernel
Geep networking stack-linuxkernelGeep networking stack-linuxkernel
Geep networking stack-linuxkernel
Kiran 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.pdf
Aggarwalelectronic18
 

Similar to 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
 

More from 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 .pdf
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 
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
aioils
 

More from 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
 

Recently uploaded

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 

Recently uploaded (20)

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 

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