Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
72d78171
Commit
72d78171
authored
Jun 20, 2021
by
Pavel Vainerman
Committed by
Pavel Vainerman
Jun 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[unet-multicast]: configure refactoring
parent
26347ffb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
24 deletions
+47
-24
MulticastTransport.cc
extensions/UNetUDP/MulticastTransport.cc
+8
-1
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+14
-14
UNetExchange.h
extensions/UNetUDP/UNetExchange.h
+16
-5
unetudp-test-configure.xml
extensions/UNetUDP/tests/unetudp-test-configure.xml
+9
-3
unet-multicast-tester.cc
extensions/UNetUDP/unet-multicast-tester.cc
+0
-1
No files found.
extensions/UNetUDP/MulticastTransport.cc
View file @
72d78171
...
...
@@ -299,7 +299,14 @@ std::unique_ptr<MulticastSendTransport> MulticastSendTransport::createFromXml( U
if
(
numChan
>
0
)
ipField
<<
numChan
;
const
string
ip
=
it
.
getProp2
(
ipField
.
str
(),
"0.0.0.0"
);
const
string
ip
=
it
.
getProp
(
ipField
.
str
());
if
(
ip
.
empty
()
)
{
ostringstream
err
;
err
<<
"(MulticastSendTransport): Undefined "
<<
ipField
.
str
()
<<
" for "
<<
it
.
getProp
(
"name"
);
throw
SystemError
(
err
.
str
());
}
int
ttl
=
it
.
getPIntProp
(
"unet_multicast_ttl"
,
1
);
return
unisetstd
::
make_unique
<
MulticastSendTransport
>
(
ip
,
p
,
h
,
p
,
ttl
);
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
72d78171
...
...
@@ -66,17 +66,6 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
logserv_port
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-logserver-port"
,
it
.
getProp
(
"logserverPort"
),
getId
());
}
// определяем фильтр
s_field
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-filter-field"
);
s_fvalue
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-filter-value"
);
unetinfo
<<
myname
<<
"(init): read filter-field='"
<<
s_field
<<
"' filter-value='"
<<
s_fvalue
<<
"'"
<<
endl
;
const
string
n_field
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-nodes-filter-field"
));
const
string
n_fvalue
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-nodes-filter-value"
));
unetinfo
<<
myname
<<
"(init): read nodes-filter-field='"
<<
n_field
<<
"' nodes-filter-value='"
<<
n_fvalue
<<
"'"
<<
endl
;
int
recvTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-recv-timeout"
,
it
.
getProp
(
"recvTimeout"
),
5000
);
int
prepareTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-prepare-time"
,
it
.
getProp
(
"prepareTime"
),
2000
);
int
evrunTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-evrun-timeout"
,
it
.
getProp
(
"evrunTimeout"
),
60000
);
...
...
@@ -124,7 +113,18 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
UniXML
::
iterator
n_it
(
nodes
);
const
string
unet_transport
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-transport"
,
n_it
.
getProp
(
"unet_transport"
),
"udp"
);
// определяем фильтр
s_field
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-filter-field"
,
n_it
.
getProp
(
"filter_field"
));
s_fvalue
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-filter-value"
,
n_it
.
getProp
(
"filter_value"
));
unetinfo
<<
myname
<<
"(init): read filter-field='"
<<
s_field
<<
"' filter-value='"
<<
s_fvalue
<<
"'"
<<
endl
;
const
string
n_field
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-nodes-filter-field"
,
n_it
.
getProp
(
"nodes_filter_field"
));
const
string
n_fvalue
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-nodes-filter-value"
,
n_it
.
getProp
(
"nodes_filter_value"
));
unetinfo
<<
myname
<<
"(init): read nodes-filter-field='"
<<
n_field
<<
"' nodes-filter-value='"
<<
n_fvalue
<<
"'"
<<
endl
;
const
string
unet_transport
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-transport"
,
n_it
.
getProp
(
"unet_transport"
),
"broadcast"
);
if
(
unet_transport
==
"multicast"
)
initMulticastTransport
(
n_it
,
n_field
,
n_fvalue
,
prefix
);
...
...
@@ -847,7 +847,7 @@ void UNetExchange::initUDPTransport( UniXML::iterator n_it,
if
(
n
==
conf
->
getLocalNodeName
()
)
{
if
(
no_sender
)
if
(
no_sender
||
n_it
.
getIntProp
(
"nosedner"
)
>
0
)
{
unetinfo
<<
myname
<<
"(init): sender OFF for this node...("
<<
n_it
.
getProp
(
"name"
)
<<
")"
<<
endl
;
...
...
@@ -1121,7 +1121,7 @@ void UNetExchange::initMulticastTransport( UniXML::iterator n_it,
continue
;
}
if
(
no_sender
)
if
(
no_sender
||
n_it
.
getIntProp
(
"nosedner"
)
>
0
)
{
unetinfo
<<
myname
<<
"(init): "
<<
n_it
.
getProp
(
"name"
)
<<
" sender DISABLED."
<<
endl
;
break
;
...
...
extensions/UNetUDP/UNetExchange.h
View file @
72d78171
...
...
@@ -62,10 +62,10 @@ namespace uniset
или каждый на своём потоке. Это определяется параметром \b unet_update_strategy.
В текущей версии поддерживается два протокола для обмена udp и multicast. Какой использовать протокол
определяется в настроечной секции параметром \b unet_transport="
udp
" или \b unet_transport="multicast".
По умолчанию "
udp
".
определяется в настроечной секции параметром \b unet_transport="
broadcast
" или \b unet_transport="multicast".
По умолчанию "
broadcast
".
\code
<UNetExchange name=".." unet_transport="
udp
" />
<UNetExchange name=".." unet_transport="
broadcast
" />
\endcode
В зависимости от заданного протокола, будут использованы те или иные настройки.
...
...
@@ -100,6 +100,10 @@ namespace uniset
\note Имеется возможность задавать отдельную настроечную секцию для "списка узлов" при помощи параметра
--prefix-nodes-confnode name. По умолчанию настройка ведётся по секции <nodes>
Чтобы отключить запуск "sender", можно указать \b nosender="1" в \b <item> конкретного узла
или непосредственно в настройках \b <UNetExchange nosender="1"...>
\section pgUNetUDP_ConfMulticast Пример конфигурирования (Multicast)
По умолчанию при считывании используется \b unet_multicast_ip и \b id узла - в качестве порта.
Но можно переопределиять эти параметры, при помощи указания \b unet_multicast_port и/или \b unet_multicast_ip,
...
...
@@ -115,6 +119,9 @@ namespace uniset
В данной реализации поддерживается работа в два канала. Соответствующие настройки для второго канала имеют индекс "2".
unet_multicast_ip2, unet_multicast_port2, unet_multicast_iface2
Чтобы отключить запуск "sender", можно указать \b nosender="1" в \b <item> конкретного узла
или непосредственно в настройках \b <UNetExchange nosender="1"...>
\code
<nodes port="2809" unet_broadcast_ip="192.168.56.255">
<item ip="127.0.0.1" name="LocalhostNode" textname="Локальный узел" unet_ignore="10">
...
...
@@ -124,14 +131,18 @@ namespace uniset
</item>
<item id="3001" ip="192.168.56.10" name="Node1" textname="Node1" unet_update_strategy="evloop"
unet_multicast_ip="224.0.0.1"
unet_multicast_sender_ip="192.168.1.1"
unet_multicast_port2="3031"
unet_multicast_ip2="225.0.0.1">
unet_multicast_ip2="225.0.0.1"
unet_multicast_sender_ip2="192.168.2.1">
...
</item>
<item id="3002" ip="192.168.56.11" name="Node2" textname="Node2">
unet_multicast_ip="224.0.0.2"
unet_multicast_sender_ip="192.168.1.2"
unet_multicast_port2="3032"
unet_multicast_ip2="225.0.0.2">
unet_multicast_ip2="225.0.0.2"
unet_multicast_sender_ip2="192.168.2.2">
...
</item>
</nodes>
...
...
extensions/UNetUDP/tests/unetudp-test-configure.xml
View file @
72d78171
...
...
@@ -35,17 +35,23 @@
<nodes
port=
"2809"
unet_broadcast_ip=
"127.255.255.255"
unet_broadcast_ip2=
"badip"
>
<item
id=
"3000"
ip=
"127.0.0.1"
name=
"localhost"
textname=
"Локальный узел"
unet_ignore=
"0"
unet_port=
"3000"
unet_multicast_ip=
"224.0.0.1"
unet_multicast_sender_ip=
"0.0.0.0"
unet_multicast_ip2=
"225.0.0.1"
unet_multicast_port2=
"3030"
/>
unet_multicast_port2=
"3030"
unet_multicast_sender_ip2=
"0.0.0.0"
/>
<item
id=
"3001"
ip=
"127.0.0.1"
name=
"localhost1"
textname=
"Локальный узел"
unet_ignore=
"1"
unet_port=
"3001"
/>
<item
id=
"3002"
ip=
"192.168.56.10"
name=
"Node1"
textname=
"Node1"
unet_ignore=
"0"
unet_respond_id=
"Node1_Not_Respond_S"
unet_respond_invert=
"1"
unet_channelswitchcount_id=
"Node1_ChannelSwitchCount_AS"
unet_multicast_ip=
"224.0.0.2"
unet_multicast_sender_ip=
"0.0.0.0"
unet_multicast_ip2=
"225.0.0.2"
unet_multicast_port2=
"3032"
/>
unet_multicast_port2=
"3032"
unet_multicast_sender_ip2=
"0.0.0.0"
/>
<item
id=
"3003"
ip=
"192.168.56.11"
name=
"Node2"
textname=
"Node2"
unet_ignore=
"0"
unet_respond_id=
"Node2_Respond_S"
unet_lostpackets_id=
"Node2_LostPackets_AS"
unet_numchannel_id=
"Node2_NumChannel_AS"
unet_multicast_ip=
"224.0.0.3"
unet_multicast_sender_ip=
"0.0.0.0"
unet_multicast_ip2=
"225.0.0.3"
unet_multicast_port2=
"3033"
/>
unet_multicast_port2=
"3033"
unet_multicast_sender_ip2=
"0.0.0.0"
/>
</nodes>
<!-- ************************ Датчики ********************** -->
<sensors
name=
"Sensors"
>
...
...
extensions/UNetUDP/unet-multicast-tester.cc
View file @
72d78171
...
...
@@ -362,7 +362,6 @@ int main(int argc, char* argv[])
if
(
addr
.
isMulticast
()
&&
groups
.
empty
()
)
groups
.
push_back
(
addr
);
if
(
groups
.
empty
()
)
{
cerr
<<
"(send): Unknown multicast group address for send ..."
<<
endl
;
...
...
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