Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tinynets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jake Read
tinynets
Commits
df250870
Commit
df250870
authored
7 years ago
by
rupumped
Browse files
Options
Downloads
Patches
Plain Diff
Delays
parent
2b713811
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sim/TinyNets/public_html/js_code.txt
+100
-10000
100 additions, 10000 deletions
sim/TinyNets/public_html/js_code.txt
sim/TinyNets/public_html/sim.js
+21
-12
21 additions, 12 deletions
sim/TinyNets/public_html/sim.js
with
121 additions
and
10012 deletions
sim/TinyNets/public_html/js_code.txt
+
100
−
10000
View file @
df250870
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
sim/TinyNets/public_html/sim.js
+
21
−
12
View file @
df250870
...
@@ -3,15 +3,25 @@ var net = require("./network"),
...
@@ -3,15 +3,25 @@ var net = require("./network"),
const
startupDelay
=
100
;
const
startupDelay
=
100
;
const
connectDelay
=
100
;
const
connectDelay
=
100
;
const
bufferCheckDelay
=
1000
;
// The time it takes for a node to process a byte = DELAY_PKT +
const
heartbeatPeriod
=
400
;
// n*DELAY_TX_HB*DELAY_PKT/PERIOD_TX_HB +
// n*DELAY_RX_HB*DELAY_PKT/PERIOD_RX_HB +
// n*DELAY_TAKE_PULSE*DELAY_PKT/PERIOD_TAKE_PULSE,
// n=# of nearest neighbors
const
DELAY_PKT
=
500
;
// Baseline packet delay. Assuming no heartbeats, how long it takes to process a packet
const
DELAY_TX_HB
=
50
;
// How long it takes to transmit a single heartbeat to a single neighbor
const
PERIOD_TX_HB
=
240
;
// Period with which heartbeats are transmitted to all neighbors
const
DELAY_RX_HB
=
50
;
// How long it takes to receive and process a single heartbeat from a single neighbor
const
PERIOD_RX_HB
=
PERIOD_TX_HB
;
// Period with which heartbeats are received from a single neighbor
const
DELAY_TAKE_PULSE
=
50
;
// How long it takes to process received heartbeats
const
PERIOD_TAKE_PULSE
=
2
*
PERIOD_RX_HB
;
// Period with which received heartbeats are processed
// INITIALIZE NETWORK TOPOLOGY HERE
// INITIALIZE NETWORK TOPOLOGY HERE
var
initTopology
=
[];
var
initTopology
=
[];
var
rawFile
=
new
XMLHttpRequest
();
var
rawFile
=
new
XMLHttpRequest
();
rawFile
.
open
(
"
GET
"
,
"
js_code.txt
"
,
false
);
rawFile
.
open
(
"
GET
"
,
"
js_code.txt
"
,
false
);
rawFile
.
onreadystatechange
=
function
()
{
rawFile
.
onreadystatechange
=
function
()
{
if
(
rawFile
.
readyState
===
4
&&
(
rawFile
.
status
===
200
||
rawFile
.
status
==
0
))
if
(
rawFile
.
readyState
===
4
&&
(
rawFile
.
status
===
200
||
rawFile
.
status
==
=
0
))
{
{
var
allText
=
rawFile
.
responseText
;
var
allText
=
rawFile
.
responseText
;
allText
=
allText
.
split
(
'
\n
'
);
allText
=
allText
.
split
(
'
\n
'
);
...
@@ -25,7 +35,7 @@ rawFile.onreadystatechange = function () {
...
@@ -25,7 +35,7 @@ rawFile.onreadystatechange = function () {
initTopology
.
push
(
neighbors
);
initTopology
.
push
(
neighbors
);
}
}
}
}
}
}
;
rawFile
.
send
(
null
);
rawFile
.
send
(
null
);
// Don't touch this code
// Don't touch this code
...
@@ -42,21 +52,20 @@ for (let i = 0; i < initTopology.length; i++) {
...
@@ -42,21 +52,20 @@ for (let i = 0; i < initTopology.length; i++) {
this
.
delay
(
startupDelay
,
function
()
{
this
.
delay
(
startupDelay
,
function
()
{
this
.
manager
.
setup
(
initTopology
[
i
].
length
);
this
.
manager
.
setup
(
initTopology
[
i
].
length
);
});
});
this
.
delay
(
500
,
function
()
{
this
.
tick
(
DELAY_PKT
+
initTopology
[
i
].
length
*
DELAY_TX_HB
*
DELAY_PKT
/
PERIOD_TX_HB
this
.
manager
.
printPorts
();
+
initTopology
[
i
].
length
*
DELAY_RX_HB
*
DELAY_PKT
/
PERIOD_RX_HB
});
+
initTopology
[
i
].
length
*
DELAY_TAKE_PULSE
*
DELAY_PKT
/
PERIOD_TAKE_PULSE
,
function
()
{
this
.
tick
(
bufferCheckDelay
,
function
()
{
this
.
manager
.
checkBuffer
();
this
.
manager
.
checkBuffer
();
});
});
this
.
tick
(
heartbeatPeriod
,
function
()
{
this
.
tick
(
PERIOD_TX_HB
,
function
()
{
this
.
manager
.
heartbeat
();
this
.
manager
.
heartbeat
();
});
});
this
.
tick
(
2
*
heartbeatPeriod
,
function
()
{
this
.
tick
(
PERIOD_RX_HB
,
function
()
{
this
.
manager
.
takePulse
();
this
.
manager
.
takePulse
();
});
});
});
});
for
(
let
j
=
0
;
j
<
initTopology
[
i
].
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
initTopology
[
i
].
length
;
j
++
)
{
if
(
initTopology
[
i
][
j
]
==
-
1
)
{
if
(
initTopology
[
i
][
j
]
==
=
-
1
)
{
continue
;
continue
;
}
}
...
@@ -70,7 +79,7 @@ for (let i = 0; i < initTopology.length; i++) {
...
@@ -70,7 +79,7 @@ for (let i = 0; i < initTopology.length; i++) {
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// PUT CUSTOM CODE HERE:
// PUT CUSTOM CODE HERE:
sendPacket
(
0
,
99
99
,
1
,
"
Hello!
"
,
1000
);
sendPacket
(
0
,
99
,
1
,
"
Hello!
"
,
1000
);
// To test link failure, uncomment one. To test node failure, uncomment both.
// To test link failure, uncomment one. To test node failure, uncomment both.
//disconnect(0,1,2,0,6000);
//disconnect(0,1,2,0,6000);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment