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
ded77519
Commit
ded77519
authored
Dec 15, 2016
by
Marc Schiller
Browse files
Fixed getModel() for specific combinations.
parent
3434115d
Changes
1
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/views/fiveg/ModelBasedSegmentDatabase.java
View file @
ded77519
...
...
@@ -133,68 +133,84 @@ public class ModelBasedSegmentDatabase
AbstractModel
getModel
(
int
segID
,
ParameterType
type
,
Boolean
isUpload
)
{
Integer
segmentID
=
new
Integer
(
segID
);
Direction
dir
=
Direction
.
DOWNLOAD
;
if
(
isUpload
)
{
dir
=
Direction
.
UPLOAD
;
}
// Check if type exists
if
(!
this
.
models
.
containsKey
(
type
))
{
throw
new
ConfigurationException
(
"No Model is defined for "
+
type
+
"."
);
}
if
(!
this
.
models
.
get
(
type
).
containsKey
(
segmentID
))
{
segmentID
=
DEFAULT_SEGMENT_ID
;
// Check if there is a specific model
if
(
this
.
models
.
get
(
type
).
containsKey
(
segmentID
)
&&
this
.
models
.
get
(
type
).
get
(
segmentID
).
containsKey
(
dir
))
{
return
this
.
models
.
get
(
type
).
get
(
segmentID
).
get
(
dir
);
}
if
(!
this
.
models
.
get
(
type
).
containsKey
(
segment
ID
))
{
throw
new
ConfigurationException
(
"No Model is defined for Type "
+
type
+
" and S
egment
ID
"
+
segmentID
+
"."
);
// Check if there is a BOTH model in this
segment
if
(
this
.
models
.
get
(
type
).
containsKey
(
segmentID
)
&&
this
.
models
.
get
(
type
).
get
(
segmentID
).
containsKey
(
Direction
.
BOTH
))
{
return
this
.
models
.
get
(
type
).
get
(
s
egmentID
).
get
(
Direction
.
BOTH
);
}
Direction
dir
=
Direction
.
DOWNLOAD
;
if
(
isUpload
)
{
dir
=
Direction
.
UPLOAD
;
// Check default model for specific model
if
(
this
.
models
.
get
(
type
).
containsKey
(
DEFAULT_SEGMENT_ID
)
&&
this
.
models
.
get
(
type
).
get
(
DEFAULT_SEGMENT_ID
).
containsKey
(
dir
))
{
return
this
.
models
.
get
(
type
).
get
(
DEFAULT_SEGMENT_ID
).
get
(
dir
);
}
if
(!
this
.
models
.
get
(
type
).
get
(
segmentID
).
containsKey
(
dir
))
{
dir
=
Direction
.
BOTH
;
// Check if there is a default BOTH model
if
(
this
.
models
.
get
(
type
).
containsKey
(
DEFAULT_SEGMENT_ID
)
&&
this
.
models
.
get
(
type
).
get
(
DEFAULT_SEGMENT_ID
).
containsKey
(
Direction
.
BOTH
))
{
return
this
.
models
.
get
(
type
).
get
(
DEFAULT_SEGMENT_ID
).
get
(
Direction
.
BOTH
);
}
if
(!
this
.
models
.
get
(
type
).
get
(
segmentID
).
containsKey
(
dir
))
{
throw
new
ConfigurationException
(
"No Model is defined for Type "
+
type
+
", Segment ID "
+
segmentID
+
" and Direction "
+
dir
+
"."
);
}
return
this
.
models
.
get
(
type
).
get
(
segmentID
).
get
(
dir
);
}
public
class
ModelBasedEntry
implements
FiveGTopologyDatabase
.
Entry
{
// How is a overload defined
private
final
long
OVERLOAD_LATENCY
=
9999
*
Time
.
MILLISECOND
;
private
final
long
OVERLOAD_BANDWIDTH
=
(
long
)
0.1
;
private
final
double
OVERLOAD_DROPRATE
=
1
;
// When is a node considered overloaded
private
final
long
THRESHOLD_LATENCY
=
Time
.
SECOND
;
private
final
long
THRESHOLD_BANDWIDTH
=
10
;
private
final
double
THRESHOLD_DROPRATE
=
1
;
// Other storage
private
final
int
segment
;
private
boolean
isAvailable
=
true
;
private
HashSet
<
MacAddress
>
hostsInSegment
=
new
HashSet
<>();
private
boolean
overload
;
// The current metrics of this segment
private
long
bandUp
;
private
long
bandDown
;
private
long
latUp
;
private
long
latDown
;
private
double
dropUp
;
private
double
dropDown
;
/**
* Create a new entry for the given segment
*
* @param segment
*/
public
ModelBasedEntry
(
int
segment
)
{
...
...
@@ -227,7 +243,8 @@ public class ModelBasedSegmentDatabase
@Override
public
double
getDropProbability
(
boolean
isUpload
)
{
// Segment is overloaded or not available return overloaded drop probability
// Segment is overloaded or not available return overloaded drop
// probability
if
(!
isAvailable
||
overload
)
{
return
OVERLOAD_DROPRATE
;
}
...
...
@@ -257,7 +274,8 @@ public class ModelBasedSegmentDatabase
@Override
public
long
getBandwidth
(
boolean
isUpload
)
{
// Segment is overloaded or not available return overloaded bandwidth
// Segment is overloaded or not available return overloaded
// bandwidth
if
(!
isAvailable
||
overload
)
{
return
OVERLOAD_BANDWIDTH
;
}
...
...
@@ -298,7 +316,8 @@ public class ModelBasedSegmentDatabase
if
(
bandDown
<=
THRESHOLD_BANDWIDTH
||
bandUp
<=
THRESHOLD_BANDWIDTH
)
{
overload
=
true
;
System
.
out
.
println
(
"Bandwidth is overloaded in Segment: "
+
getSegmentID
());
System
.
out
.
println
(
"Bandwidth is overloaded in Segment: "
+
getSegmentID
());
}
// Calc Latency
...
...
@@ -309,7 +328,8 @@ public class ModelBasedSegmentDatabase
if
(
latUp
>=
THRESHOLD_LATENCY
||
latDown
>=
THRESHOLD_LATENCY
)
{
overload
=
true
;
System
.
out
.
println
(
"Latency is overloaded in Segment: "
+
getSegmentID
());
System
.
out
.
println
(
"Latency is overloaded in Segment: "
+
getSegmentID
());
}
// Calc Droprate
...
...
@@ -321,7 +341,8 @@ public class ModelBasedSegmentDatabase
if
(
dropUp
>=
THRESHOLD_DROPRATE
||
dropDown
>=
THRESHOLD_DROPRATE
)
{
overload
=
true
;
System
.
out
.
println
(
"Droprate is overloaded in Segment: "
+
getSegmentID
());
System
.
out
.
println
(
"Droprate is overloaded in Segment: "
+
getSegmentID
());
}
}
}
...
...
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