Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pim_dm
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
pim_dm
Commits
58dd3f58
Commit
58dd3f58
authored
Feb 15, 2018
by
Pedro Oliveira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issues related with assert state machine & remove some unused code
parent
4c12b098
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
52 deletions
+14
-52
tree/assert_.py
tree/assert_.py
+5
-23
tree/metric.py
tree/metric.py
+1
-3
tree/tree_if_downstream.py
tree/tree_if_downstream.py
+6
-24
tree/tree_if_upstream.py
tree/tree_if_upstream.py
+1
-1
tree/tree_interface.py
tree/tree_interface.py
+1
-1
No files found.
tree/assert_.py
View file @
58dd3f58
...
@@ -104,10 +104,8 @@ class AssertStateABC(metaclass=ABCMeta):
...
@@ -104,10 +104,8 @@ class AssertStateABC(metaclass=ABCMeta):
def
_sendAssert_setAT
(
interface
:
"TreeInterfaceDownstream"
):
def
_sendAssert_setAT
(
interface
:
"TreeInterfaceDownstream"
):
#interface.assert_timer.set_timer(pim_globals.ASSERT_TIME)
interface
.
set_assert_timer
(
pim_globals
.
ASSERT_TIME
)
interface
.
set_assert_timer
(
pim_globals
.
ASSERT_TIME
)
interface
.
send_assert
()
interface
.
send_assert
()
#interface.assert_timer.reset()
@
staticmethod
@
staticmethod
def
rprint
(
interface
:
"TreeInterfaceDownstream"
,
msg
,
*
entrys
):
def
rprint
(
interface
:
"TreeInterfaceDownstream"
,
msg
,
*
entrys
):
...
@@ -134,11 +132,10 @@ class NoInfoState(AssertStateABC):
...
@@ -134,11 +132,10 @@ class NoInfoState(AssertStateABC):
"""
"""
@type interface: TreeInterface
@type interface: TreeInterface
"""
"""
interface
.
set_assert_state
(
AssertState
.
Winner
)
interface
.
set_assert_winner_metric
(
interface
.
my_assert_metric
())
interface
.
set_assert_winner_metric
(
interface
.
my_assert_metric
())
interface
.
set_assert_state
(
AssertState
.
Winner
)
NoInfoState
.
_sendAssert_setAT
(
interface
)
NoInfoState
.
_sendAssert_setAT
(
interface
)
#interface.assert_winner_metric = interface.assert_metric
print
(
'receivedDataFromDownstreamIf, NI -> W'
)
print
(
'receivedDataFromDownstreamIf, NI -> W'
)
...
@@ -148,12 +145,10 @@ class NoInfoState(AssertStateABC):
...
@@ -148,12 +145,10 @@ class NoInfoState(AssertStateABC):
@
staticmethod
@
staticmethod
def
receivedInferiorMetricFromNonWinner_couldAssertIsTrue
(
interface
:
"TreeInterfaceDownstream"
):
def
receivedInferiorMetricFromNonWinner_couldAssertIsTrue
(
interface
:
"TreeInterfaceDownstream"
):
interface
.
set_assert_state
(
AssertState
.
Winner
)
interface
.
set_assert_winner_metric
(
interface
.
my_assert_metric
())
interface
.
set_assert_winner_metric
(
interface
.
my_assert_metric
())
interface
.
set_assert_state
(
AssertState
.
Winner
)
NoInfoState
.
_sendAssert_setAT
(
interface
)
NoInfoState
.
_sendAssert_setAT
(
interface
)
#interface.assert_state = AssertState.Winner
#interface.assert_winner_metric = interface.assert_metric
print
(
print
(
'receivedInferiorMetricFromNonWinner_couldAssertIsTrue, NI -> W'
)
'receivedInferiorMetricFromNonWinner_couldAssertIsTrue, NI -> W'
)
...
@@ -260,9 +255,8 @@ class WinnerState(AssertStateABC):
...
@@ -260,9 +255,8 @@ class WinnerState(AssertStateABC):
@
staticmethod
@
staticmethod
def
assertTimerExpires
(
interface
:
"TreeInterfaceDownstream"
):
def
assertTimerExpires
(
interface
:
"TreeInterfaceDownstream"
):
#interface.assert_state = AssertState.NoInfo
interface
.
set_assert_state
(
AssertState
.
NoInfo
)
interface
.
set_assert_winner_metric
(
AssertMetric
.
infinite_assert_metric
())
interface
.
set_assert_winner_metric
(
AssertMetric
.
infinite_assert_metric
())
interface
.
set_assert_state
(
AssertState
.
NoInfo
)
print
(
'assertTimerExpires, W -> NI'
)
print
(
'assertTimerExpires, W -> NI'
)
...
@@ -270,13 +264,10 @@ class WinnerState(AssertStateABC):
...
@@ -270,13 +264,10 @@ class WinnerState(AssertStateABC):
def
couldAssertIsNowFalse
(
interface
:
"TreeInterfaceDownstream"
):
def
couldAssertIsNowFalse
(
interface
:
"TreeInterfaceDownstream"
):
interface
.
send_assert_cancel
()
interface
.
send_assert_cancel
()
#interface.assert_timer.stop()
interface
.
clear_assert_timer
()
interface
.
clear_assert_timer
()
#interface.assert_state = AssertState.NoInfo
interface
.
set_assert_state
(
AssertState
.
NoInfo
)
interface
.
set_assert_winner_metric
(
AssertMetric
.
infinite_assert_metric
())
interface
.
set_assert_winner_metric
(
AssertMetric
.
infinite_assert_metric
())
interface
.
set_assert_state
(
AssertState
.
NoInfo
)
print
(
'couldAssertIsNowFalse, W -> NI'
)
print
(
'couldAssertIsNowFalse, W -> NI'
)
...
@@ -330,9 +321,6 @@ class LoserState(AssertStateABC):
...
@@ -330,9 +321,6 @@ class LoserState(AssertStateABC):
assert_timer_value
=
state_refresh_interval
*
3
assert_timer_value
=
state_refresh_interval
*
3
interface
.
set_assert_timer
(
assert_timer_value
)
interface
.
set_assert_timer
(
assert_timer_value
)
#has_winner_changed = interface.assert_winner_metric.node != better_metric.node
interface
.
set_assert_winner_metric
(
better_metric
)
interface
.
set_assert_winner_metric
(
better_metric
)
if
interface
.
could_assert
():
if
interface
.
could_assert
():
...
@@ -348,21 +336,16 @@ class LoserState(AssertStateABC):
...
@@ -348,21 +336,16 @@ class LoserState(AssertStateABC):
@
staticmethod
@
staticmethod
def
assertTimerExpires
(
interface
:
"TreeInterfaceDownstream"
):
def
assertTimerExpires
(
interface
:
"TreeInterfaceDownstream"
):
LoserState
.
_to_NoInfo
(
interface
)
LoserState
.
_to_NoInfo
(
interface
)
if
interface
.
could_assert
():
interface
.
evaluate_ingroup
()
print
(
'assertTimerExpires, L -> NI'
)
print
(
'assertTimerExpires, L -> NI'
)
@
staticmethod
@
staticmethod
def
couldAssertIsNowFalse
(
interface
:
"TreeInterfaceDownstream"
):
def
couldAssertIsNowFalse
(
interface
:
"TreeInterfaceDownstream"
):
LoserState
.
_to_NoInfo
(
interface
)
LoserState
.
_to_NoInfo
(
interface
)
print
(
'couldAssertIsNowFalse, L -> NI'
)
print
(
'couldAssertIsNowFalse, L -> NI'
)
@
staticmethod
@
staticmethod
def
couldAssertIsNowTrue
(
interface
:
"TreeInterfaceDownstream"
):
def
couldAssertIsNowTrue
(
interface
:
"TreeInterfaceDownstream"
):
LoserState
.
_to_NoInfo
(
interface
)
LoserState
.
_to_NoInfo
(
interface
)
print
(
'couldAssertIsNowTrue, L -> NI'
)
print
(
'couldAssertIsNowTrue, L -> NI'
)
@
staticmethod
@
staticmethod
...
@@ -379,10 +362,9 @@ class LoserState(AssertStateABC):
...
@@ -379,10 +362,9 @@ class LoserState(AssertStateABC):
@
staticmethod
@
staticmethod
def
_to_NoInfo
(
interface
:
"TreeInterfaceDownstream"
):
def
_to_NoInfo
(
interface
:
"TreeInterfaceDownstream"
):
#interface.assert_timer.stop()
interface
.
clear_assert_timer
()
interface
.
clear_assert_timer
()
interface
.
set_assert_state
(
AssertState
.
NoInfo
)
interface
.
set_assert_winner_metric
(
AssertMetric
.
infinite_assert_metric
())
interface
.
set_assert_winner_metric
(
AssertMetric
.
infinite_assert_metric
())
interface
.
set_assert_state
(
AssertState
.
NoInfo
)
class
AssertState
():
class
AssertState
():
...
...
tree/metric.py
View file @
58dd3f58
...
@@ -45,8 +45,7 @@ class AssertMetric(object):
...
@@ -45,8 +45,7 @@ class AssertMetric(object):
def
i_am_assert_winner
(
self
,
tree_if
):
def
i_am_assert_winner
(
self
,
tree_if
):
interface_ip
=
ipaddress
.
ip_address
(
tree_if
.
get_ip
())
return
self
.
get_ip
()
==
tree_if
.
get_ip
()
return
self
.
_ip_address
==
interface_ip
@
property
@
property
def
metric_preference
(
self
):
def
metric_preference
(
self
):
...
@@ -84,6 +83,5 @@ class AssertMetric(object):
...
@@ -84,6 +83,5 @@ class AssertMetric(object):
def
state_refresh_interval
(
self
,
value
):
def
state_refresh_interval
(
self
,
value
):
self
.
_state_refresh_interval
=
value
self
.
_state_refresh_interval
=
value
def
get_ip
(
self
):
def
get_ip
(
self
):
return
str
(
self
.
_ip_address
)
return
str
(
self
.
_ip_address
)
tree/tree_if_downstream.py
View file @
58dd3f58
...
@@ -116,14 +116,11 @@ class TreeInterfaceDownstream(TreeInterface):
...
@@ -116,14 +116,11 @@ class TreeInterfaceDownstream(TreeInterface):
# Send messages
# Send messages
######################################
######################################
def
send_state_refresh
(
self
,
state_refresh_msg_received
):
def
send_state_refresh
(
self
,
state_refresh_msg_received
):
if
not
self
.
get_interface
().
is_state_refresh_enabled
():
if
self
.
lost_assert
()
or
not
self
.
get_interface
().
is_state_refresh_enabled
():
return
return
interval
=
state_refresh_msg_received
.
interval
interval
=
state_refresh_msg_received
.
interval
if
self
.
lost_assert
():
return
self
.
_assert_state
.
sendStateRefresh
(
self
,
interval
)
self
.
_assert_state
.
sendStateRefresh
(
self
,
interval
)
self
.
_prune_state
.
send_state_refresh
(
self
)
self
.
_prune_state
.
send_state_refresh
(
self
)
...
@@ -166,17 +163,18 @@ class TreeInterfaceDownstream(TreeInterface):
...
@@ -166,17 +163,18 @@ class TreeInterfaceDownstream(TreeInterface):
# Override
# Override
def
is_forwarding
(
self
):
def
is_forwarding
(
self
):
return
((
self
.
has_neighbors
()
and
not
self
.
is_pruned
())
or
self
.
igmp_has_members
())
and
not
self
.
lost_assert
()
return
((
self
.
has_neighbors
()
and
not
self
.
is_pruned
())
or
self
.
igmp_has_members
())
and
not
self
.
lost_assert
()
#return self._assert_state == AssertState.Winner and self.is_in_group()
def
is_pruned
(
self
):
def
is_pruned
(
self
):
return
self
.
_prune_state
==
DownstreamState
.
Pruned
return
self
.
_prune_state
==
DownstreamState
.
Pruned
def
lost_assert
(
self
):
#def lost_assert(self):
return
self
.
_assert_state
==
AssertState
.
Loser
# return not AssertMetric.i_am_assert_winner(self) and \
# self._assert_winner_metric.is_better_than(AssertMetric.spt_assert_metric(self))
# Override
# Override
def
nbr_connected
(
self
):
def
nbr_connected
(
self
):
self
.
_prune_state
.
new_nbr
(
self
)
# TODO resend last state refresh messages
return
# Override
# Override
def
delete
(
self
):
def
delete
(
self
):
...
@@ -185,21 +183,5 @@ class TreeInterfaceDownstream(TreeInterface):
...
@@ -185,21 +183,5 @@ class TreeInterfaceDownstream(TreeInterface):
self
.
clear_prune_timer
()
self
.
clear_prune_timer
()
self
.
clear_prune_pending_timer
()
self
.
clear_prune_pending_timer
()
def
get_metric
(
self
):
return
AssertMetric
.
spt_assert_metric
(
self
)
def
_get_winner_metric
(
self
):
'''
@rtype: SFMRAssertMetric
'''
return
self
.
_assert_metric
def
_set_winner_metric
(
self
,
value
):
assert
isinstance
(
value
,
AssertMetric
)
or
value
is
None
# todo
self
.
_assert_metric
=
value
def
is_downstream
(
self
):
def
is_downstream
(
self
):
return
True
return
True
tree/tree_if_upstream.py
View file @
58dd3f58
...
@@ -159,7 +159,7 @@ class TreeInterfaceUpstream(TreeInterface):
...
@@ -159,7 +159,7 @@ class TreeInterfaceUpstream(TreeInterface):
# Recv packets
# Recv packets
###########################################
###########################################
def
recv_data_msg
(
self
):
def
recv_data_msg
(
self
):
if
self
.
is_olist_null
()
and
not
self
.
is_prune_limit_timer_running
()
and
not
self
.
is_S_directly_conn
():
if
not
self
.
is_prune_limit_timer_running
()
and
not
self
.
is_S_directly_conn
()
and
self
.
is_olist_null
():
self
.
_graft_prune_state
.
dataArrivesRPFinterface_OListNull_PLTstoped
(
self
)
self
.
_graft_prune_state
.
dataArrivesRPFinterface_OListNull_PLTstoped
(
self
)
elif
self
.
is_S_directly_conn
()
and
self
.
get_interface
().
is_state_refresh_enabled
():
elif
self
.
is_S_directly_conn
()
and
self
.
get_interface
().
is_state_refresh_enabled
():
self
.
_originator_state
.
recvDataMsgFromSource
(
self
)
self
.
_originator_state
.
recvDataMsgFromSource
(
self
)
...
...
tree/tree_interface.py
View file @
58dd3f58
...
@@ -377,7 +377,7 @@ class TreeInterface(metaclass=ABCMeta):
...
@@ -377,7 +377,7 @@ class TreeInterface(metaclass=ABCMeta):
if
not
self
.
is_downstream
():
if
not
self
.
is_downstream
():
return
False
return
False
else
:
else
:
return
not
AssertM
etric
.
i_am_assert_winner
(
self
)
and
\
return
not
self
.
_assert_winner_m
etric
.
i_am_assert_winner
(
self
)
and
\
self
.
_assert_winner_metric
.
is_better_than
(
AssertMetric
.
spt_assert_metric
(
self
))
self
.
_assert_winner_metric
.
is_better_than
(
AssertMetric
.
spt_assert_metric
(
self
))
def
could_assert
(
self
):
def
could_assert
(
self
):
...
...
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