Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
re6stnet
Commits
3f8dfa4c
Commit
3f8dfa4c
authored
Aug 24, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update in simulations
parent
9abaa20d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
83 additions
and
50 deletions
+83
-50
TODO
TODO
+0
-3
re6st-registry
re6st-registry
+1
-1
re6stnet
re6stnet
+1
-1
simulation/realistic_dataset/data/refresh1/arity.png
simulation/realistic_dataset/data/refresh1/arity.png
+0
-0
simulation/realistic_dataset/data/refresh1/mkGraph.py
simulation/realistic_dataset/data/refresh1/mkGraph.py
+27
-15
simulation/realistic_dataset/graph.cpp
simulation/realistic_dataset/graph.cpp
+20
-3
simulation/realistic_dataset/latency.cpp
simulation/realistic_dataset/latency.cpp
+3
-1
simulation/realistic_dataset/main.cpp
simulation/realistic_dataset/main.cpp
+26
-23
simulation/realistic_dataset/main.h
simulation/realistic_dataset/main.h
+5
-3
No files found.
TODO
View file @
3f8dfa4c
Bug :
possible bug in the upnp refresh, when refreshing after a too long time
To be done :
Test the package
...
...
re6st-registry
View file @
3f8dfa4c
...
...
@@ -41,7 +41,7 @@ class main(object):
def
__init__
(
self
):
self
.
cert_duration
=
365
*
86400
self
.
time_out
=
864
00
self
.
time_out
=
450
00
self
.
refresh_interval
=
600
self
.
last_refresh
=
time
.
time
()
...
...
re6stnet
View file @
3f8dfa4c
...
...
@@ -42,7 +42,7 @@ def getConfig():
_
(
'--registry'
,
required
=
True
,
help
=
"HTTP URL of the discovery peer server,"
" with public host (default port: 80)"
)
_
(
'--peers-db-refresh'
,
default
=
36
00
,
type
=
int
,
_
(
'--peers-db-refresh'
,
default
=
432
00
,
type
=
int
,
help
=
'the time (seconds) to wait before refreshing the peers db'
)
_
(
'-l'
,
'--log'
,
default
=
'/var/log'
,
help
=
'Path to re6stnet logs directory'
)
...
...
simulation/realistic_dataset/data/refresh1/arity.png
View replaced file @
9abaa20d
View file @
3f8dfa4c
67.8 KB
|
W:
|
H:
47.5 KB
|
W:
|
H:
2-up
Swipe
Onion skin
simulation/realistic_dataset/data/refresh1/mkGraph.py
View file @
3f8dfa4c
import
matplotlib.pyplot
as
plt
max_peers
=
30
nFiles
=
2
nRounds
=
30
00
nFiles
=
4
nRounds
=
9
00
file_names
=
[
'out_%s.csv'
%
i
for
i
in
range
(
nFiles
)]
distance
=
[
0
]
*
nRounds
arityLat
=
[[
0
]
*
(
max_peers
-
9
)
for
i
in
range
(
10
)]
arity
=
[[
0
]
*
31
for
i
in
range
(
nRounds
)]
arity
=
[[
0
]
*
(
max_peers
+
1
)
for
i
in
range
(
nRounds
)]
for
file_name
in
file_names
:
# open the file
...
...
@@ -16,27 +17,38 @@ for file_name in file_names:
for
line
in
lines
:
vals
=
line
.
split
(
','
)
if
len
(
vals
)
<
2
:
continue
i
=
int
(
vals
[
0
])
if
i
>=
nRounds
:
continue
distance
[
i
]
+=
float
(
vals
[
1
])
for
j
in
range
(
0
,
31
):
arity
[
i
][
j
]
+=
float
(
vals
[
j
+
2
])
for
j
in
range
(
10
,
31
):
arity
[
i
][
j
]
+=
float
(
vals
[
j
-
6
])
for
j
in
range
(
0
,
10
):
for
k
in
range
(
0
,
max_peers
-
9
):
arityLat
[
j
][
k
]
+=
int
(
vals
[
48
+
22
*
j
+
k
])
for
i
in
range
(
0
,
nRounds
):
distance
[
i
]
=
distance
[
i
]
/
len
(
file_names
)
for
j
in
range
(
0
,
31
):
arity
[
i
][
j
]
=
arity
[
i
][
j
]
/
len
(
file_names
)
plt
.
plot
(
range
(
31
),
arity
[
1
],
range
(
31
),
arity
[
nRounds
-
1
])
plt
.
legend
((
'Random network'
,
'After %s iterations'
%
nRounds
))
for
i
in
range
(
0
,
10
):
s
=
sum
(
arityLat
[
i
])
for
j
in
range
(
0
,
max_peers
-
9
):
arityLat
[
i
][
j
]
=
float
(
arityLat
[
i
][
j
])
/
float
(
s
)
#plt.plot(range(31), arity[1], range(31), arity[nRounds - 1])
#plt.legend(('Random network', 'After %s iterations' % nRounds))
#plt.xlabel('Arity')
#plt.axis([10, 30, 0, 0.3])
latRange
=
range
(
10
,
31
)
plt
.
plot
(
latRange
,
arityLat
[
0
],
latRange
,
arityLat
[
9
])
plt
.
legend
((
'average latency < 50ms'
,
'average latency > 90ms'
),
loc
=
2
)
plt
.
xlabel
(
'Arity'
)
plt
.
ylabel
(
'Ratio of node'
)
plt
.
axis
([
10
,
30
,
0
,
0.4
])
#plt.xscale('log')
#plt.plot(range(0, nRounds), distance)
#plt.yscale('log')
plt
.
show
()
simulation/realistic_dataset/graph.cpp
View file @
3f8dfa4c
#include "main.h"
Graph
::
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
rng
,
Latency
*
latency
)
:
Graph
::
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
rng
,
Latency
*
latency
,
double
minKillProba
,
double
maxKillProba
)
:
generator
(
mt19937
(
rng
())),
size
(
size
),
k
(
k
),
maxPeers
(
maxPeers
),
latency
(
latency
),
distrib
(
uniform_int_distribution
<
int
>
(
0
,
size
-
1
))
{
adjacency
=
new
unordered_set
<
int
>
[
size
];
generated
=
new
unordered_set
<
int
>
[
size
];
killProba
=
new
double
[
size
];
uniform_real_distribution
<
double
>
kill_distrib
(
minKillProba
,
maxKillProba
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
SaturateNode
(
i
);
killProba
[
i
]
=
kill_distrib
(
generator
);
}
}
Graph
::
Graph
(
Graph
&
g
)
:
...
...
@@ -328,11 +333,11 @@ void Graph::KillMachines(float proportion)
}
}
void
Graph
::
Reboot
(
double
proba
,
int
round
)
void
Graph
::
Reboot
()
{
uniform_real_distribution
<
double
>
d
(
0.0
,
1.0
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
if
(
d
(
generator
)
<=
proba
)
if
(
d
(
generator
)
<=
killProba
[
i
]
)
{
stack
<
int
>
toSaturate
;
...
...
@@ -376,6 +381,18 @@ void Graph::GetArityLat(int arity[][10])
arity
[
adjacency
[
i
].
size
()][
max
(
min
((
int
)(
latency
->
avgLatencyToOthers
[
i
]
-
45000
)
/
5000
,
9
),
0
)]
++
;
}
void
Graph
::
GetArityKill
(
int
arity
[][
10
])
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
for
(
int
a
=
0
;
a
<=
maxPeers
;
a
++
)
arity
[
a
][
i
]
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
arity
[
adjacency
[
i
].
size
()][
max
(
min
((
int
)(
killProba
[
i
]
*
200.0
),
9
),
0
)]
++
;
}
}
double
Graph
::
GetAvgDistanceHop
()
{
double
avgDist
=
0
;
...
...
simulation/realistic_dataset/latency.cpp
View file @
3f8dfa4c
...
...
@@ -27,6 +27,8 @@ Latency::Latency(const char* filePath, int size) : size(size)
values
[
a
-
1
][
b
-
1
]
=
latency
;
}
fclose
(
file
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
avgLatencyToOthers
[
i
]
=
0
;
...
...
@@ -35,7 +37,6 @@ Latency::Latency(const char* filePath, int size) : size(size)
avgLatencyToOthers
[
i
]
/=
size
;
}
fclose
(
file
);
}
void
Latency
::
Rewrite
(
int
n
)
...
...
@@ -76,6 +77,7 @@ Latency::~Latency()
for
(
int
i
=
0
;
i
<
size
;
i
++
)
delete
[]
values
[
i
];
delete
[]
values
;
delete
[]
avgLatencyToOthers
;
}
double
Latency
::
GetAverageDistance
()
...
...
simulation/realistic_dataset/main.cpp
View file @
3f8dfa4c
...
...
@@ -13,44 +13,47 @@ void simulate(int size, int k, int maxPeer, int seed, Latency* latency, const ch
FILE
*
output
=
fopen
(
outName
,
"wt"
);
int
fno
=
fileno
(
output
);
double
nRoutesKilled
=
0
;
int
arityLat
Distrib
[
maxPeer
+
1
][
10
];
//int arityKill
Distrib[maxPeer+1][10];
double
avgDistance
,
unreachable
;
double
arityDistrib
[
31
],
bcArity
[
31
];
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
,
0
,
0.05
);
cout
<<
"
\r
"
<<
0
<<
"/"
<<
3000
;
cout
.
flush
();
for
(
int
i
=
0
;
i
<
3000
;
i
++
)
{
/*
for(float a=0.05; a<1; a+=0.05
)
/*
if(i>=100
)
{
Graph copy(graph);
copy.KillMachines(a);
fprintf(output, "%d,%f,%f\n",i , a , copy.GetUnAvalaibility());
fflush(output);
fsync(fno);
for(float a=0.05; a<1; a+=0.05)
{
Graph copy(graph);
copy.KillMachines(a);
fprintf(output, "%d,%f,%f\n",i , a , copy.GetUnAvalaibility());
fflush(output);
fsync(fno);
}
}*/
//graph.Reboot(
1.0/(100 + 1.0), i
);
//graph.Reboot();
graph
.
UpdateLowRoutes
(
avgDistance
,
unreachable
,
nRoutesKilled
,
arityDistrib
,
bcArity
,
1
,
i
);
graph
.
GetArityLat
(
arityLat
Distrib
);
//graph.GetArityKill(arityKill
Distrib);
fprintf
(
output
,
"%d,%f,%f
,A
"
,
i
,
avgDistance
,
nRoutesKilled
);
fprintf
(
output
,
"%d,%f,%f"
,
i
,
avgDistance
,
nRoutesKilled
);
for
(
int
j
=
k
;
j
<=
30
;
j
++
)
fprintf
(
output
,
",%f"
,
arityDistrib
[
j
]);
fprintf
(
output
,
",B"
);
/*
fprintf(output, ",B");
for(int j=k; j<=30; j++)
fprintf(output, ",%f", bcArity[j]);
for(int j=0; j<10; j++)
{
fprintf
(
output
,
",
L
%d"
,
j
);
fprintf(output, ",
K
%d", j);
for(int a=k; a<=maxPeer; a++)
fprintf
(
output
,
",%d"
,
arity
Lat
Distrib
[
a
][
j
]);
}
fprintf(output, ",%d", arity
Kill
Distrib[a][j]);
}
*/
fprintf
(
output
,
"
\n
"
);
fflush
(
output
);
fsync
(
fno
);
...
...
@@ -74,7 +77,7 @@ void testOptimized(int size, int k, int maxPeer, int seed, Latency* latency, con
FILE
*
input
=
fopen
(
"update_order"
,
"r"
);
mt19937
rng
(
seed
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
,
0
,
0.1
);
double
nRoutesKilled
=
0
;
int
arityDistrib
[
maxPeer
+
1
];
...
...
@@ -98,7 +101,7 @@ void testOptimized(int size, int k, int maxPeer, int seed, Latency* latency, con
fflush
(
output
);
fsync
(
fno
);
graph
.
Reboot
(
1.0
/
(
2500
+
1.0
),
i
);
graph
.
Reboot
();
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
3000
;
cout
.
flush
();
...
...
@@ -118,7 +121,7 @@ void Optimize(int size, int k, int maxPeer, int seed, Latency* latency, const ch
int
fno
=
fileno
(
output
);
mt19937
rng
(
seed
);
Graph
*
graph
=
new
Graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
Graph
*
graph
=
new
Graph
(
size
,
k
,
maxPeer
,
rng
,
latency
,
0
,
0.1
);
int
range
=
maxPeer
-
k
+
1
;
int
updates
[
range
];
...
...
@@ -181,7 +184,7 @@ void Optimize(int size, int k, int maxPeer, int seed, Latency* latency, const ch
fflush
(
output
);
fsync
(
fno
);
graph
->
Reboot
(
1.0
/
(
2500
+
1.0
),
i
);
graph
->
Reboot
();
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
3000
;
cout
.
flush
();
}
...
...
@@ -193,7 +196,7 @@ void Optimize(int size, int k, int maxPeer, int seed, Latency* latency, const ch
string
computeDist
(
int
size
,
int
k
,
int
maxPeer
,
int
seed
,
Latency
*
latency
)
{
mt19937
rng
(
seed
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
,
0
,
0.1
);
double
avgDistLatency
=
0
;
int
nRoutes
[
size
],
prevs
[
size
],
distances
[
size
];
...
...
@@ -215,12 +218,12 @@ int main(int argc, char** argv)
mt19937
rng
(
time
(
NULL
));
Latency
*
latency
=
new
Latency
(
"datasets/latency_2_2500"
,
2500
);
//
cout << "Optimal distance : " << latency->GetAverageDistance() << endl;
//
cout << "Average ping : " << latency->GetAveragePing() << endl;
cout
<<
"Optimal distance : "
<<
latency
->
GetAverageDistance
()
<<
endl
;
cout
<<
"Average ping : "
<<
latency
->
GetAveragePing
()
<<
endl
;
vector
<
future
<
void
>>
threads
;
for
(
int
i
=
0
;
i
<
1
;
i
++
)
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
int
seed
=
rng
();
char
*
out
=
new
char
[
100
];
...
...
simulation/realistic_dataset/main.h
View file @
3f8dfa4c
...
...
@@ -38,18 +38,19 @@ private:
class
Graph
{
public:
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
Latency
*
latency
);
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
Latency
*
latency
,
double
minKillProba
,
double
maxKillProba
);
Graph
(
Graph
&
g
);
~
Graph
()
{
delete
[]
adjacency
;
delete
[]
generated
;};
~
Graph
()
{
delete
[]
adjacency
;
delete
[]
generated
;
delete
[]
killProba
;
};
int
UpdateLowRoutes
(
double
&
avgDistance
,
double
&
unreachable
,
double
&
nRoutesKilled
,
double
*
arityDistrib
,
double
*
bcArity
,
int
nRefresh
,
int
round
);
double
GetUnAvalaibility
();
void
Reboot
(
double
proba
,
int
round
);
void
Reboot
();
void
KillMachines
(
float
proportion
);
pair
<
double
,
double
>
UpdateLowRoutesArity
(
int
arityToUpdate
);
void
GetArity
(
int
*
arity
);
void
GetRoutesFrom
(
int
from
,
int
*
nRoutes
,
int
*
prevs
,
int
*
distances
);
double
GetAvgDistanceHop
();
void
GetArityLat
(
int
arity
[][
10
]);
void
GetArityKill
(
int
arity
[][
10
]);
private:
void
SaturateNode
(
int
node
);
...
...
@@ -67,4 +68,5 @@ private:
unordered_set
<
int
>*
adjacency
;
unordered_set
<
int
>*
generated
;
Latency
*
latency
;
double
*
killProba
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment