Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
multicast-study
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
Kirill Smelkov
multicast-study
Commits
1f4fcb1c
Commit
1f4fcb1c
authored
Apr 29, 2022
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add client and server scripts to test multicast
parents
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
client6.py
client6.py
+26
-0
server6.py
server6.py
+29
-0
No files found.
client6.py
0 → 100644
View file @
1f4fcb1c
import
argparse
import
socket
import
struct
import
sys
if
not
hasattr
(
socket
,
'SO_BINDTODEVICE'
):
socket
.
SO_BINDTODEVICE
=
25
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"multicast_group"
,
help
=
"Multicast IPv6 to use for subscription"
)
args
=
parser
.
parse_args
()
server_address
=
(
''
,
10000
)
sock
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
sock
.
bind
(
server_address
)
# on all interfaces.
sock
.
setsockopt
(
socket
.
IPPROTO_IPV6
,
socket
.
IPV6_JOIN_GROUP
,
socket
.
inet_pton
(
socket
.
AF_INET6
,
args
.
multicast_group
)
+
struct
.
pack
(
'@I'
,
0
))
try
:
while
True
:
data
,
address
=
sock
.
recvfrom
(
10240
)
print
(
data
.
decode
(
"utf-8"
))
finally
:
sock
.
close
()
server6.py
0 → 100644
View file @
1f4fcb1c
import
argparse
import
socket
import
struct
import
traceback
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"addr"
,
help
=
"IPv6 address to use for source"
)
parser
.
add_argument
(
"multicast_group"
,
help
=
"Multicast IPv6 address to use for destination"
)
args
=
parser
.
parse_args
()
print
(
args
.
addr
)
print
(
args
.
multicast_group
)
ttl
=
12
sock
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
sock
.
setsockopt
(
socket
.
IPPROTO_IPV6
,
socket
.
IPV6_MULTICAST_HOPS
,
ttl
)
sock
.
bind
((
args
.
addr
,
10000
))
try
:
while
True
:
input_msg
=
input
(
'msg --> '
)
try
:
sock
.
sendto
(
input_msg
.
encode
(
"utf-8"
),
(
args
.
multicast_group
,
10000
))
except
Exception
:
traceback
.
print_exc
()
continue
finally
:
sock
.
close
()
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