LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-13-2016, 08:45 AM   #16
haitam09
Member
 
Registered: Jan 2015
Posts: 30

Rep: Reputation: Disabled

Hello Sir knudfl,

First, I apologize for disturbing you.

When the protocol LEACH is remplaced by DSDV, the script "kmeansleach.tcl" works well and gives me the same result like you

set val(rp) DSDV ;# routing protocol

But when I replace DSDV by LEACH, it gives me the above error.

I want to apply this code "kmeansleach.tcl" on LEACH protocol in WSN but i don't know what i do !!!!

Please help me if you have an idea.
Thanks
Best regards.
 
Old 01-13-2016, 10:30 AM   #17
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
#16.

There is no such thing as a protocol by name LEACH.
Leach is a nickname for the things happening when you run ./test or ./leach_test.

{ test , leach_test } are text files. Please read the files.



Please also read the file LEACH_mannasim.tcl ...
https://drive.google.com/file/d/0B7S...ew?usp=sharing
... Mannasim examples can be run with e.g. the executable 'ns235-mannasim'.


-
 
Old 01-15-2016, 04:12 AM   #18
haitam09
Member
 
Registered: Jan 2015
Posts: 30

Rep: Reputation: Disabled
Hello Sir kundfl,
I tried to insert the code "kmeansleach.tcl" for clustering in /tcl/ex/wireless.tcl and i run the script the following ./leach_test it gives me the error in "leach.err":
------------------------------------------------------------
mac/chanel.cc: INITIALIZE THE LIST xListHead
can't read "val(x)": no such variable
while executing
"expr {int(rand()*$val(x))}"
("for" body line 2)
invoked from within
"for {set i 0} {$i < $NETWORK_NODE } { incr i } {
set xx [expr {int(rand()*$val(x))}]
set yy [expr {int(rand()*$val(y))}]

$node($i) set..."
(file "tcl/ex/wireless.tcl" line 316)

Mr Script ./leach_test is :
=========================================================================
#!/bin/bash
# This file runs a generic LEACH protocol simulation.
#This is the algorithm that we are going to run.
alg=leach
#dirname, filename =
# The directory and filename that we want our output to be written.
dirname="mit/leach_sims"
filename=$alg
#Topology
# This file is the scenario that we are going to run.
# This file can be editted manually if you are very careful to create
# a predefined topology. To generate a random topology go to the
# ./mit/uAMPS/sims directory and run 'ns genscen'.
topology_file="mit/uAMPS/sims/100nodes.txt"
#number of clusters we want. It is recommended to use 5% of the total
# number of nodes in the scenario.
num_clusters=5
# energy values. How much energy does each node have initially
eq_energy=1
init_energy=2
# stop is the time to stop the simulation if it is still running
stop=1000
# x,y is the size of the field
x=1000
y=1000
# bs_x, bs_y is the location of the base station in the field.
bs_x=70
bs_y=200
# Number of nodes. WARNING! This should be 1 higher then the number
# of nodes generated in the scenario.
nn=101
ns tcl/ex/wireless.tcl \
-sc mit/uAMPS/sims/nodescen \
-rp $alg \
-x $x \
-y $y \
-nn $nn \
-stop $stop \
-eq_energy $eq_energy \
-init_energy $init_energy \
-filename $filename \
-dirname $dirname \
-topo $topology_file \
-num_clusters $num_clusters \
-bs_x $bs_x \
-bs_y $bs_y 2>$dirname/$filename.err 1>$dirname/$filename.out &
=========================================================================
Have you idea how to update any protocol in NS2 for taken into account k means algorithm ?
Thanks in advances.
Best regards.
 
Old 02-10-2016, 04:45 AM   #19
haitam09
Member
 
Registered: Jan 2015
Posts: 30

Rep: Reputation: Disabled
Hello Sir knudfl,

Please can you help me how to extract from kmeans.tr the new centroids and their associated objects.

Number of clusters : 3
Number of nodes : 30

