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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
re6stnet
Commits
ed6df9d4
Commit
ed6df9d4
authored
Jul 18, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove trailing whitespaces
parent
7d4346a9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
22 deletions
+22
-22
db.py
db.py
+2
-2
propagation.py
propagation.py
+3
-3
registry.py
registry.py
+2
-2
simulation/graph.cpp
simulation/graph.cpp
+5
-5
simulation/main.cpp
simulation/main.cpp
+6
-6
simulation/main.h
simulation/main.h
+2
-2
simulation/results.cpp
simulation/results.cpp
+2
-2
No files found.
db.py
View file @
ed6df9d4
...
@@ -31,12 +31,12 @@ class PeerManager:
...
@@ -31,12 +31,12 @@ class PeerManager:
def
_declare
(
self
):
def
_declare
(
self
):
if
self
.
_external_ip
!=
None
:
if
self
.
_external_ip
!=
None
:
utils
.
log
(
'Declaring our connections info'
,
3
)
utils
.
log
(
'Declaring our connections info'
,
3
)
self
.
_proxy
.
declare
((
self
.
_internal_ip
,
self
.
_external_ip
,
self
.
_external_port
,
self
.
_proto
))
self
.
_proxy
.
declare
((
self
.
_internal_ip
,
self
.
_external_ip
,
self
.
_external_port
,
self
.
_proto
))
else
:
else
:
utils
.
log
(
'Warning : could not declare the external ip because it is unknown'
,
4
)
utils
.
log
(
'Warning : could not declare the external ip because it is unknown'
,
4
)
def
_populate
(
self
):
def
_populate
(
self
):
utils
.
log
(
'Populating the peers DB'
,
2
)
utils
.
log
(
'Populating the peers DB'
,
2
)
new_peer_list
=
self
.
_proxy
.
getPeerList
(
self
.
_db_size
,
self
.
_internal_ip
)
new_peer_list
=
self
.
_proxy
.
getPeerList
(
self
.
_db_size
,
self
.
_internal_ip
)
self
.
_db
.
executemany
(
"INSERT OR IGNORE INTO peers (ip, port, proto, used) VALUES (?,?,?,0)"
,
new_peer_list
)
self
.
_db
.
executemany
(
"INSERT OR IGNORE INTO peers (ip, port, proto, used) VALUES (?,?,?,0)"
,
new_peer_list
)
...
...
propagation.py
View file @
ed6df9d4
...
@@ -17,7 +17,7 @@ class RingMember:
...
@@ -17,7 +17,7 @@ class RingMember:
return
str
(
self
.
id
)
+
' '
+
self
.
ip
+
' '
+
str
(
self
.
port
)
return
str
(
self
.
id
)
+
' '
+
self
.
ip
+
' '
+
str
(
self
.
port
)
class
Ring
:
class
Ring
:
def
__init__
(
self
,
entryPoint
):
def
__init__
(
self
,
entryPoint
):
# initialize the connection
# initialize the connection
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
...
@@ -64,7 +64,7 @@ class Ring:
...
@@ -64,7 +64,7 @@ class Ring:
# if n < x && x < self.successor:
# if n < x && x < self.successor:
# self.successor = x
# self.successor = x
# SEND notify self.ip, self.id TO self.successor
# SEND notify self.ip, self.id TO self.successor
# def notify(self, n2)
# def notify(self, n2)
# if self.predecessor == None || (predecessor < n2 && n2 < n):
# if self.predecessor == None || (predecessor < n2 && n2 < n):
# self.predecessor = n2
# self.predecessor = n2
...
@@ -73,7 +73,7 @@ class Ring:
...
@@ -73,7 +73,7 @@ class Ring:
# def fixFingers(self)
# def fixFingers(self)
# next = (next + 1) mod (nFingers) # Or Random, cf google
# next = (next + 1) mod (nFingers) # Or Random, cf google
# finger[next] = find_successor(n+2^{next-1});
# finger[next] = find_successor(n+2^{next-1});
# to be called periodically
# to be called periodically
# def checkPredecessor(self)
# def checkPredecessor(self)
# if NO PING from self.predecessor:
# if NO PING from self.predecessor:
...
...
registry.py
View file @
ed6df9d4
...
@@ -86,7 +86,7 @@ class main(object):
...
@@ -86,7 +86,7 @@ class main(object):
server4
.
register_instance
(
self
)
server4
.
register_instance
(
self
)
server6
=
SimpleXMLRPCServer6
((
'::'
,
self
.
config
.
port
),
requestHandler
=
RequestHandler
,
allow_none
=
True
)
server6
=
SimpleXMLRPCServer6
((
'::'
,
self
.
config
.
port
),
requestHandler
=
RequestHandler
,
allow_none
=
True
)
server6
.
register_instance
(
self
)
server6
.
register_instance
(
self
)
# Main loop
# Main loop
while
True
:
while
True
:
try
:
try
:
...
@@ -169,7 +169,7 @@ class main(object):
...
@@ -169,7 +169,7 @@ class main(object):
return
crypto
.
dump_certificate
(
crypto
.
FILETYPE_PEM
,
self
.
ca
)
return
crypto
.
dump_certificate
(
crypto
.
FILETYPE_PEM
,
self
.
ca
)
def
getBootstrapPeer
(
self
,
handler
):
def
getBootstrapPeer
(
self
,
handler
):
# TODO: Insert a flag column for bootstrap ready servers in peers
# TODO: Insert a flag column for bootstrap ready servers in peers
# ( servers which shouldn't go down or change ip and port as opposed to servers owned by particulars )
# ( servers which shouldn't go down or change ip and port as opposed to servers owned by particulars )
# that way, we also ascertain that the server sent is not the new node....
# that way, we also ascertain that the server sent is not the new node....
ip
,
port
,
proto
=
self
.
db
.
execute
(
"SELECT ip, port, proto FROM peers ORDER BY random() LIMIT 1"
).
next
()
ip
,
port
,
proto
=
self
.
db
.
execute
(
"SELECT ip, port, proto FROM peers ORDER BY random() LIMIT 1"
).
next
()
...
...
simulation/graph.cpp
View file @
ed6df9d4
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include <map>
#include <map>
#include <queue>
#include <queue>
Graph
::
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
rng
)
:
Graph
::
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
rng
)
:
distrib
(
uniform_int_distribution
<
int
>
(
0
,
size
-
1
)),
distrib
(
uniform_int_distribution
<
int
>
(
0
,
size
-
1
)),
size
(
size
),
generator
(
rng
)
size
(
size
),
generator
(
rng
)
{
{
...
@@ -17,9 +17,9 @@ Graph::Graph(int size, int k, int maxPeers, mt19937& rng) :
...
@@ -17,9 +17,9 @@ Graph::Graph(int size, int k, int maxPeers, mt19937& rng) :
{
{
int
otherNode
;
int
otherNode
;
while
(
alreadyConnected
.
count
(
otherNode
=
distrib
(
rng
))
==
1
while
(
alreadyConnected
.
count
(
otherNode
=
distrib
(
rng
))
==
1
||
otherNode
>
i
&&
adjacency
[
otherNode
].
size
()
>
maxPeers
-
10
||
otherNode
>
i
&&
adjacency
[
otherNode
].
size
()
>
maxPeers
-
10
||
adjacency
[
otherNode
].
size
()
>
maxPeers
)
||
adjacency
[
otherNode
].
size
()
>
maxPeers
)
{
}
{
}
adjacency
[
i
].
push_back
(
otherNode
);
adjacency
[
i
].
push_back
(
otherNode
);
adjacency
[
otherNode
].
push_back
(
i
);
adjacency
[
otherNode
].
push_back
(
i
);
...
@@ -75,7 +75,7 @@ int Graph::CountUnreachableFrom(int node)
...
@@ -75,7 +75,7 @@ int Graph::CountUnreachableFrom(int node)
unAccessible
--
;
unAccessible
--
;
toVisit
.
pop
();
toVisit
.
pop
();
}
}
return
unAccessible
;
return
unAccessible
;
}
}
...
@@ -156,7 +156,7 @@ void MinCutGraph::Merge(int nMerge, mt19937& rng)
...
@@ -156,7 +156,7 @@ void MinCutGraph::Merge(int nMerge, mt19937& rng)
int
n1
=
edges
[
eId
].
v
.
first
;
int
n1
=
edges
[
eId
].
v
.
first
;
int
n2
=
edges
[
eId
].
v
.
second
;
int
n2
=
edges
[
eId
].
v
.
second
;
// anilate n2
// anilate n2
nodes
[
n2
].
null
=
true
;
nodes
[
n2
].
null
=
true
;
...
...
simulation/main.cpp
View file @
ed6df9d4
...
@@ -49,16 +49,16 @@ int main(int argc, char** argv)
...
@@ -49,16 +49,16 @@ int main(int argc, char** argv)
for
(
float
a
=
0.01
;
a
<=
1
;
a
+=
0.05
)
for
(
float
a
=
0.01
;
a
<=
1
;
a
+=
0.05
)
{
{
int
seed
=
rng
();
int
seed
=
rng
();
outputStrings
.
push_back
(
async
(
launch
::
async
,
[
seed
,
n
,
k
,
a
]()
outputStrings
.
push_back
(
async
(
launch
::
async
,
[
seed
,
n
,
k
,
a
]()
{
{
Results
results
=
Simulate
(
seed
,
n
,
k
,
3
*
k
,
10000
,
a
,
1
);
Results
results
=
Simulate
(
seed
,
n
,
k
,
3
*
k
,
10000
,
a
,
1
);
ostringstream
out
;
ostringstream
out
;
out
<<
n
<<
","
<<
k
<<
","
<<
a
<<
","
<<
3
*
k
<<
","
out
<<
n
<<
","
<<
k
<<
","
<<
a
<<
","
<<
3
*
k
<<
","
<<
results
.
avgDistance
<<
","
<<
results
.
avgDistance
<<
","
<<
results
.
disconnected
<<
","
<<
results
.
disconnected
<<
","
<<
results
.
disconnectionProba
<<
","
<<
results
.
disconnectionProba
<<
","
<<
results
.
maxDistanceReached
<<
","
<<
results
.
maxDistanceReached
<<
","
<<
results
.
arityDistrib
[
3
*
k
]
<<
","
<<
results
.
arityDistrib
[
3
*
k
]
<<
","
<<
results
.
minKConnexity
<<
","
<<
results
.
minKConnexity
<<
","
<<
results
.
avgAccessibility
<<
results
.
avgAccessibility
<<
endl
;
<<
endl
;
...
...
simulation/main.h
View file @
ed6df9d4
...
@@ -9,7 +9,7 @@ using namespace std;
...
@@ -9,7 +9,7 @@ using namespace std;
template
<
class
T
>
template
<
class
T
>
struct
nullable
struct
nullable
{
{
T
v
;
T
v
;
bool
null
;
bool
null
;
...
@@ -75,7 +75,7 @@ public:
...
@@ -75,7 +75,7 @@ public:
double
arityTooBig
;
double
arityTooBig
;
double
distanceTooBig
;
double
distanceTooBig
;
int64_t
disconnected
;
int64_t
disconnected
;
int
maxArity
;
int
maxArity
;
int
maxDistance
;
int
maxDistance
;
...
...
simulation/results.cpp
View file @
ed6df9d4
#include "main.h"
#include "main.h"
Results
::
Results
(
int
maxArity
,
int
maxDistance
)
:
Results
::
Results
(
int
maxArity
,
int
maxDistance
)
:
maxArity
(
maxArity
),
maxDistance
(
maxDistance
)
maxArity
(
maxArity
),
maxDistance
(
maxDistance
)
{
{
arityDistrib
=
new
double
[
maxArity
+
1
];
arityDistrib
=
new
double
[
maxArity
+
1
];
...
@@ -54,7 +54,7 @@ void Results::AddDistanceSample(int distance)
...
@@ -54,7 +54,7 @@ void Results::AddDistanceSample(int distance)
{
{
if
(
distance
==
-
1
)
if
(
distance
==
-
1
)
disconnected
++
;
disconnected
++
;
else
else
{
{
avgDistance
+=
distance
;
avgDistance
+=
distance
;
if
(
distance
<=
maxDistance
)
if
(
distance
<=
maxDistance
)
...
...
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