Distributed Systems: How to connect your real-time applications
-
Upload
jaime-martin-losa -
Category
Software
-
view
163 -
download
3
Transcript of Distributed Systems: How to connect your real-time applications
![Page 1: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/1.jpg)
Distributed Systems: How to connect your real-time applications
UsingCPP 24/11/2016
Jaime Martin LosaCTO eProsima
[email protected]+34 607 91 37 45
www.eProsima.com
![Page 2: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/2.jpg)
Agenda
Introduction– DDS– Architecture– Shapes Demo
Hello World– eProsima Fast RTPS – Open Source (Apache 2.0)– RTI Connext DDS - Comercial
Modern CPP API
![Page 3: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/3.jpg)
Introduction and Background
![Page 4: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/4.jpg)
Introduction: Everything is distributed
Enterprise Internet Internet of Things Cloud Computing Industry 4.0 …
Next-generation systems needs: Scalability Integration & Evolution Robustness & Availability Performance Security
![Page 5: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/5.jpg)
“Real World” Systems are integrated using a Data Model Grounded on the “physics” of the problem domain
– Tied to the nature of the sensors and real objects in the system (vehicles, device types, …)
Provides governance across disparate teams & organizations– The “N^2” integration problem is reduced to a “N” problem
Increased decoupling from use-cases and components– Avoids over constraining applications
Open, Evolvable, Platform-Independent– The use-cases, algorithms might change between missions or versions of
the system
© 2010 Real-Time Innovations, Inc.
Realizing this data-model requires a middleware infrastructure
App AppApp
![Page 6: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/6.jpg)
Challenge
Everything is connected, and we should enable communication between the different nodes.
And this means:– Common protocols– Common Data Types– Known interfaces– Different QoS over different datalinks and
performance requirements.– Different comunications patterns.– Broad platform and programming language support.– Good Data Models!– …
![Page 7: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/7.jpg)
DDS: Standards-based Integration Infrastructure for Critical Applications
Data Centric
StreamingData Sensors Events
Real-TimeApplications
EnterpriseApplications Actuators
![Page 8: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/8.jpg)
Family of Specifications
![Page 9: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/9.jpg)
Broad Adoption
Vendor independent– API for portability– Wire protocol for interoperability
Multiple implementations– 10 of API– 8 support RTPS
Heterogeneous– C, C++, Java, .NET (C#, C++/CLI)– Linux, Windows, VxWorks, other
embedded & real time� Loosely coupled
![Page 10: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/10.jpg)
DDS adopted by key programs in Europe
European Air Traffic Control– DDS proposed for interoperate
ATC centers Spanish Army
– DDS is mandated for C2 Interoperability (ethernet, radio & satellite)
UK Generic Vehicle Architecture– Mandates DDS for vehicle
comm.– Mandates DDS-RTPS for
interop.
![Page 11: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/11.jpg)
US-DoD mandates DDS for data-distribution
DISR (formerly JTA)– DoD Information Technology
Standards Registry US Navy Open Architecture Army, OSD
– UCS, Unmanned Vehicle Control
SPAWAR NESI– Net-centric Enterprise
Solutions for Interoperability – Mandates DDS for Pub-Sub
SOA
![Page 12: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/12.jpg)
RTPS Adoption
ROS (Robotic Operating System)
FIWARE– EU R&D Software Platform
Many Drone Companies– 3D Robotics– Magma UAVs– …
![Page 13: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/13.jpg)
DDS Architecture
![Page 14: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/14.jpg)
DDS
DDS (Data Distribution Service for Real-Time Systems) is a OMG specification for a pub/sub data centric model (DCPS, Data Centric Publish/Subscribe) for Real-Time data comms in distributed systems.
DDS is a networking middleware that:– Simplifies and Standardizes data flows in distributed real-time
systems. – Provides robust comms (no single point of failure) and efficient
(minimum latency)– Provides all kind of QoS to shape the data flows and deliver
predictable results.
![Page 15: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/15.jpg)
DDS
DDS uses the concept of Global Data Space. In this Space we define topics of data, and the publishers publish samples of these topics. DDS distributes these samples to all the subscribers of those topics. Any node can be a publisher or a subscriber.
![Page 16: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/16.jpg)
Why DDS? Decoupled model
Space (location)– Automatic Discovery ensures network topology independence
Redundancy:– It is possible to configure redundant publishers and subscribers,
primary/secundary and takeover schemas supported Time:
– The reception of data does not need to be synchronous with the writing. A subscriber may, if so configured, receive data that was written even before the subscriber joined the network.
Platform:– Applications do not have to worry about data representation, processor
architecture, Operating System, or even programming language on the other side
Implementation:– DDS Protocol is also an standard. Different implementations
interoperate.
![Page 17: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/17.jpg)
Why DDS? Fully configurable
QoS PolicyDURABILITY
HISTORY
READER DATA LIFECYCLE
WRITER DATA LIFECYCLE
LIFESPAN
ENTITY FACTORY
RESOURCE LIMITS
RELIABILITY
TIME BASED FILTER
DEADLINE
CONTENT FILTERS
Vola
tility
User Q
oS
Del
iver
y
PresentationR
edundancy
Infr
astr
uctu
re
Transport
QoS PolicyUSER DATA
TOPIC DATA
GROUP DATA
PARTITION
PRESENTATION
DESTINATION ORDER
OWNERSHIP
OWNERSHIP STRENGTH
LIVELINESS
LATENCY BUDGET
TRANSPORT PRIORITY
![Page 18: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/18.jpg)
DDS Infrastructure
Standard API for portability.
RTPS can be implemented over any transport
No central Broker/Service
Different Comm channel per topic
![Page 19: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/19.jpg)
Quality of Service: QoS
The DDS Model
Domain Participant
DataReader
Node
Subscriber
Data Domain
Subscriber
DataWriter
DataWriter
DataReader
DataReader
DataWriter
Publisher
Topic
Publisher
Topic Topic
![Page 20: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/20.jpg)
Topics, Instances and Keys
Topic: A set of similar objects, sharing a common Data Type
Instance: A particular object of the set Key: Fields of the Data Type to identify an
object.Topic: RadarTrack
Key: Flight ID
InstanceFlight ID=
MAD-BER57
InstanceFlight ID=
PAR-BER89
InstanceFlight ID=
PAR-BER89
Qos Applied by Instance.
![Page 21: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/21.jpg)
Demo
const long STR_LEN=24;struct ShapeType { string<MSG_LEN> color; //@key long x; long y; long shapesize;};
• 3 Topics: • Square, Circle,
Triangle• Color is the KEY
![Page 23: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/23.jpg)
Fast RTPS Hands On:A Hello World
![Page 24: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/24.jpg)
Hands-on Example (C++)
TypeDefinition
MyType.idl
fastrtpsgen
MyType.h
MyTypePubSubTypes.cMyTypePublisher.cxx
MyTypeSubscriber.cxx
MyType.sln
Publisher Subscriber.exe
Three minutes to a running app!!1. Define your data2. Create your project3. Build4. Run: publisher subscriber
compiler
![Page 25: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/25.jpg)
Example #1 - Hello World
We will use this data-type :
const long MSG_LEN=256;struct HelloMsg { string<MSG_LEN> user; //@key string<MSG_LEN> msg;};
![Page 26: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/26.jpg)
Generate type support (for C++) [Windows]
Look at the directory you should see:– solution-x64Win64VS2015.sln– And Several other files…
Open the Solution:
Compile from visual studio
fastrtpsgen HelloMsg.idl -example x64Win64VS2015\ -replace -ppDisable
![Page 27: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/27.jpg)
Execute the program [Windows]
C++:– On one window run:
bin\x64Win64VS2015\HelloMsgPublisherSubscriberd.exe publisher
– On another window run: bin\x64Win64VS2015\HelloMsgPublisherSubscriberd.exe subscriber
You should see the subscribers getting an empty string…
![Page 28: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/28.jpg)
Writting some data
Modify HelloMsgPublisher.cxx:
/* Main loop */do{if(ch == 'y'){
st.msg() = std::string("Hello using cpp ") + std::to_string(msgsent);
mp_publisher->write(&st); ++msgsent;
cout << "Sending sample, count=" << msgsent << ",send another sample?(y-yes,n-stop): ";
}
![Page 29: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/29.jpg)
How to Get Data? (Listener-Based)
// Listener codevoid HelloMsgSubscriber::SubListener::onNewDataMessage(Subscriber* sub){
// Take dataHelloMsg st;
if(sub->takeNextData(&st, &m_info)){
if(m_info.sampleKind == ALIVE){
// Print your structure data here.++n_msg;cout << "Sample received, count=" << n_msg <<
endl;cout << " " << st.msg() << endl;
}}
}
![Page 30: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/30.jpg)
RTI Connext DDSHands On:
A Hello World
![Page 31: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/31.jpg)
Hands-on Example (C++)
TypeDefinition
MyType.idl
rtiddsgen
MyType.h
MyTypeSupport.c MyTypePublisher.cpp
MyTypeSubscriber.cpp
MyType.sln
Publisher.exe Subscriber.exe
Three minutes to a running app!!1. Define your data2. Create your project3. Build4. Run: publisher subscriber
compiler
![Page 32: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/32.jpg)
Example #1 - Hello World
We will use this data-type :
const long MSG_LEN=256;struct HelloMsg { string<MSG_LEN> user; //@key string<MSG_LEN> msg;};
![Page 33: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/33.jpg)
Generate type support (for C++) [Windows]
Look at the directory you should see:– HelloMsg-64-vs2010.sln– And Several other files…
Open the Solution:HelloMsgPublisher.cxx
Compile from visual studio
rtiddsgen HelloMsg.idl -language C++ -example x64Win64VS2010\ -replace -ppDisable
![Page 34: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/34.jpg)
Execute the program [Windows]
C++:– On one window run:
objs\i86Win32VS2005\HelloMsgPublisher.exe– On another window run:
objs\i86Win32VS2005\HelloMsgSubscriber.exe Java
– On one window run: gmake –f makefile_hello_i86Win32jdk HelloMsgPublisher
– On another window run: gmake –f makefile_hello_i86Win32jdk HelloMsgSubscriber
You should see the subscribers getting an empty string…
![Page 35: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/35.jpg)
Writting some data
Modify HelloMsg_publisher.cxx:
/* Main loop */for (count=0; (sample_count == 0) || (count < sample_count); ++count) {
printf("Writing HelloMsg, count %d\n", count);
/* Modify the data to be sent here */sprintf(instance->user,"%s","eProsima");sprintf(instance->msg,"Writing HelloMsg, user eProsima, count %d",count);retcode = HelloMsg_writer->write(*instance, instance_handle);
![Page 36: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/36.jpg)
Writting some data (performance tip)
Modify HelloMsg_publisher.cxx:
/* For a data type that has a key, if the same instance is going to be written multiple times, initialize the key here and register the keyed instance prior to writing */sprintf(instance->user,"%s","eProsima");
instance_handle = HelloMsg_writer->register_instance(*instance);
/* Main loop */for (count=0; (sample_count == 0) || (count < sample_count); ++count) {
printf("Writing HelloMsg, count %d\n", count);
/* Modify the data to be sent here */sprintf(instance->msg,"Writing HelloMsg, user eProsima, count %d",count);retcode = HelloMsg_writer->write(*instance, instance_handle);
![Page 37: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/37.jpg)
Example: Publication
// Entities creationDomainParticipant participant = TheParticipantFactory->create_participant(
domain_id, participant_qos, participant_listener);
Publisher publisher = domain->create_publisher(publisher_qos, publisher_listener);
Topic topic = domain->create_topic("MyTopic", "MyType", topic_qos, topic_listener);
DataWriter writer = publisher->create_datawriter( topic, writer_qos, writer_listener);
MyTypeDataWriter twriter = MyTypeDataWriter::narrow(writer);
MyType my_instance;twriter->write(my_instance);
![Page 38: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/38.jpg)
Example: Subscription
// Entities creationSubscriber subscriber = domain->create_subscriber( subscriber_qos, subscriber_listener);
Topic topic = domain->create_topic( "MyTopic", "MyType", topic_qos, topic_listener);
DataReader reader = subscriber->create_datareader( topic, reader_qos, reader_listener);
// Use listener-based or wait-based access
![Page 39: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/39.jpg)
How to Get Data? (Listener-Based)
// Listener codeMyListener::on_data_available( DataReader reader ){ MyTypeSeq received_data; SampleInfoSeq sample_info; MyTypeDataReader treader = TextDataReader::narrow(reader); treader->take( &received_data, &sample_info, …) // Use received_data printf("Got: %s\n", received_data[0]->contents);}
![Page 40: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/40.jpg)
DDS Modern CPP
UsingCPP Conference 23/11/2016
Jaime Martin LosaCTO eProsima
[email protected]+34 607 91 37 45
www.eProsima.com
![Page 41: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/41.jpg)
Modern CPP DDS API
OMG Spec:– ISO/IEC C++ 2003 Language DDS PSM
C++03 with support for some C++11 features
![Page 42: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/42.jpg)
Example Modern CPP: DataWriter
try {// ================== DataWriter ===================DomainId id = 0;DomainParticipant dp(id);pub::qos::PublisherQos pqos;pqos << policy::Partition("Tracks");pub::Publisher pub(dp, pqos);topic::qos::TopicQos tqos;
tqos << policy::Reliability::Reliable()<< policy::Durability::Transient()<< policy::History::KeepLast(10)<< policy::TransportPriority(14);
dds::topic::Topic<RadarTrack> topic(dp, "TrackTopic", tqos);
pub::qos::DataWriterQos dwqos(tqos);
pub::DataWriter<RadarTrack> dw(pub, topic, dwqos);RadarTrack track("alpha", 100, 200);
dw.write(track);// ordw << track;
}catch (const dds::core::Exception& e) {}
![Page 43: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/43.jpg)
Example Modern CPP: DataReader
try {// ================== DataReader===================DomainId id = 0;DomainParticipant dp(id);sub::qos::SubscriberQos sqos;
sqos << policy::Partition("Tracks");
sub::Subscriber sub(dp, sqos);topic::qos::TopicQos tqos = dp.default_topic_qos();
tqos << policy::Reliability::Reliable()<< policy::Durability::Transient()<< policy::History::KeepLast(10)<< policy::TransportPriority(14);
dds::topic::Topic<RadarTrack> topic(dp, "TrackTopic", tqos);sub::qos::DataReaderQos dwqos(tqos);sub::DataReader<RadarTrack> dr(sub, topic, drqos);
std::vector< Samples<RadarTrack> > samples(MY_MAX_LEN);dr.read(samples.begin(), MY_MAX_LEN);
}catch (const dds::core::Exception& e) {}
![Page 45: Distributed Systems: How to connect your real-time applications](https://reader034.fdocuments.us/reader034/viewer/2022042907/588799ad1a28ab5b1a8b66e5/html5/thumbnails/45.jpg)
Want to know more?
www.eProsima.com
Youtube: https://www.youtube.com/user/eprosima
Mail: [email protected] Phone: +34 607913745
Twitter: @jaimemartinlosa http://es.slideshare.net/JaimeMartin-eProsima