My kmeans.tr is like:
s 0.003091411 _0_ RTR --- 0 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
s 0.037458776 _2_ RTR --- 1 message 32 [0 0 0 0] ------- [2:255 -1:255 32 0]
s 0.087462768 _13_ RTR --- 2 message 32 [0 0 0 0] ------- [13:255 -1:255 32 0]
s 0.177365656 _3_ RTR --- 3 message 32 [0 0 0 0] ------- [3:255 -1:255 32 0]
s 0.191634337 _19_ RTR --- 4 message 32 [0 0 0 0] ------- [19:255 -1:255 32 0]
s 0.234603229 _15_ RTR --- 5 message 32 [0 0 0 0] ------- [15:255 -1:255 32 0]
s 0.333839210 _12_ RTR --- 6 message 32 [0 0 0 0] ------- [12:255 -1:255 32 0]
s 0.351472650 _18_ RTR --- 7 message 32 [0 0 0 0] ------- [18:255 -1:255 32 0]
s 0.436386259 _29_ RTR --- 8 message 32 [0 0 0 0] ------- [29:255 -1:255 32 0]
s 0.470117073 _8_ RTR --- 9 message 32 [0 0 0 0] ------- [8:255 -1:255 32 0]
s 0.521504883 _22_ RTR --- 10 message 32 [0 0 0 0] ------- [22:255 -1:255 32 0]
s 0.626302117 _10_ RTR --- 11 message 32 [0 0 0 0] ------- [10:255 -1:255 32 0]
s 0.633203961 _6_ RTR --- 12 message 32 [0 0 0 0] ------- [6:255 -1:255 32 0]
s 0.703066137 _21_ RTR --- 13 message 32 [0 0 0 0] ------- [21:255 -1:255 32 0]
s 0.818871236 _23_ RTR --- 14 message 32 [0 0 0 0] ------- [23:255 -1:255 32 0]
s 0.847315218 _17_ RTR --- 15 message 32 [0 0 0 0] ------- [17:255 -1:255 32 0]
s 0.891466156 _4_ RTR --- 16 message 32 [0 0 0 0] ------- [4:255 -1:255 32 0]
s 0.932265375 _25_ RTR --- 17 message 32 [0 0 0 0] ------- [25:255 -1:255 32 0]
s 1.045355908 _24_ RTR --- 18 message 32 [0 0 0 0] ------- [24:255 -1:255 32 0]
s 1.117914998 _1_ RTR --- 19 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
s 1.279806438 _9_ RTR --- 20 message 32 [0 0 0 0] ------- [9:255 -1:255 32 0]
s 1.284507540 _14_ RTR --- 21 message 32 [0 0 0 0] ------- [14:255 -1:255 32 0]
s 1.388917713 _26_ RTR --- 22 message 32 [0 0 0 0] ------- [26:255 -1:255 32 0]
s 1.603158648 _5_ RTR --- 23 message 32 [0 0 0 0] ------- [5:255 -1:255 32 0]
s 1.615642244 _20_ RTR --- 24 message 32 [0 0 0 0] ------- [20:255 -1:255 32 0]
s 1.641665551 _7_ RTR --- 25 message 32 [0 0 0 0] ------- [7:255 -1:255 32 0]
s 1.674915381 _11_ RTR --- 26 message 32 [0 0 0 0] ------- [11:255 -1:255 32 0]
s 1.687590785 _28_ RTR --- 27 message 32 [0 0 0 0] ------- [28:255 -1:255 32 0]
s 1.723873826 _16_ RTR --- 28 message 32 [0 0 0 0] ------- [16:255 -1:255 32 0]
s 1.733148943 _27_ RTR --- 29 message 32 [0 0 0 0] ------- [27:255 -1:255 32 0]

Best regards.


Quote:
Originally Posted by knudfl View Post
#16.

There is no such thing as a protocol by name LEACH.
Leach is a nickname for the things happening when you run ./test or ./leach_test.

{ test , leach_test } are text files. Please read the files.



Please also read the file LEACH_mannasim.tcl ...
https://drive.google.com/file/d/0B7S...ew?usp=sharing
... Mannasim examples can be run with e.g. the executable 'ns235-mannasim'.


-
 
Old 02-17-2016, 09:38 AM   #20
haitam09
Member
 
Registered: Jan 2015
Posts: 30

Rep: Reputation: Disabled
kmeans clustering implementation in C++ or TCL

Hi friends,
I want to extract from the file attached (new100nodes.txt) by using kmeans clustering on C++ or TCL the news centroids and their associated nodes.
i have :
Number of cluster is : 5
Number of nodes is : 100
My mail is haitam09@hotmail.fr.
Thank very very much for your help.
Best regards.
Attached Files
File Type: txt new100nodes.txt (3.7 KB, 32 views)
 
Old 03-04-2016, 04:53 AM   #21
haitam09
Member
 
Registered: Jan 2015
Posts: 30

Rep: Reputation: Disabled
leach.tr for kmeans clustering

Hi friends,

Please find below an excerpt from my file creates leach.tr underlying kmeans clustering.
What do you think of this result? correct or not?
I count on your help.
thank you so much

M 0.0 nn 51 x 100 y 100 rp leach
M 0.0 sc mit/uAMPS/sims/nodescen.tcl cp none seed 0.0
M 0.0 prop Propagation/TwoRayGround ant Antenna/OmniAntenna
s 0.000022565 _24_ AGT --- 0 rca 2 [0 18000000 0 0] ------- [A 24 -1 -1]
s 0.000121235 _40_ AGT --- 1 rca 2 [0 28000000 0 0] ------- [A 40 -1 -1]
s 0.000134743 _37_ AGT --- 2 rca 2 [0 25000000 0 0] ------- [A 37 -1 -1]
r 0.000248575 _40_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248576 _33_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248586 _0_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248607 _17_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248622 _30_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248622 _21_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248631 _9_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248639 _49_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248640 _50_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248653 _45_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248659 _1_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248678 _10_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248684 _25_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248691 _32_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248696 _16_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248699 _26_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248702 _27_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248704 _35_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]
r 0.000248706 _34_ AGT --- 0 rca 2 [0 18000000 ffff0008 0] ------- [A 24 -1 -1]

