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
2d3d8f7e
Commit
2d3d8f7e
authored
Feb 13, 2018
by
Pedro Oliveira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor fixes to some state machines
parent
fd60f995
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
84 deletions
+28
-84
tree/DataPacketsSocket.py
tree/DataPacketsSocket.py
+4
-6
tree/KernelEntry.py
tree/KernelEntry.py
+2
-3
tree/downstream_prune.py
tree/downstream_prune.py
+4
-33
tree/globals.py
tree/globals.py
+1
-1
tree/tree_if_downstream.py
tree/tree_if_downstream.py
+1
-17
tree/tree_if_upstream.py
tree/tree_if_upstream.py
+10
-13
tree/tree_interface.py
tree/tree_interface.py
+5
-9
tree/upstream_prune.py
tree/upstream_prune.py
+1
-2
No files found.
tree/DataPacketsSocket.py
View file @
2d3d8f7e
...
...
@@ -5,24 +5,20 @@ from ctypes import create_string_buffer, addressof
SO_ATTACH_FILTER
=
26
ETH_P_IP
=
0x0800
# Internet Protocol packet
SO_RCVBUFFORCE
=
33
def
get_s_g_bpf_filter_code
(
source
,
group
,
interface_name
):
cmd
=
"tcpdump -ddd
\
"
(udp or icmp) and host %s and dst %s
\
"
"
%
(
source
,
group
)
result
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
bpf_filter
=
b''
FILTER
=
[]
tmp
=
result
.
stdout
.
read
().
splitlines
()
num
=
int
(
tmp
[
0
])
for
line
in
tmp
[
1
:]:
#read and store result in log file
for
line
in
tmp
[
1
:]:
print
(
line
)
#FILTER += (struct.pack("HBBI", *tuple(map(int, line.split(b' ')))), )
bpf_filter
+=
struct
.
pack
(
"HBBI"
,
*
tuple
(
map
(
int
,
line
.
split
(
b' '
))))
print
(
num
)
print
(
FILTER
)
# defined in linux/filter.h.
b
=
create_string_buffer
(
bpf_filter
)
...
...
@@ -33,6 +29,8 @@ def get_s_g_bpf_filter_code(source, group, interface_name):
# Create listening socket with filters
s
=
socket
.
socket
(
socket
.
AF_PACKET
,
socket
.
SOCK_RAW
,
ETH_P_IP
)
s
.
setsockopt
(
socket
.
SOL_SOCKET
,
SO_ATTACH_FILTER
,
fprog
)
# todo pequeno ajuste (tamanho de buffer pequeno para o caso de trafego em rajadas):
#s.setsockopt(socket.SOL_SOCKET, SO_RCVBUFFORCE, 1)
s
.
bind
((
interface_name
,
ETH_P_IP
))
return
s
tree/KernelEntry.py
View file @
2d3d8f7e
...
...
@@ -116,7 +116,8 @@ class KernelEntry:
def
recv_graft_ack_msg
(
self
,
index
,
packet
):
print
(
"recv graft ack msg"
)
self
.
interface_state
[
index
].
recv_graft_ack_msg
()
source_ip
=
packet
.
ip_header
.
ip_src
self
.
interface_state
[
index
].
recv_graft_ack_msg
(
source_ip
)
def
recv_state_refresh_msg
(
self
,
index
,
packet
):
print
(
"recv state refresh msg"
)
...
...
@@ -124,10 +125,8 @@ class KernelEntry:
metric_preference
=
packet
.
payload
.
payload
.
metric_preference
metric
=
packet
.
payload
.
payload
.
metric
mask_len
=
packet
.
payload
.
payload
.
mask_len
ttl
=
packet
.
payload
.
payload
.
ttl
prune_indicator_flag
=
packet
.
payload
.
payload
.
prune_indicator_flag
#P
assert_override_flag
=
packet
.
payload
.
payload
.
assert_override_flag
#O
interval
=
packet
.
payload
.
payload
.
interval
received_metric
=
AssertMetric
(
metric_preference
=
metric_preference
,
route_metric
=
metric
,
ip_address
=
source_of_state_refresh
,
state_refresh_interval
=
interval
)
...
...
tree/downstream_prune.py
View file @
2d3d8f7e
...
...
@@ -88,17 +88,14 @@ class NoInfo(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
interface
.
set_prune_state
(
DownstreamState
.
PrunePending
)
time
=
0
if
len
(
interface
.
get_interface
().
neighbors
)
>
1
:
time
=
pim_globals
.
J
T
_OVERRIDE_INTERVAL
time
=
pim_globals
.
J
P
_OVERRIDE_INTERVAL
#timer = interface.get_ppt().start(time)
interface
.
set_prune_pending_timer
(
time
)
print
(
"receivedPrune, NI -> PP"
)
@
staticmethod
...
...
@@ -119,9 +116,6 @@ class NoInfo(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
# todo why pt stop???!!!
#interface.get_pt().stop()
interface
.
send_graft_ack
(
source_ip
)
print
(
'receivedGraft, NI -> NI'
)
...
...
@@ -211,8 +205,6 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
# todo why prune timer and not prune pending timer???!
#interface.get_pt().stop()
interface
.
clear_prune_pending_timer
()
interface
.
set_prune_state
(
DownstreamState
.
NoInfo
)
...
...
@@ -227,16 +219,11 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
interface
.
set_prune_state
(
DownstreamState
.
Pruned
)
interface
.
set_prune_timer
(
interface
.
get_received_prune_holdtime
()
-
pim_globals
.
JP_OVERRIDE_INTERVAL
)
#pt = interface.get_pt()
#pt.start(interface.get_lpht() - pim_globals.JT_OVERRIDE_INTERVAL)
#interface.set_prune_timer(prune_holdtime - pim_globals.JT_OVERRIDE_INTERVAL)
interface
.
set_prune_timer
(
interface
.
get_received_prune_holdtime
()
-
pim_globals
.
JT_OVERRIDE_INTERVAL
)
interface
.
send_pruneecho
()
if
len
(
interface
.
get_interface
().
neighbors
)
>
1
:
interface
.
send_pruneecho
()
print
(
'PPTexpires, PP -> P'
)
...
...
@@ -260,7 +247,6 @@ class PrunePending(DownstreamStateABS):
"""
# todo understand better
#interface.get_ppt().stop()
interface
.
clear_prune_pending_timer
()
interface
.
set_prune_state
(
DownstreamState
.
NoInfo
)
...
...
@@ -293,13 +279,6 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
# todo ppt???! should be pt
#ppt = interface.get_ppt()
#if interface.get_lpht() > ppt.time_left():
# ppt.set_timer(interface.get_lpht())
# ppt.reset()
# todo nao percebo... corrigir 0
#if holdtime > 0:
if
interface
.
get_received_prune_holdtime
()
>
interface
.
remaining_prune_timer
():
interface
.
set_prune_timer
(
holdtime
)
...
...
@@ -312,8 +291,6 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
#interface.get_pt().stop()
interface
.
clear_prune_timer
()
interface
.
set_prune_state
(
DownstreamState
.
NoInfo
)
...
...
@@ -327,7 +304,6 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
#interface.get_pt().stop()
interface
.
clear_prune_timer
()
interface
.
set_prune_state
(
DownstreamState
.
NoInfo
)
interface
.
send_graft_ack
(
source_ip
)
...
...
@@ -377,11 +353,6 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream
"""
#pt = interface.get_pt()
#pt.set_timer(interface.get_lpht())
#pt.reset()
#interface.set_prune_timer(interface.get_lpht())
interface
.
set_prune_timer
(
interface
.
get_received_prune_holdtime
())
print
(
'send_state_refresh, P -> P'
)
...
...
tree/globals.py
View file @
2d3d8f7e
...
...
@@ -8,7 +8,7 @@ This module is intended to have all constants and global values for pim_dm
ASSERT_TIME
=
180
GRAFT_RETRY_PERIOD
=
3
J
T
_OVERRIDE_INTERVAL
=
3.0
J
P
_OVERRIDE_INTERVAL
=
3.0
OVERRIDE_INTERVAL
=
2.5
PROPAGATION_DELAY
=
0.5
REFRESH_INTERVAL
=
60
# State Refresh Interval
...
...
tree/tree_if_downstream.py
View file @
2d3d8f7e
...
...
@@ -27,22 +27,6 @@ class TreeInterfaceDownstream(TreeInterface):
def
__init__
(
self
,
kernel_entry
,
interface_id
):
TreeInterface
.
__init__
(
self
,
kernel_entry
,
interface_id
)
# State
#self._local_membership_state = None # todo NoInfo or Include
# Prune State
#self._prune_state = DownstreamState.NoInfo
#self._prune_pending_timer = None
#self._prune_timer = None
# Assert Winner State
#self._assert_state = AssertState.NoInfo
#self._assert_timer = None
#self._assert_winner_ip = None
#self._assert_winner_metric = None
#self.set_dipt_timer()
#self.send_prune()
##########################################
# Set state
...
...
@@ -132,7 +116,7 @@ class TreeInterfaceDownstream(TreeInterface):
# Send messages
######################################
def
send_state_refresh
(
self
,
state_refresh_msg_received
):
if
not
self
.
get_interface
().
_state_refresh_capable
:
if
not
self
.
get_interface
().
is_state_refresh_enabled
()
:
return
interval
=
state_refresh_msg_received
.
interval
...
...
tree/tree_if_upstream.py
View file @
2d3d8f7e
...
...
@@ -3,10 +3,6 @@ Created on Jul 16, 2015
@author: alex
'''
#from des.addr import Addr
#from .messages.assert_msg import SFMRAssertMsg
#from .messages.join import SFMRJoinMsg
from
.tree_interface
import
TreeInterface
from
.upstream_prune
import
UpstreamState
from
threading
import
Timer
...
...
@@ -23,11 +19,13 @@ import threading
class
TreeInterfaceUpstream
(
TreeInterface
):
def
__init__
(
self
,
kernel_entry
,
interface_id
,
is_originater
:
bool
):
TreeInterface
.
__init__
(
self
,
kernel_entry
,
interface_id
)
# Graft/Prune State:
self
.
_graft_prune_state
=
UpstreamState
.
Forward
self
.
_graft_retry_timer
=
None
self
.
_override_timer
=
None
self
.
_prune_limit_timer
=
None
# Originator state
self
.
_originator_state
=
OriginatorState
.
NotOriginator
self
.
_state_refresh_timer
=
None
self
.
_source_active_timer
=
None
...
...
@@ -35,7 +33,8 @@ class TreeInterfaceUpstream(TreeInterface):
if
self
.
is_S_directly_conn
():
self
.
_graft_prune_state
.
sourceIsNowDirectConnect
(
self
)
self
.
_originator_state
.
recvDataMsgFromSource
(
self
)
if
self
.
get_interface
().
is_state_refresh_enabled
():
self
.
_originator_state
.
recvDataMsgFromSource
(
self
)
# TODO TESTE SOCKET RECV DATA PCKTS
...
...
@@ -160,27 +159,25 @@ class TreeInterfaceUpstream(TreeInterface):
# Recv packets
###########################################
def
recv_data_msg
(
self
):
# todo check olist
if
self
.
is_olist_null
()
and
not
self
.
is_prune_limit_timer_running
()
and
not
self
.
is_S_directly_conn
():
self
.
_graft_prune_state
.
dataArrivesRPFinterface_OListNull_PLTstoped
(
self
)
if
self
.
is_S_directly_conn
():
elif
self
.
is_S_directly_conn
()
and
self
.
get_interface
().
is_state_refresh_enabled
():
self
.
_originator_state
.
recvDataMsgFromSource
(
self
)
def
recv_join_msg
(
self
,
upstream_neighbor_address
):
super
().
recv_join_msg
(
upstream_neighbor_address
)
# todo check rpf nbr
self
.
_graft_prune_state
.
seeJoinToRPFnbr
(
self
)
if
upstream_neighbor_address
==
self
.
get_neighbor_RPF
():
self
.
_graft_prune_state
.
seeJoinToRPFnbr
(
self
)
def
recv_prune_msg
(
self
,
upstream_neighbor_address
,
holdtime
):
super
().
recv_prune_msg
(
upstream_neighbor_address
,
holdtime
)
self
.
_graft_prune_state
.
seePrune
(
self
)
def
recv_graft_ack_msg
(
self
):
def
recv_graft_ack_msg
(
self
,
source_ip_of_graft_ack
):
print
(
"GRAFT ACK!!!"
)
# todo check rpf nbr
self
.
_graft_prune_state
.
recvGraftAckFromRPFnbr
(
self
)
if
source_ip_of_graft_ack
==
self
.
get_neighbor_RPF
():
self
.
_graft_prune_state
.
recvGraftAckFromRPFnbr
(
self
)
def
recv_state_refresh_msg
(
self
,
received_metric
:
AssertMetric
,
prune_indicator
:
int
):
super
().
recv_state_refresh_msg
(
received_metric
,
prune_indicator
)
...
...
tree/tree_interface.py
View file @
2d3d8f7e
...
...
@@ -66,8 +66,6 @@ class TreeInterface(metaclass=ABCMeta):
self
.
_assert_state
=
AssertState
.
NoInfo
self
.
_assert_winner_metric
=
AssertMetric
()
self
.
_assert_timer
=
None
#self._assert_winner_ip = None
#self._assert_winner_metric = None
# Received prune hold time
self
.
_received_prune_holdtime
=
None
...
...
@@ -126,8 +124,9 @@ class TreeInterface(metaclass=ABCMeta):
self
.
_assert_state
.
assertTimerExpires
(
self
)
###########################################
# Recv packets
###########################################
def
recv_data_msg
(
self
):
pass
...
...
@@ -156,8 +155,8 @@ class TreeInterface(metaclass=ABCMeta):
if
upstream_neighbor_address
==
self
.
get_ip
():
self
.
_assert_state
.
receivedPruneOrJoinOrGraft
(
self
)
def
recv_graft_ack_msg
(
self
):
pass
def
recv_graft_ack_msg
(
self
,
source_ip_of_graft_ack
):
return
def
recv_state_refresh_msg
(
self
,
received_metric
:
AssertMetric
,
prune_indicator
):
self
.
recv_assert_msg
(
received_metric
)
...
...
@@ -336,9 +335,6 @@ class TreeInterface(metaclass=ABCMeta):
interface
=
Main
.
interfaces
[
interface_name
]
return
interface
def
get_node
(
self
):
# todo: para ser substituido por get_ip
return
self
.
get_ip
()
def
get_ip
(
self
):
ip
=
self
.
get_interface
().
get_ip
()
...
...
tree/upstream_prune.py
View file @
2d3d8f7e
...
...
@@ -195,8 +195,6 @@ class Forward(UpstreamStateABC):
@type interface: TreeInterfaceUpstream
"""
#interface.cancel_ot()
interface
.
clear_override_timer
()
print
(
'seeJoinToRPFnbr, F -> F'
)
...
...
@@ -687,6 +685,7 @@ class AckPending(UpstreamStateABC):
print
(
'recvGraftAckFromRPFnbr, AP -> F'
)
class
UpstreamState
():
Forward
=
Forward
()
Pruned
=
Pruned
()
...
...
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