Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
a362cb93
Commit
a362cb93
authored
Dec 14, 2016
by
Marc Schiller
Browse files
Added debug graphs.
parent
1473d2ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/views/fiveg/ModelBasedSegmentDatabase.java
View file @
a362cb93
...
...
@@ -49,6 +49,7 @@ public class ModelBasedSegmentDatabase
}
public
void
setModel
(
AbstractModel
model
)
{
model
.
debug
();
ParameterType
type
=
model
.
getParameterType
();
if
(
type
==
null
)
{
throw
new
ConfigurationException
(
...
...
@@ -140,6 +141,16 @@ public class ModelBasedSegmentDatabase
}
public
class
ModelBasedEntry
implements
FiveGTopologyDatabase
.
Entry
{
private
final
long
OVERLOAD_LATENCY
=
9999
*
Time
.
MILLISECOND
;
private
final
long
OVERLOAD_BANDWIDTH
=
(
long
)
0.1
;
private
final
double
OVERLOAD_DROPRATE
=
1
;
private
final
long
THRESHOLD_LATENCY
=
Time
.
SECOND
;
private
final
long
THRESHOLD_BANDWIDTH
=
10
;
private
final
double
THRESHOLD_DROPRATE
=
1
;
private
HashMap
<
ParameterType
,
HashMap
<
Direction
,
Long
>>
currentValues
=
new
HashMap
<>();
private
final
int
segment
;
...
...
@@ -149,6 +160,7 @@ public class ModelBasedSegmentDatabase
public
ModelBasedEntry
(
int
segment
)
{
this
.
segment
=
segment
;
evaluateAll
();
}
@Override
...
...
@@ -158,44 +170,39 @@ public class ModelBasedSegmentDatabase
public
void
onHostLeavesSegment
(
MacAddress
hostAddr
)
{
this
.
hostsInSegment
.
remove
(
hostAddr
);
evaluateAll
();
}
public
void
onHostEntersSegment
(
MacAddress
hostAddr
)
{
this
.
hostsInSegment
.
add
(
hostAddr
);
evaluateAll
();
}
@Override
public
double
getDropProbability
(
boolean
isUpload
)
{
if
(!
isAvailable
)
{
return
1
;
if
(
isUpload
)
{
return
this
.
currentValues
.
get
(
ParameterType
.
DROPRATE
).
get
(
Direction
.
UPLOAD
);
}
else
{
return
this
.
currentValues
.
get
(
ParameterType
.
DROPRATE
).
get
(
Direction
.
DOWNLOAD
);
}
// TODO: Eval other parameters first
return
getModel
(
new
Integer
(
getSegmentID
()),
ParameterType
.
DROPRATE
,
isUpload
).
getDouble
(
this
.
hostsInSegment
.
size
());
}
@Override
public
long
getLatency
(
boolean
isUpload
)
{
if
(!
isAvailable
)
{
return
9999
*
Time
.
MILLISECOND
;
if
(
isUpload
)
{
return
this
.
currentValues
.
get
(
ParameterType
.
LATENCY
).
get
(
Direction
.
UPLOAD
);
}
else
{
return
this
.
currentValues
.
get
(
ParameterType
.
LATENCY
).
get
(
Direction
.
DOWNLOAD
);
}
// TODO: Eval other parameters first
return
getModel
(
new
Integer
(
getSegmentID
()),
ParameterType
.
LATENCY
,
isUpload
).
getLong
(
this
.
hostsInSegment
.
size
());
}
@Override
public
long
getBandwidth
(
boolean
isUpload
)
{
if
(!
isAvailable
)
{
return
0
;
if
(
isUpload
)
{
return
this
.
currentValues
.
get
(
ParameterType
.
BANDWIDTH
).
get
(
Direction
.
UPLOAD
);
}
else
{
return
this
.
currentValues
.
get
(
ParameterType
.
BANDWIDTH
).
get
(
Direction
.
DOWNLOAD
);
}
// TODO: Eval other parameters first
return
getModel
(
new
Integer
(
getSegmentID
()),
ParameterType
.
BANDWIDTH
,
isUpload
)
.
getLong
(
this
.
hostsInSegment
.
size
());
}
@Override
...
...
@@ -207,5 +214,63 @@ public class ModelBasedSegmentDatabase
public
void
setAvailability
(
boolean
isAvailable
)
{
this
.
isAvailable
=
isAvailable
;
}
private
void
evaluateAll
()
{
int
currentUsers
=
this
.
hostsInSegment
.
size
();
// Calc Bandwidth
long
bandUp
=
getModel
(
getSegmentID
(),
ParameterType
.
BANDWIDTH
,
true
).
getLong
(
currentUsers
);
long
bandDown
=
getModel
(
getSegmentID
(),
ParameterType
.
BANDWIDTH
,
true
).
getLong
(
currentUsers
);
// Calc Latency
long
latencyUp
=
getModel
(
getSegmentID
(),
ParameterType
.
LATENCY
,
true
).
getLong
(
currentUsers
);
long
latencyDown
=
getModel
(
getSegmentID
(),
ParameterType
.
LATENCY
,
true
).
getLong
(
currentUsers
);
// Calc DropRate
double
droprateUp
=
getModel
(
getSegmentID
(),
ParameterType
.
DROPRATE
,
true
).
getLong
(
currentUsers
);
double
droprateDown
=
getModel
(
getSegmentID
(),
ParameterType
.
DROPRATE
,
true
).
getLong
(
currentUsers
);
// One Value is above threshold -> everyone is down
if
(!
isAvailable
||
bandUp
<=
THRESHOLD_BANDWIDTH
||
bandDown
<=
THRESHOLD_BANDWIDTH
||
latencyUp
>=
THRESHOLD_LATENCY
||
latencyDown
>=
THRESHOLD_LATENCY
||
droprateDown
>=
THRESHOLD_DROPRATE
||
droprateUp
>=
THRESHOLD_DROPRATE
)
{
//System.out.println("Overload!");
HashMap
<
Direction
,
Long
>
tmp
=
new
HashMap
<>(
2
);
tmp
.
put
(
Direction
.
DOWNLOAD
,
OVERLOAD_BANDWIDTH
);
tmp
.
put
(
Direction
.
UPLOAD
,
OVERLOAD_BANDWIDTH
);
this
.
currentValues
.
put
(
ParameterType
.
BANDWIDTH
,
tmp
);
tmp
=
new
HashMap
<>(
2
);
tmp
.
put
(
Direction
.
DOWNLOAD
,
OVERLOAD_LATENCY
);
tmp
.
put
(
Direction
.
UPLOAD
,
OVERLOAD_LATENCY
);
this
.
currentValues
.
put
(
ParameterType
.
LATENCY
,
tmp
);
tmp
=
new
HashMap
<>(
2
);
tmp
.
put
(
Direction
.
DOWNLOAD
,
(
long
)
OVERLOAD_DROPRATE
);
tmp
.
put
(
Direction
.
UPLOAD
,
(
long
)
OVERLOAD_DROPRATE
);
this
.
currentValues
.
put
(
ParameterType
.
DROPRATE
,
tmp
);
}
else
{
//System.out.println("Everything ok!");
HashMap
<
Direction
,
Long
>
tmp
=
new
HashMap
<>(
2
);
tmp
.
put
(
Direction
.
DOWNLOAD
,
bandDown
);
tmp
.
put
(
Direction
.
UPLOAD
,
bandUp
);
this
.
currentValues
.
put
(
ParameterType
.
BANDWIDTH
,
tmp
);
tmp
=
new
HashMap
<>(
2
);
tmp
.
put
(
Direction
.
DOWNLOAD
,
latencyDown
);
tmp
.
put
(
Direction
.
UPLOAD
,
latencyUp
);
this
.
currentValues
.
put
(
ParameterType
.
LATENCY
,
tmp
);
tmp
=
new
HashMap
<>(
2
);
tmp
.
put
(
Direction
.
DOWNLOAD
,
(
long
)
droprateDown
);
tmp
.
put
(
Direction
.
UPLOAD
,
(
long
)
droprateUp
);
this
.
currentValues
.
put
(
ParameterType
.
DROPRATE
,
tmp
);
}
//System.out.println(this.currentValues);
}
}
}
src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/AbstractModel.java
View file @
a362cb93
...
...
@@ -22,6 +22,7 @@ package de.tud.kom.p2psim.impl.topology.views.fiveg.models;
import
de.tud.kom.p2psim.api.scenario.ConfigurationException
;
import
de.tud.kom.p2psim.impl.topology.views.fiveg.utils.Direction
;
import
de.tud.kom.p2psim.impl.topology.views.fiveg.utils.Graph
;
import
de.tud.kom.p2psim.impl.topology.views.fiveg.utils.ParameterType
;
public
abstract
class
AbstractModel
{
...
...
@@ -30,7 +31,9 @@ public abstract class AbstractModel {
private
ParameterType
type
;
private
Direction
dir
=
Direction
.
BOTH
;
private
boolean
debug
=
false
;
public
void
setSegmentID
(
int
segmentid
)
{
assert
segmentid
>
0
;
this
.
segmentID
=
segmentid
;
...
...
@@ -79,8 +82,21 @@ public abstract class AbstractModel {
public
Direction
getDirection
()
{
return
dir
;
}
public
void
setDebug
(
boolean
debug
)
{
this
.
debug
=
true
;
}
public
boolean
getDebug
()
{
return
this
.
debug
;
}
public
abstract
long
getLong
(
int
users
);
public
abstract
double
getDouble
(
int
users
);
public
void
debug
()
{
Graph
test
=
new
Graph
(
"Debug Graph"
);
test
.
setModel
(
this
);
}
}
src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LogarithmicModel.java
View file @
a362cb93
...
...
@@ -55,7 +55,12 @@ public class LogarithmicModel extends AbstractModel {
@Override
public
double
getDouble
(
int
users
)
{
return
this
.
a
*
Math
.
log
(
this
.
c
*
users
+
this
.
d
)
+
this
.
b
;
double
tmp
=
this
.
a
*
Math
.
log
(
this
.
c
*
users
+
this
.
d
)
+
this
.
b
;
if
(
tmp
<
0
)
{
return
0
;
}
else
{
return
tmp
;
}
}
@Override
...
...
src/de/tud/kom/p2psim/impl/topology/views/fiveg/utils/Graph.java
0 → 100644
View file @
a362cb93
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tud.kom.p2psim.impl.topology.views.fiveg.utils
;
import
org.jfree.chart.ChartFactory
;
import
org.jfree.chart.ChartPanel
;
import
org.jfree.chart.JFreeChart
;
import
org.jfree.chart.plot.PlotOrientation
;
import
org.jfree.data.category.DefaultCategoryDataset
;
import
org.jfree.ui.ApplicationFrame
;
import
de.tud.kom.p2psim.impl.topology.views.fiveg.models.AbstractModel
;
public
class
Graph
extends
ApplicationFrame
{
public
Graph
(
String
title
)
{
super
(
title
);
}
public
void
setModel
(
AbstractModel
model
)
{
if
(
model
.
getDebug
())
{
DefaultCategoryDataset
dataset
=
new
DefaultCategoryDataset
();
for
(
int
i
=
0
;
i
<=
500
;
i
+=
1
)
{
System
.
out
.
println
(
model
.
getDouble
(
i
));
dataset
.
addValue
(
model
.
getDouble
(
i
),
"Value"
,
Integer
.
toString
(
i
));
}
JFreeChart
lineChart
=
ChartFactory
.
createLineChart
(
model
.
toString
(),
"Users"
,
"Value"
,
dataset
,
PlotOrientation
.
VERTICAL
,
false
,
true
,
false
);
ChartPanel
chartPanel
=
new
ChartPanel
(
lineChart
);
setContentPane
(
chartPanel
);
pack
();
setVisible
(
true
);
}
}
}
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