....

r 0.070881114 _32_ AGT --- 12 rca 10 [0 d000000 ffff0008 0] ------- [R 13 37 -1]
r 0.070881131 _23_ AGT --- 12 rca 10 [0 d000000 ffff0008 0] ------- [R 13 37 -1]
r 0.070881134 _37_ AGT --- 12 rca 10 [0 d000000 ffff0008 0] ------- [R 13 37 -1]
s 0.073368313 _36_ AGT --- 13 rca 10 [0 24000000 0 0] ------- [R 36 40 -1]
r 0.073658464 _40_ AGT --- 13 rca 10 [0 24000000 ffff0008 0] ------- [R 36 40 -1]
r 0.073658465 _17_ AGT --- 13 rca 10 [0 24000000 ffff0008 0] ------- [R 36 40 -1]
M 0.10000 0 (46.00, 96.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 1 (66.00, 84.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 2 (91.00, 95.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 3 (3.00, 54.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 4 (37.00, 0.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 5 (97.00, 81.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 6 (12.00, 60.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 7 (23.00, 53.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 8 (99.00, 78.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 9 (21.00, 90.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 10 (68.00, 76.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 11 (65.00, 2.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 12 (65.00, 29.00, 0.00), (0.00, 0.00), 0.00
M 0.10000 13 (76.00, 29.00, 0.00), (0.00, 0.00), 0.00

....

s 354.153950463 _13_ AGT --- 29428 rca 2510 [0 d000000 0 0] ------- [s 13 50 -1]
s 354.156910049 _38_ AGT --- 29429 rca 2510 [0 26000000 0 0] ------- [s 38 50 -1]
s 354.158466563 _48_ AGT --- 29430 rca 2510 [0 30000000 0 0] ------- [s 48 50 -1]
r 354.174240568 _43_ AGT --- 29428 rca 2510 [0 d000000 ffff0008 0] ------- [r 13 50 -1]
r 354.174240594 _20_ AGT --- 29428 rca 2510 [0 d000000 ffff0008 0] ------- [r 13 50 -1]
r 354.174240639 _50_ AGT --- 29428 rca 2510 [0 d000000 ffff0008 0] ------- [r 13 50 -1]
r 354.197440141 _43_ AGT --- 29429 rca 2510 [0 26000000 ffff0008 0] ------- [r 38 50 -1]
r 354.197440173 _20_ AGT --- 29429 rca 2510 [0 26000000 ffff0008 0] ------- [r 38 50 -1]
r 354.197440238 _50_ AGT --- 29429 rca 2510 [0 26000000 ffff0008 0] ------- [r 38 50 -1]
M 354.20000 0 (46.00, 96.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 1 (66.00, 84.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 2 (91.00, 95.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 3 (3.00, 54.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 4 (37.00, 0.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 5 (97.00, 81.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 6 (12.00, 60.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 7 (23.00, 53.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 8 (99.00, 78.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 9 (21.00, 90.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 10 (68.00, 76.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 11 (65.00, 2.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 12 (65.00, 29.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 13 (76.00, 29.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 14 (43.00, 43.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 15 (98.00, 93.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 16 (44.00, 56.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 17 (44.00, 83.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 18 (54.00, 49.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 19 (55.00, 11.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 20 (38.00, 19.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 21 (23.00, 97.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 22 (11.00, 32.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 23 (6.00, 21.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 24 (40.00, 95.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 25 (29.00, 61.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 26 (0.00, 91.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 27 (77.00, 77.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 28 (83.00, 80.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 29 (3.00, 40.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 30 (41.00, 78.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 31 (16.00, 44.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 32 (20.00, 63.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 33 (41.00, 92.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 34 (82.00, 90.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 35 (4.00, 74.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 36 (87.00, 98.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 37 (7.00, 48.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 38 (75.00, 24.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 39 (55.00, 5.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 40 (42.00, 93.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 41 (30.00, 6.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 42 (83.00, 14.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 43 (92.00, 2.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 44 (91.00, 81.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 45 (63.00, 82.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 46 (69.00, 3.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 47 (40.00, 51.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 48 (4.00, 47.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 49 (18.00, 96.00, 0.00), (0.00, 0.00), 0.00
M 354.20000 50 (50.00, 75.00, 0.00), (0.00, 0.00), 0.00
 
  


Reply

Tags
k-means, ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
K-means Algorithom code in ns2 Rizwanamalek Linux - Wireless Networking 2 02-14-2015 09:54 AM
NS2: Require eap-sim authentication code for simulation in ns2.24 noamankhatib Linux - Software 0 04-29-2013 12:03 PM
Code of GPSR for ns2.33 or ns2.35 monikagoyal Linux - Software 31 04-26-2013 12:13 PM
[SOLVED] what does this line of code means mia_tech Programming 4 07-12-2012 08:24 PM
weight throwing protocol using ns2 code,diffusion based protocol using ns2 code rajrupa Linux - Networking 1 05-27-2010 03:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration