Pls provide TCL source code for finding optimal path using GA and PSO.
Posts: 8,059
Threads: 1
Joined: Mar 2014
Procedure General for shortest path:
Initialize the array smallestWeight so that smallestWeight [u] = weight [vertex, u].
Set smallestWeight [vertex] = 0.
Find the top, v, which is the nearest Summit for which the shortest route has not been determined.
Mark v (next) Summit for which the smallest weight is found.
For each vertex w G, so that the shortest path from Summit by weight has not been determined and an edge (v, w) exists, if the weight of the path w via v is smaller than his current weight, updating the weight w to the weight of v + the weight of edge (v, w).
This code contains main function of dijikstra’s routing algorithm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
int main()
{
Node N0(0);
Node N1(1);
Node N2(2);
Node N3(3);
Node N4(4);
RoutingVec_t NextHop;
RoutingVec_t Parent;
N0.AddAdj(1, 10);
N0.AddAdj(2, 5);
N1.AddAdj(3, 1);
N1.AddAdj(2, 2);
N2.AddAdj(4, 2);
N2.AddAdj(1, 3);
N2.AddAdj(3, 9);
N3.AddAdj(4, 4);
N4.AddAdj(0, 7);
N4.AddAdj(3, 6);
Nodes.push_back(&N0);
Nodes.push_back(&N1);
Nodes.push_back(&N2);
Nodes.push_back(&N3);
Nodes.push_back(&N4);
for (nodeid_t i = 0; i < Nodes.size(); i++)
{ // Get shortest path for each root node
printf("\nFrom root %ld\n", i);
Dijkstra(Nodes, i, NextHop, Parent);
PrintParents(Parent);
for (unsigned int k = 0; k < Nodes.size(); k++)
printf("Next hop for node %d is %ld\n", k, NextHop[k]);
printf("Printing paths\n");
for (nodeid_t j = 0; j < Nodes.size(); j++)
{
PrintRoute(i, j, Parent);
}
}
return(0);
Reason for choosing NS2 Simulator
Ns2 tech solution is a global development project and the outsourcing of the Ns2 projects for students and clients. . Ns2 technical solution works primarily in the field of searching NS2. This offers students and researchers to use our developer skills to develop a project effective Ns2. We provide various innovative ideas with an innovative solution for any type of projects NS2 in network communication. solution Ns2 helps students from last year's intelligence B.E, B.Tech, M.E and M.Tech and PhD Scholars. We provide the satisfaction of 100% with your projects and the implementation in an efficient manner.
Posts: 6,843
Threads: 4
Joined: Mar 2015
Proactive routing protocol maintains constant and updated routing information for each pair of networking nodes by propagating route updates proactively at fixed interval of time. The periodic and event-driven messages are responsible for route establishment and route maintenance. The Destination-Sequenced Distance Vector (DSDV) protocol is the commonly used proactive routing protocol in mobile ad hoc network (MANET). In DSDV, each node maintains a routing table with one route entry for each destination in which the shortest path is recorded. It uses a destination sequence number to avoid routing loops. The sample17.tcl shows a node configuration for a wireless mobile node that runs DSDV as its adhoc routing protocol. Prior to the establishment of communication between the source and receiver node, the routing protocol should be mentioned to find the route between them. Data Transmission is established between nodes using UDP agent and CBR traffic. Routing process follows DSDV routing protocol.
#Filename: sample17.tcl
#*******************DSDV ROUTING PROTOCOL****************#
# Simulator Instance Creation
set ns [new Simulator]
#Fixing the co-ordinate of simulation area
set val(x) 500
set val(y) 500
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# page link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 10 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 500 ;# Y dimension of topography
set val(stop) 10.0 ;# time of simulation end
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# general operational descriptor- storing the hop details in the network
create-god $val(nn)
# configure the nodes
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
# Node Creation
for {set i 0} {$i < 3} {incr i} {
set node_($i) [$ns node]
$node_($i) color black
}
#******************************Defining Communication Between node0 and all nodes ****************************8
for {set i 1} {$i < 10} {incr i} {
# Defining a transport agent for sending
set udp [new Agent/UDP]
# Attaching transport agent to sender node
$ns attach-agent $node_($i) $udp
# Defining a transport agent for receiving
set null [new Agent/Null]
# Attaching transport agent to receiver node
$ns attach-agent $node_(0) $null
#Connecting sending and receiving transport agents
$ns connect $udp $null
#Defining Application instance
set cbr [new Application/Traffic/CBR]
# Attaching transport agent to application agent
$cbr attach-agent $udp
#Packet size in bytes and interval in seconds definition
$cbr set packetSize_ 512
$cbr set interval_ 0.1
# data packet generation starting time
$ns at 1.0 "$cbr start"
# data packet generation ending time
#$ns at 6.0 "$cbr stop"
}