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
Xiaowu Zhang
re6stnet
Commits
28bcfc52
Commit
28bcfc52
authored
Jul 31, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The simulator con now check the resilience
parent
0287dc9a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
32 deletions
+77
-32
README
README
+16
-16
simulation/realistic_dataset/graph.cpp
simulation/realistic_dataset/graph.cpp
+8
-5
simulation/realistic_dataset/latency.cpp
simulation/realistic_dataset/latency.cpp
+32
-3
simulation/realistic_dataset/main.cpp
simulation/realistic_dataset/main.cpp
+18
-7
simulation/realistic_dataset/main.h
simulation/realistic_dataset/main.h
+3
-1
No files found.
README
View file @
28bcfc52
New log system :
we use the logging module now. There are three levels for log messages :
- info : give basic information about what vifibnet is doing
- debug : display internal work of the script (finished action, detailed
information about tunnels, etc... )
- trace : for intensive debug, display configuration, arguments given to
processes, all information pertinent to debug but not required
mot of the time
Additionally, warning, error and exception can be used.
Note : logging.exception prints informations similar to pdb.set_trace()
info, which is pretty heavy, so for exception we expect ( for
instance, connection problems to the registry ), one can print the
exception as warning. ( see db.refresh() ).
Vifibnet is a daemon setting up a resilient virtual private network over the
internet
...
...
@@ -32,7 +18,8 @@ The organisation of the code
Note: On certain version of python (e.g. 2.7.3~rc2-2.1 ) dns lookup is
performed for each request, and cause a delay in response.
To avoid this, one can either upgrade python, or fix their resolv.conf
To avoid this, one can either upgrade python, fix their resolv.conf or use
the fix at the end of this file.
OPTIONS : REGISTRY.PY
usage : ./registry port [options...]
...
...
@@ -243,7 +230,6 @@ the beggining of registry.py
--------------------------------------------------------------------------------
# Fix for librpcxml to avoid doing reverse dns on each request
# it was causing a 10s delay on each request when no reverse DNS was avalaible
# for tis IP
import BaseHTTPServer
...
...
@@ -254,3 +240,17 @@ def not_insane_address_string(self):
BaseHTTPServer.BaseHTTPRequestHandler.address_string = not_insane_address_string
--------------------------------------------------------------------------------
New log system :
we use the logging module now. There are three levels for log messages :
- info : give basic information about what vifibnet is doing
- debug : display internal work of the script (finished action, detailed
information about tunnels, etc... )
- trace : for intensive debug, display configuration, arguments given to
processes, all information pertinent to debug but not required
mot of the time
Additionally, warning, error and exception can be used.
Note : logging.exception prints informations similar to pdb.set_trace()
info, which is pretty heavy, so for exception we expect ( for
instance, connection problems to the registry ), one can print the
exception as warning. ( see db.refresh() ).
\ No newline at end of file
simulation/realistic_dataset/graph.cpp
View file @
28bcfc52
#include "main.h"
Graph
::
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
const
Latency
&
latency
)
:
generator
(
generator
),
size
(
size
),
k
(
k
),
maxPeers
(
maxPeers
),
latency
(
latency
),
Graph
::
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
rng
,
const
Latency
&
latency
)
:
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
];
...
...
@@ -36,8 +36,9 @@ bool Graph::AddEdge(int from)
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
to
=
distrib
(
generator
);
if
(
latency
.
values
[
from
][
to
]
>
0
&&
to
!=
from
if
(
to
!=
from
&&
latency
.
values
[
from
][
to
]
>
0
&&
adjacency
[
from
].
count
(
to
)
==
0
&&
adjacency
[
to
].
size
()
+
generated
[
to
].
size
()
<=
maxPeers
+
k
)
{
...
...
@@ -218,6 +219,8 @@ double Graph::GetUnAvalaibility()
void
Graph
::
KillMachines
(
float
proportion
)
{
size
=
proportion
*
size
;
distrib
=
uniform_int_distribution
<
int
>
(
0
,
size
-
1
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
vector
<
int
>
toBeRemoved
;
...
...
simulation/realistic_dataset/latency.cpp
View file @
28bcfc52
...
...
@@ -30,7 +30,7 @@ void Latency::Rewrite(int n)
int
nReachable
=
0
;
for
(
int
j
=
0
;
j
<
size
;
j
++
)
{
if
(
values
[
i
][
j
]
>
0
)
if
(
j
!=
i
&&
values
[
i
][
j
]
>=
1
0
)
nReachable
++
;
}
...
...
@@ -47,9 +47,9 @@ void Latency::Rewrite(int n)
file
=
fopen
(
"latency/pw-1715/rewrite"
,
"w"
);
for
(
int
i
=
0
;
i
<
size
-
1
;
i
++
)
if
(
nat
[
i
]
!=
-
1
)
for
(
int
j
=
1
;
j
<
size
;
j
++
)
for
(
int
j
=
i
+
1
;
j
<
size
;
j
++
)
if
(
nat
[
j
]
!=
-
1
)
fprintf
(
file
,
"%d %d %d
\n
"
,
nat
[
i
],
nat
[
j
],
values
[
i
][
j
]);
fprintf
(
file
,
"%d %d %d
\n
"
,
nat
[
i
],
nat
[
j
],
values
[
i
][
j
]
>=
10
?
values
[
i
][
j
]
:-
1
);
fclose
(
file
);
}
...
...
@@ -60,3 +60,32 @@ Latency::~Latency()
delete
[]
values
[
i
];
delete
[]
values
;
}
double
Latency
::
GetAverageDistance
()
{
int
size
=
1555
;
double
**
distances
=
new
double
*
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
distances
[
i
]
=
new
double
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
j
=
0
;
j
<
size
;
j
++
)
if
(
i
==
j
)
distances
[
i
][
j
]
=
0
;
else
if
(
values
[
i
][
j
]
>
0
)
distances
[
i
][
j
]
=
values
[
i
][
j
];
else
distances
[
i
][
j
]
=
numeric_limits
<
double
>::
infinity
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
j
=
0
;
j
<
size
;
j
++
)
for
(
int
k
=
0
;
k
<
size
;
k
++
)
distances
[
i
][
j
]
=
min
(
distances
[
i
][
j
],
distances
[
i
][
k
]
+
distances
[
k
][
j
]);
double
avg
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
j
=
0
;
j
<
size
;
j
++
)
avg
+=
distances
[
i
][
j
];
return
avg
/
(
size
*
size
);
}
\ No newline at end of file
simulation/realistic_dataset/main.cpp
View file @
28bcfc52
// To compile : g++ -std=c++0x results.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
#include "main.h"
void
simulate
(
int
size
,
int
k
,
int
maxPeer
,
int
seed
,
const
Latency
&
latency
,
const
char
*
outName
)
{
mt19937
rng
(
seed
);
FILE
*
output
=
fopen
(
outName
,
"wt"
);
int
fno
=
fileno
(
output
);
fprintf
(
output
,
"round,alive,unreachable
\n
"
);
mt19937
rng
(
seed
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
cout
<<
"
\r
"
<<
0
<<
"/"
<<
300
;
...
...
@@ -19,7 +22,7 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
{
Graph
copy
(
graph
);
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
);
fsync
(
fno
);
}
...
...
@@ -28,6 +31,14 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
double
avgDistance
,
unreachable
;
double
arityDistrib
[
31
];
graph
.
UpdateLowRoutes
(
avgDistance
,
unreachable
,
arityDistrib
);
/*fprintf(output, "%d,%f", i, avgDistance);
for(int j=0; j<=30; j++)
fprintf(output, ",%f", arityDistrib[j]);
fprintf(output, "\n");
fflush(output);
fsync(fno);*/
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
300
;
cout
.
flush
();
}
...
...
@@ -39,13 +50,13 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
int
main
(
int
argc
,
char
**
argv
)
{
mt19937
rng
(
time
(
NULL
));
//Latency latency
("latency/pw-1715/pw-1715-latencies", 1715);
//latency
.Rewrite(20);
Latency
latencyR
(
"latency/pw-1715/pw-1715-latencies"
,
1715
);
latencyR
.
Rewrite
(
20
);
Latency
latency
(
"latency/pw-1715/rewrite"
,
1555
);
vector
<
future
<
void
>>
threads
;
for
(
int
i
=
0
;
i
<
8
;
i
++
)
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
int
seed
=
rng
();
char
*
out
=
new
char
[
20
];
...
...
@@ -54,7 +65,7 @@ int main(int argc, char** argv)
{
simulate
(
1555
,
10
,
30
,
seed
,
latency
,
out
);
delete
[]
out
;
}));
}
for
(
int
i
=
0
;
i
<
8
;
i
++
)
for
(
int
i
=
0
;
i
<
1
;
i
++
)
threads
[
i
].
get
();
return
0
;
...
...
simulation/realistic_dataset/main.h
View file @
28bcfc52
...
...
@@ -7,6 +7,7 @@
#include <future>
#include <sstream>
#include <unistd.h>
#include <limits>
using
namespace
std
;
...
...
@@ -17,6 +18,7 @@ public:
Latency
(
const
char
*
filePath
,
int
size
);
void
Rewrite
(
int
n
);
~
Latency
();
double
GetAverageDistance
();
int
**
values
;
private:
...
...
@@ -40,7 +42,7 @@ private:
void
GetRoutesFrom
(
int
from
,
int
*
nRoutes
,
int
*
prevs
,
int
*
distances
);
int
CountUnreachableFrom
(
int
node
);
mt19937
&
generator
;
mt19937
generator
;
uniform_int_distribution
<
int
>
distrib
;
int
maxPeers
;
int
k
;
...
...
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