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
...
@@ -133,68 +133,84 @@ public class ModelBasedSegmentDatabase
AbstractModel
getModel
(
int
segID
,
ParameterType
type
,
Boolean
isUpload
)
{
AbstractModel
getModel
(
int
segID
,
ParameterType
type
,
Boolean
isUpload
)
{
Integer
segmentID
=
new
Integer
(
segID
);
Integer
segmentID
=
new
Integer
(
segID
);
Direction
dir
=
Direction
.
DOWNLOAD
;
if
(
isUpload
)
{
dir
=
Direction
.
UPLOAD
;
}
// Check if type exists
if
(!
this
.
models
.
containsKey
(
type
))
{
if
(!
this
.
models
.
containsKey
(
type
))
{
throw
new
ConfigurationException
(
throw
new
ConfigurationException
(
"No Model is defined for "
+
type
+
"."
);
"No Model is defined for "
+
type
+
"."
);
}
}
if
(!
this
.
models
.
get
(
type
).
containsKey
(
segmentID
))
{
// Check if there is a specific model
segmentID
=
DEFAULT_SEGMENT_ID
;
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
))
{
// Check if there is a BOTH model in this
segment
throw
new
ConfigurationException
(
"No Model is defined for Type "
if
(
this
.
models
.
get
(
type
).
containsKey
(
segmentID
)
&&
this
.
models
.
get
(
type
).
get
(
segmentID
).
containsKey
(
Direction
.
BOTH
))
{
+
type
+
" and S
egment
ID
"
+
segmentID
+
"."
);
return
this
.
models
.
get
(
type
).
get
(
s
egmentID
).
get
(
Direction
.
BOTH
);
}
}
Direction
dir
=
Direction
.
DOWNLOAD
;
// 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
))
{
if
(
isUpload
)
{
return
this
.
models
.
get
(
type
).
get
(
DEFAULT_SEGMENT_ID
).
get
(
dir
);
dir
=
Direction
.
UPLOAD
;
}
}
if
(!
this
.
models
.
get
(
type
).
get
(
segmentID
).
containsKey
(
dir
))
{
// Check if there is a default BOTH model
dir
=
Direction
.
BOTH
;
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
(
throw
new
ConfigurationException
(
"No Model is defined for Type "
+
type
+
", Segment ID "
"No Model is defined for Type "
+
type
+
", Segment ID "
+
segmentID
+
" and Direction "
+
dir
+
"."
);
+
segmentID
+
" and Direction "
+
dir
+
"."
);
}
}
return
this
.
models
.
get
(
type
).
get
(
segmentID
).
get
(
dir
);
}
public
class
ModelBasedEntry
implements
FiveGTopologyDatabase
.
Entry
{
public
class
ModelBasedEntry
implements
FiveGTopologyDatabase
.
Entry
{
// How is a overload defined
// How is a overload defined
private
final
long
OVERLOAD_LATENCY
=
9999
*
Time
.
MILLISECOND
;
private
final
long
OVERLOAD_LATENCY
=
9999
*
Time
.
MILLISECOND
;
private
final
long
OVERLOAD_BANDWIDTH
=
(
long
)
0.1
;
private
final
long
OVERLOAD_BANDWIDTH
=
(
long
)
0.1
;
private
final
double
OVERLOAD_DROPRATE
=
1
;
private
final
double
OVERLOAD_DROPRATE
=
1
;
// When is a node considered overloaded
// When is a node considered overloaded
private
final
long
THRESHOLD_LATENCY
=
Time
.
SECOND
;
private
final
long
THRESHOLD_LATENCY
=
Time
.
SECOND
;
private
final
long
THRESHOLD_BANDWIDTH
=
10
;
private
final
long
THRESHOLD_BANDWIDTH
=
10
;
private
final
double
THRESHOLD_DROPRATE
=
1
;
private
final
double
THRESHOLD_DROPRATE
=
1
;
// Other storage
// Other storage
private
final
int
segment
;
private
final
int
segment
;
private
boolean
isAvailable
=
true
;
private
boolean
isAvailable
=
true
;
private
HashSet
<
MacAddress
>
hostsInSegment
=
new
HashSet
<>();
private
HashSet
<
MacAddress
>
hostsInSegment
=
new
HashSet
<>();
private
boolean
overload
;
private
boolean
overload
;
// The current metrics of this segment
// The current metrics of this segment
private
long
bandUp
;
private
long
bandUp
;
private
long
bandDown
;
private
long
bandDown
;
private
long
latUp
;
private
long
latUp
;
private
long
latDown
;
private
long
latDown
;
private
double
dropUp
;
private
double
dropUp
;
private
double
dropDown
;
private
double
dropDown
;
/**
/**
* Create a new entry for the given segment
* Create a new entry for the given segment
*
* @param segment
* @param segment
*/
*/
public
ModelBasedEntry
(
int
segment
)
{
public
ModelBasedEntry
(
int
segment
)
{
...
@@ -227,7 +243,8 @@ public class ModelBasedSegmentDatabase
...
@@ -227,7 +243,8 @@ public class ModelBasedSegmentDatabase
@Override
@Override
public
double
getDropProbability
(
boolean
isUpload
)
{
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
)
{
if
(!
isAvailable
||
overload
)
{
return
OVERLOAD_DROPRATE
;
return
OVERLOAD_DROPRATE
;
}
}
...
@@ -257,7 +274,8 @@ public class ModelBasedSegmentDatabase
...
@@ -257,7 +274,8 @@ public class ModelBasedSegmentDatabase
@Override
@Override
public
long
getBandwidth
(
boolean
isUpload
)
{
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
)
{
if
(!
isAvailable
||
overload
)
{
return
OVERLOAD_BANDWIDTH
;
return
OVERLOAD_BANDWIDTH
;
}
}
...
@@ -298,7 +316,8 @@ public class ModelBasedSegmentDatabase
...
@@ -298,7 +316,8 @@ public class ModelBasedSegmentDatabase
if
(
bandDown
<=
THRESHOLD_BANDWIDTH
if
(
bandDown
<=
THRESHOLD_BANDWIDTH
||
bandUp
<=
THRESHOLD_BANDWIDTH
)
{
||
bandUp
<=
THRESHOLD_BANDWIDTH
)
{
overload
=
true
;
overload
=
true
;
System
.
out
.
println
(
"Bandwidth is overloaded in Segment: "
+
getSegmentID
());
System
.
out
.
println
(
"Bandwidth is overloaded in Segment: "
+
getSegmentID
());
}
}
// Calc Latency
// Calc Latency
...
@@ -309,7 +328,8 @@ public class ModelBasedSegmentDatabase
...
@@ -309,7 +328,8 @@ public class ModelBasedSegmentDatabase
if
(
latUp
>=
THRESHOLD_LATENCY
||
latDown
>=
THRESHOLD_LATENCY
)
{
if
(
latUp
>=
THRESHOLD_LATENCY
||
latDown
>=
THRESHOLD_LATENCY
)
{
overload
=
true
;
overload
=
true
;
System
.
out
.
println
(
"Latency is overloaded in Segment: "
+
getSegmentID
());
System
.
out
.
println
(
"Latency is overloaded in Segment: "
+
getSegmentID
());
}
}
// Calc Droprate
// Calc Droprate
...
@@ -321,7 +341,8 @@ public class ModelBasedSegmentDatabase
...
@@ -321,7 +341,8 @@ public class ModelBasedSegmentDatabase
if
(
dropUp
>=
THRESHOLD_DROPRATE
if
(
dropUp
>=
THRESHOLD_DROPRATE
||
dropDown
>=
THRESHOLD_DROPRATE
)
{
||
dropDown
>=
THRESHOLD_DROPRATE
)
{
overload
=
true
;
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