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
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Yohann D'Anello
re6stnet
Commits
01f450fd
Commit
01f450fd
authored
Aug 02, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simulation update
parent
4f9f9c37
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
35 deletions
+97
-35
re6stnet
re6stnet
+1
-1
simulation/realistic_dataset/graph.cpp
simulation/realistic_dataset/graph.cpp
+45
-15
simulation/realistic_dataset/latency.cpp
simulation/realistic_dataset/latency.cpp
+27
-4
simulation/realistic_dataset/main.cpp
simulation/realistic_dataset/main.cpp
+21
-13
simulation/realistic_dataset/main.h
simulation/realistic_dataset/main.h
+3
-2
No files found.
re6stnet
View file @
01f450fd
...
@@ -81,7 +81,7 @@ def getConfig():
...
@@ -81,7 +81,7 @@ def getConfig():
# Openvpn options
# Openvpn options
_
(
'openvpn_args'
,
nargs
=
argparse
.
REMAINDER
,
_
(
'openvpn_args'
,
nargs
=
argparse
.
REMAINDER
,
help
=
"Common OpenVPN options
(e.g. certificates)
"
)
help
=
"Common OpenVPN options"
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
...
...
simulation/realistic_dataset/graph.cpp
View file @
01f450fd
...
@@ -40,7 +40,7 @@ bool Graph::AddEdge(int from)
...
@@ -40,7 +40,7 @@ bool Graph::AddEdge(int from)
if
(
to
!=
from
if
(
to
!=
from
&&
latency
.
values
[
from
][
to
]
>
0
&&
latency
.
values
[
from
][
to
]
>
0
&&
adjacency
[
from
].
count
(
to
)
==
0
&&
adjacency
[
from
].
count
(
to
)
==
0
&&
adjacency
[
to
].
size
()
+
generated
[
to
].
size
()
<=
maxPeers
+
k
)
&&
adjacency
[
to
].
size
()
+
k
<
maxPeers
+
generated
[
to
].
size
()
)
{
{
generated
[
from
].
insert
(
to
);
generated
[
from
].
insert
(
to
);
adjacency
[
from
].
insert
(
to
);
adjacency
[
from
].
insert
(
to
);
...
@@ -112,22 +112,45 @@ void Graph::GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances)
...
@@ -112,22 +112,45 @@ void Graph::GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances)
}
}
void
Graph
::
UpdateLowRoutes
(
double
&
avgDistance
,
double
unreachable
,
double
*
arityDistrib
,
int
refreshCount
)
int
Graph
::
UpdateLowRoutes
(
double
&
avgDistance
,
double
unreachable
,
double
*
arityDistrib
,
double
*
bcArity
,
int
nRefresh
,
int
round
)
{
{
int
nUpdated
=
0
;
routesResult
results
[
size
];
routesResult
results
[
size
];
double
bc
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
bc
[
i
]
=
0
;
avgDistance
=
0
;
double
avgDistanceWeight
=
0
;
unreachable
=
0
;
for
(
int
i
=
0
;
i
<=
maxPeers
;
i
++
)
{
bcArity
[
i
]
=
0
;
arityDistrib
[
i
]
=
0
;
}
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
{
// Compute the routes
// Compute the routes
int
nRoutes
[
size
],
prevs
[
size
],
distances
[
size
];
int
nRoutes
[
size
],
prevs
[
size
],
distances
[
size
];
GetRoutesFrom
(
i
,
nRoutes
,
prevs
,
distances
);
GetRoutesFrom
(
i
,
nRoutes
,
prevs
,
distances
);
for
(
int
j
=
0
;
j
<
size
;
j
++
)
bc
[
j
]
+=
nRoutes
[
j
];
// Get the values
// Get the values
routesResult
r
;
routesResult
r
;
r
.
toDelete
=
-
1
;
for
(
int
k
=
0
;
k
<
nRefresh
;
k
++
)
{
int
mini
=
-
1
;
for
(
int
j
:
generated
[
i
])
for
(
int
j
:
generated
[
i
])
if
(
r
.
toDelete
==
-
1
||
nRoutes
[
r
.
toDelete
]
>
nRoutes
[
j
])
if
(
mini
==
-
1
||
nRoutes
[
mini
]
>
nRoutes
[
j
])
r
.
toDelete
=
j
;
mini
=
j
;
if
(
mini
!=
-
1
)
r
.
toDelete
.
push
(
mini
);
}
r
.
arity
=
adjacency
[
i
].
size
();
r
.
arity
=
adjacency
[
i
].
size
();
...
@@ -146,17 +169,18 @@ void Graph::UpdateLowRoutes(double& avgDistance, double unreachable, double* ari
...
@@ -146,17 +169,18 @@ void Graph::UpdateLowRoutes(double& avgDistance, double unreachable, double* ari
results
[
i
]
=
r
;
results
[
i
]
=
r
;
}
}
avgDistance
=
0
;
double
avgDistanceWeight
=
0
;
unreachable
=
0
;
for
(
int
i
=
0
;
i
<=
maxPeers
;
i
++
)
arityDistrib
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
{
routesResult
r
=
results
[
i
];
routesResult
r
=
results
[
i
];
if
(
r
.
toDelete
>=
0
)
if
((
adjacency
[
i
].
size
()
>
16
&&
adjacency
[
i
].
size
()
<
26
)
||
round
%
4
==
0
)
RemoveEdge
(
i
,
r
.
toDelete
);
{
nUpdated
++
;
while
(
!
r
.
toDelete
.
empty
())
{
RemoveEdge
(
i
,
r
.
toDelete
.
top
());
r
.
toDelete
.
pop
();
}
}
SaturateNode
(
i
);
SaturateNode
(
i
);
...
@@ -164,12 +188,18 @@ void Graph::UpdateLowRoutes(double& avgDistance, double unreachable, double* ari
...
@@ -164,12 +188,18 @@ void Graph::UpdateLowRoutes(double& avgDistance, double unreachable, double* ari
avgDistanceWeight
+=
size
-
r
.
unreachable
;
avgDistanceWeight
+=
size
-
r
.
unreachable
;
unreachable
+=
r
.
unreachable
;
unreachable
+=
r
.
unreachable
;
arityDistrib
[
adjacency
[
i
].
size
()]
++
;
arityDistrib
[
adjacency
[
i
].
size
()]
++
;
bcArity
[
adjacency
[
i
].
size
()]
+=
bc
[
i
]
-
2
*
size
+
1
;
}
}
avgDistance
/=
avgDistanceWeight
;
avgDistance
/=
avgDistanceWeight
;
for
(
int
i
=
0
;
i
<=
maxPeers
;
i
++
)
for
(
int
i
=
0
;
i
<=
maxPeers
;
i
++
)
{
bcArity
[
i
]
=
arityDistrib
[
i
]
>
0
?
bcArity
[
i
]
/
arityDistrib
[
i
]
:
0
;
arityDistrib
[
i
]
/=
size
;
arityDistrib
[
i
]
/=
size
;
}
return
nUpdated
;
}
}
int
Graph
::
CountUnreachableFrom
(
int
node
)
int
Graph
::
CountUnreachableFrom
(
int
node
)
...
...
simulation/realistic_dataset/latency.cpp
View file @
01f450fd
...
@@ -4,18 +4,26 @@ Latency::Latency(const char* filePath, int size) : size(size)
...
@@ -4,18 +4,26 @@ Latency::Latency(const char* filePath, int size) : size(size)
{
{
values
=
new
int
*
[
size
];
values
=
new
int
*
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
values
[
i
]
=
new
int
[
size
];
values
[
i
]
=
new
int
[
size
];
for
(
int
j
=
0
;
j
<
size
;
j
++
)
values
[
i
][
j
]
=
-
1
;
}
FILE
*
file
=
NULL
;
FILE
*
file
=
NULL
;
file
=
fopen
(
filePath
,
"r"
);
file
=
fopen
(
filePath
,
"r"
);
int
a
,
b
,
latency
;
int
a
,
b
;
double
latency
;
while
(
!
feof
(
file
))
while
(
!
feof
(
file
))
{
{
fscanf
(
file
,
"%d %d %d"
,
&
a
,
&
b
,
&
latency
);
fscanf
(
file
,
"%d %d %lf"
,
&
a
,
&
b
,
&
latency
);
values
[
b
][
a
]
=
latency
;
if
(
latency
<
100
)
values
[
a
][
b
]
=
latency
;
latency
=
-
1
;
values
[
b
-
1
][
a
-
1
]
=
latency
;
values
[
a
-
1
][
b
-
1
]
=
latency
;
}
}
fclose
(
file
);
fclose
(
file
);
...
@@ -89,3 +97,18 @@ double Latency::GetAverageDistance()
...
@@ -89,3 +97,18 @@ double Latency::GetAverageDistance()
return
avg
/
(
size
*
size
);
return
avg
/
(
size
*
size
);
}
}
double
Latency
::
GetAveragePing
()
{
double
out
=
0
;
double
nPing
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
j
=
0
;
j
<
size
;
j
++
)
if
(
values
[
i
][
j
]
>
0
)
{
nPing
++
;
out
+=
values
[
i
][
j
];
}
return
out
/
nPing
;
}
\ No newline at end of file
simulation/realistic_dataset/main.cpp
View file @
01f450fd
// To compile : g++ -std=c++0x latency.cpp graph.cpp main.cpp -lpthread
// To compile : g++ -std=c++0x latency.cpp graph.cpp main.cpp -lpthread
// The best distance : 66.9239 with a full graph
// The best distance
for latency
: 66.9239 with a full graph
// other dataset : http://pdos.csail.mit.edu/p2psim/kingdata/
// other dataset : http://pdos.csail.mit.edu/p2psim/kingdata/
// for latency_2 :
// Optimal distance : 16085.3
// Average ping : 75809.4
#include "main.h"
#include "main.h"
...
@@ -10,35 +13,38 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
...
@@ -10,35 +13,38 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
FILE
*
output
=
fopen
(
outName
,
"wt"
);
FILE
*
output
=
fopen
(
outName
,
"wt"
);
int
fno
=
fileno
(
output
);
int
fno
=
fileno
(
output
);
fprintf
(
output
,
"round,alive,unreachable
\n
"
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
cout
<<
"
\r
"
<<
0
<<
"/"
<<
300
;
cout
<<
"
\r
"
<<
0
<<
"/"
<<
300
;
cout
.
flush
();
cout
.
flush
();
long
long
int
nUpdates
=
0
;
for
(
int
i
=
0
;
i
<
300
;
i
++
)
for
(
int
i
=
0
;
i
<
300
;
i
++
)
{
{
for
(
float
a
=
0.05
;
a
<
1
;
a
+=
0.05
)
/*
for(float a=0.05; a<1; a+=0.05)
{
{
Graph copy(graph);
Graph copy(graph);
copy.KillMachines(a);
copy.KillMachines(a);
fprintf(output, "%d,%f,%f\n",i , a , copy.GetUnAvalaibility());
fprintf(output, "%d,%f,%f\n",i , a , copy.GetUnAvalaibility());
fflush(output);
fflush(output);
fsync(fno);
fsync(fno);
}
}
*/
double
avgDistance
,
unreachable
;
double
avgDistance
,
unreachable
;
double
arityDistrib
[
31
];
double
arityDistrib
[
31
]
,
bcArity
[
31
]
;
graph
.
UpdateLowRoutes
(
avgDistance
,
unreachable
,
arityDistrib
);
nUpdates
+=
graph
.
UpdateLowRoutes
(
avgDistance
,
unreachable
,
arityDistrib
,
bcArity
,
1
,
i
);
/*fprintf(output, "%d,%f", i, avgDistance
);
fprintf
(
output
,
"%d,%f, %lld"
,
i
,
avgDistance
,
nUpdates
);
for
(
int
j
=
0
;
j
<=
30
;
j
++
)
for
(
int
j
=
0
;
j
<=
30
;
j
++
)
fprintf
(
output
,
",%f"
,
arityDistrib
[
j
]);
fprintf
(
output
,
",%f"
,
arityDistrib
[
j
]);
for
(
int
j
=
0
;
j
<=
30
;
j
++
)
fprintf
(
output
,
",%f"
,
bcArity
[
j
]);
fprintf
(
output
,
"
\n
"
);
fprintf
(
output
,
"
\n
"
);
fflush
(
output
);
fflush
(
output
);
fsync(fno);
*/
fsync
(
fno
);
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
300
;
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
300
;
cout
.
flush
();
cout
.
flush
();
...
@@ -51,19 +57,21 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
...
@@ -51,19 +57,21 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
mt19937
rng
(
time
(
NULL
));
mt19937
rng
(
time
(
NULL
));
Latency
latencyR
(
"latency/pw-1715/pw-1715-latencies"
,
1715
);
//
Latency latencyR("latency/pw-1715/pw-1715-latencies", 1715);
latencyR
.
Rewrite
(
20
);
//
latencyR.Rewrite(20);
Latency
latency
(
"
latency/pw-1715/rewrite"
,
1555
);
Latency
latency
(
"
datasets/latency_2_2500"
,
2500
);
//cout << "Optimal distance : " << latency.GetAverageDistance() << endl;
//cout << "Average ping : " << latency.GetAveragePing() << endl;
vector
<
future
<
void
>>
threads
;
vector
<
future
<
void
>>
threads
;
for
(
int
i
=
0
;
i
<
20
;
i
++
)
for
(
int
i
=
0
;
i
<
1
;
i
++
)
{
{
int
seed
=
rng
();
int
seed
=
rng
();
char
*
out
=
new
char
[
20
];
char
*
out
=
new
char
[
20
];
sprintf
(
out
,
"out_%d.csv"
,
i
);
sprintf
(
out
,
"out_%d.csv"
,
i
);
threads
.
push_back
(
async
(
launch
::
async
,
[
seed
,
out
,
&
latency
]()
threads
.
push_back
(
async
(
launch
::
async
,
[
seed
,
out
,
&
latency
]()
{
simulate
(
1555
,
10
,
30
,
seed
,
latency
,
out
);
delete
[]
out
;
}));
{
simulate
(
2500
,
10
,
30
,
seed
,
latency
,
out
);
delete
[]
out
;
}));
}
}
for
(
int
i
=
0
;
i
<
1
;
i
++
)
for
(
int
i
=
0
;
i
<
1
;
i
++
)
...
...
simulation/realistic_dataset/main.h
View file @
01f450fd
...
@@ -19,6 +19,7 @@ public:
...
@@ -19,6 +19,7 @@ public:
void
Rewrite
(
int
n
);
void
Rewrite
(
int
n
);
~
Latency
();
~
Latency
();
double
GetAverageDistance
();
double
GetAverageDistance
();
double
GetAveragePing
();
int
**
values
;
int
**
values
;
private:
private:
...
@@ -31,7 +32,7 @@ public:
...
@@ -31,7 +32,7 @@ public:
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
const
Latency
&
latency
);
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
const
Latency
&
latency
);
Graph
(
const
Graph
&
g
);
Graph
(
const
Graph
&
g
);
~
Graph
()
{
delete
[]
adjacency
;
delete
[]
generated
;
};
~
Graph
()
{
delete
[]
adjacency
;
delete
[]
generated
;
};
void
UpdateLowRoutes
(
double
&
avgDistance
,
double
unreachable
,
double
*
arityDistrib
);
int
UpdateLowRoutes
(
double
&
avgDistance
,
double
unreachable
,
double
*
arityDistrib
,
double
*
bcArity
,
int
nRefresh
,
int
round
);
double
GetUnAvalaibility
();
double
GetUnAvalaibility
();
void
KillMachines
(
float
proportion
);
void
KillMachines
(
float
proportion
);
...
@@ -58,5 +59,5 @@ struct routesResult
...
@@ -58,5 +59,5 @@ struct routesResult
double
avgDistance
;
double
avgDistance
;
int
arity
;
int
arity
;
int
unreachable
;
int
unreachable
;
int
toDelete
;
stack
<
int
>
toDelete
;
};
};
\ No newline at end of file
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