- Simulation and Analysis of Opportunistic Routing Protocols. 2.2 Running the Simulation The simulator is written in Java and with our scripts it can run on Unix, Linux, and Mac OS X. Run the simulation for epidemic routing. $./task2.sh -b 1 epidemic Follow how data is routed in the network.
- OSPF Routing Protocol - Part 1. Simulation of ospf routing protocol in java simulation of ospf routing protocol program in java ospf routing protocol lab.
NS2 wireless sensor networks (Leach PROTOCOLS) LEACH protocol, stands for 'Low Energy Adaptive Clustering Hierarchy Protocol' (Low Energy Adaptive Clustering Hierarchy), is a wireless sensor network ROUTING PROTOCOLS. LEACH protocol-based algorithm, called LEACH algorithm.1 In order to reduce the amount of information transmitted to th. Routing Simulator Code In Java, free routing simulator code in java software downloads, Page 3.
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up![Program Program](/uploads/1/2/4/6/124698197/524253936.png)
Find file Copy path
Cannot retrieve contributors at this time
importjava.util.Random; |
/* ****************************************************************** |
Project 4: implementing distributed, asynchronous, distance vector routing. |
THIS IS THE MAIN ROUTINE. The TRACE and LINKCHANGES variables can be |
changed to modify the simulator's output and behavior. |
This code is a Java translation of code provided by Kurose and Ross. |
Output GUIs added by Ch. Schuba 2007. |
**********************************************************************/ |
publicclassRouterSimulator { |
publicstaticfinalintNUM_NODES=4; |
publicstaticfinalintINFINITY=999; |
publicstaticfinalbooleanLINKCHANGES=true; |
publicintTRACE=3; /* for debugging */ |
privateGuiTextArea myGUI =null; |
privateRouterNode[] nodes; |
privateRandom generator; |
privateint[][] connectcosts =newint[NUM_NODES][NUM_NODES]; |
/***************************************************************** |
***************** NETWORK EMULATION CODE STARTS BELOW *********** |
The code below emulates the layer 2 and below network environment: |
- emulates the tranmission and delivery (with no loss and no |
corruption) between two physically connected nodes |
- calls the initializations routines rtinit0, etc., once before |
beginning emulation |
THERE IS NOT REASON THAT ANY STUDENT SHOULD HAVE TO READ OR UNDERSTAND |
THE CODE BELOW. YOU SHOLD NOT TOUCH, OR REFERENCE (in your code) ANY |
OF THE DATA STRUCTURES BELOW. If you're interested in how I designed |
the emulator, you're welcome to look at the code - but again, you |
should not have to, and you defeinitely should not have to modify |
******************************************************************/ |
Event evlist =null; /* the event list */ |
/* possible events: */ |
finalstaticintFROM_LAYER2=2; |
finalstaticintLINK_CHANGE=10; |
double clocktime =0.000; |
publicstaticvoidmain(String[] argv){ |
RouterSimulator sim =newRouterSimulator(); |
sim.runSimulation(); |
} |
RouterSimulator() /* initialize the simulator */ |
{ |
double sum, avg; |
Event evptr; |
long seed =1234; |
String prop; |
myGUI =newGuiTextArea(' Output window for Router Simulator '); |
if((prop=System.getProperty('Trace'))!=null) |
TRACE=Integer.parseInt(prop); |
if((prop=System.getProperty('Seed'))!=null) |
seed =Long.parseLong(prop); |
generator =newRandom(seed); |
clocktime=0.0; /* initialize time to 0.0 */ |
/* set initial costs */ |
// remember that in java everything defaults to 0 |
connectcosts[0][1]=1; |
connectcosts[0][2]=3; |
connectcosts[0][3]=7; |
connectcosts[1][0]=1; |
connectcosts[1][2]=1; |
connectcosts[1][3]=INFINITY; |
connectcosts[2][0]=3; |
connectcosts[2][1]=1; |
connectcosts[2][3]=2; |
connectcosts[3][0]=7; |
connectcosts[3][1]=INFINITY; |
connectcosts[3][2]=2; |
nodes =newRouterNode[NUM_NODES]; |
for(int i=0;i<NUM_NODES;i++) { |
nodes[i] =newRouterNode(i,this,connectcosts[i]); |
} |
/* initialize future link changes */ |
if (LINKCHANGES) { |
evptr =newEvent(); |
evptr.evtime =10000.0; |
evptr.evtype =LINK_CHANGE; |
evptr.eventity =0; |
evptr.rtpktptr =null; |
evptr.dest =3; |
evptr.cost =1; |
insertevent(evptr); |
evptr =newEvent(); |
evptr.evtype =LINK_CHANGE; |
evptr.evtime =20000.0; |
evptr.eventity =0; |
evptr.rtpktptr =null; |
evptr.dest =1; |
evptr.cost =6; |
insertevent(evptr); |
} |
} |
voidrunSimulation(){ |
Event eventptr; |
while (true) { |
eventptr = evlist; /* get next event to simulate */ |
if (eventptrnull) { |
break; |
} |
evlist = evlist.next; /* remove this event from event list */ |
if (evlist!=null) |
evlist.prev=null; |
if (TRACE>1) { |
myGUI.println('MAIN: rcv event, t='+ |
eventptr.evtime+' at '+ |
eventptr.eventity); |
if (eventptr.evtype FROM_LAYER2 ) { |
myGUI.print(' src:'+eventptr.rtpktptr.sourceid); |
myGUI.print(', dest:'+eventptr.rtpktptr.destid); |
myGUI.println(', contents: '+ |
eventptr.rtpktptr.mincost[0]+''+ eventptr.rtpktptr.mincost[1]+ |
''+ |
eventptr.rtpktptr.mincost[2]+''+ |
eventptr.rtpktptr.mincost[3]); |
} |
} |
clocktime = eventptr.evtime; /* update time to next event time */ |
if (eventptr.evtype FROM_LAYER2 ) { |
if(eventptr.eventity >=0&& eventptr.eventity <NUM_NODES) |
nodes[eventptr.eventity].recvUpdate(eventptr.rtpktptr); |
else { myGUI.println('Panic: unknown event entityn'); System.exit(0); } |
} |
elseif (eventptr.evtype LINK_CHANGE ) { |
// change link costs here if implemented |
nodes[eventptr.eventity].updateLinkCost(eventptr.dest, |
eventptr.cost); |
nodes[eventptr.dest].updateLinkCost(eventptr.eventity, |
eventptr.cost); |
} |
else |
{ myGUI.println('Panic: unknown event typen'); System.exit(0); } |
if(TRACE>2) |
for(int i=0;i<NUM_NODES;i++) |
nodes[i].printDistanceTable(); |
} |
myGUI.println('nSimulator terminated at t='+clocktime+ |
', no packets in mediumn'); |
} |
publicdoublegetClocktime() { |
return clocktime; |
} |
/********************* EVENT HANDLINE ROUTINES *******/ |
/* The next set of routines handle the event list */ |
/*****************************************************/ |
voidinsertevent(Eventp){ |
Event q,qold; |
if (TRACE>3) { |
myGUI.println(' INSERTEVENT: time is '+clocktime); |
myGUI.println(' INSERTEVENT: future time will be '+ |
p.evtime); |
} |
q = evlist; /* q points to header of list in which p struct inserted */ |
if (qnull) { /* 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 (qnull) { /* end of list */ |
qold.next = p; |
p.prev = qold; |
p.next =null; |
} |
elseif (qevlist) { /* 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; |
} |
} |
} |
voidprintevlist() |
{ |
Event q; |
myGUI.println('--------------nEvent List Follows:'); |
for(q = evlist; q!=null; q=q.next) { |
myGUI.println('Event time: '+q.evtime+ |
', type: '+q.evtype+ |
' entity: '+q.eventity); |
} |
myGUI.println('--------------'); |
} |
/************************** TOLAYER2 ***************/ |
voidtoLayer2(RouterPacketpacket){ |
RouterPacket mypktptr; |
Event evptr, q; |
double lastime; |
int i; |
/* be nice: check if source and destination id's are reasonable */ |
if (packet.sourceid<0|| packet.sourceid >NUM_NODES-1) { |
myGUI.println('WARNING: illegal source id in your packet, ignoring packet!'); |
return; |
} |
if (packet.destid<0|| packet.destid >NUM_NODES-1) { |
myGUI.println('WARNING: illegal dest id in your packet, ignoring packet!'); |
return; |
} |
if (packet.sourceid packet.destid) { |
myGUI.println('WARNING: source and destination id's the same, ignoring packet!'); |
return; |
} |
if (connectcosts[packet.sourceid][packet.destid] INFINITY) { |
myGUI.println('WARNING: source and destination not connected, ignoring packet!'); |
return; |
} |
/* make a copy of the packet student just gave me since may */ |
/* be modified after we return back */ |
mypktptr = (RouterPacket)packet.clone(); |
if (TRACE>2) { |
myGUI.print(' TOLAYER2: source: '+mypktptr.sourceid+ |
' dest: '+ mypktptr.destid+ |
' costs:'); |
for (i=0; i<NUM_NODES; i++) |
myGUI.print(mypktptr.mincost[i]+''); |
myGUI.println(); |
} |
/* create future event for arrival of packet at the other side */ |
evptr =newEvent(); |
evptr.evtype =FROM_LAYER2; /* packet will pop out from layer3 */ |
evptr.eventity = packet.destid; /* event occurs at other entity */ |
evptr.rtpktptr = mypktptr; /* 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.evtypeFROM_LAYER2&& q.eventityevptr.eventity) ) |
lastime = q.evtime; |
evptr.evtime = lastime +9*generator.nextDouble() +1; |
if (TRACE>2) |
myGUI.println(' TOLAYER2: scheduling arrival on other side'); |
insertevent(evptr); |
} |
} |
classEvent { |
double evtime; /* event time */ |
int evtype; /* event type code */ |
int eventity; /* entity where event occurs */ |
RouterPacket rtpktptr; /* ptr to packet (if any) assoc w/ this event */ |
int dest, cost; /* for link cost change */ |
Event prev; |
Event next; |
} |
Copy lines Copy permalink
Routing Protocols Pdf
![Program For Simulation Of Routing Protocols In Java Program For Simulation Of Routing Protocols In Java](/uploads/1/2/4/6/124698197/363689251.jpg)
Routing simulator project Description
Routing simulator project explains about implementing a routing analyzer system for testing performance of network and finding out path failures and which path is followed when crash Accor in a network. In real time scenario it is not possible to test algorithms and implement best one. Using these routing simulators we can increase performance of routers and links. This system will be useful for networking engineers to efficiently analyze performance and design networks.Input for these simulators is given form different statistics of the routers and links.
Download bedienungsanleitung telefon tel 2001 porsche. download without registration number. Detailed explanation about this project is provided in project report and reference documents.
download Routing simulator project source code in java and project report with ppt.