SlideShare a Scribd company logo
1 of 35
Download to read offline
IT’S ZEROCONF
Bonjour Android
Roberto Orgiu
Giuseppe Mariniello
Android Developer
Backend Developer
WHAT IS ZEROCONF?
“ZERO-CONFIGURATION NETWORKING IS A SET OF
TECHNOLOGIES THAT AUTOMATICALLY CREATES A USABLE
COMPUTER NETWORK BASED ON THE INTERNET PROTOCOL
SUITE (TCP/IP) WHEN COMPUTERS OR NETWORK
PERIPHERALS ARE INTERCONNECTED.“
WHAT IS ZEROCONF
WHAT IS ZEROCONF
“IT DOES NOT REQUIRE MANUAL
OPERATOR INTERVENTION OR SPECIAL
CONFIGURATION SERVERS.“
WHERE CAN WE FIND
ZEROCONF?
ALMOST EVERYWHERE
BONJOUR ANDROID, IT’S ZEROCONF
THINK “DIFFERENT”
▸ ZeroConf is a standard
▸ UPnP/DLNA are somehow similar, but different people and ideas
▸ Apple has its own implementation, called Bonjour (once Rendezvous)
▸ On Android, we have very different solutions for using it
APPLE OFTEN REFERS TO ZEROCONF AS
BONJOUR, GIVING THEIR OWN
DEFINITION OF THE CONCEPTS
BONJOUR ANDROID, IT’S ZEROCONF
FUN FACT
Wut? Why do you even…?
BONJOUR ANDROID, IT’S ZEROCONF
HOW DOES IT WORK?
Ehy! I am 192.168.1.50
and I have the service
DroidConService running
on port 56472!
Great! Exactly what I was looking for!
BONJOUR ANDROID, IT’S ZEROCONF
▸ No infrastructure needed
▸ Simplicity over scalability
▸ 4 areas: IP interface configuration, translation between host name and IP
address, IP multicast address allocation, service discovery
▸ Aware of network changes
▸ Still a draft
HOW DOES IT WORK?
BONJOUR ANDROID, IT’S ZEROCONF
▸ Configure netmask
▸ Allocate unique IP address
IP INTERFACE CONFIGURATION
BONJOUR ANDROID, IT’S ZEROCONF
▸ Allows hostnames to be mapped to IP addresses and back
▸ Failure proof with retry mechanism
▸ Conflict detection
TRANSLATION BETWEEN HOST NAME AND IP ADDRESS
BONJOUR ANDROID, IT’S ZEROCONF
IP MULTICAST ADDRESS ALLOCATION
▸ List which of the scopes (local, site-local, link-local) are available
▸ Select a multicast address preventing conflicts
BONJOUR ANDROID, IT’S ZEROCONF
SERVICE DISCOVERY
▸ Service must be discoverable via identifier and/or type
▸ Discovery without the use of a service-specific protocol and should complete in
a timely manner (10s of seconds)
▸ Prompt detection of new services in a timely manner (10s of seconds)
D
R
A
F
T
BONJOUR ANDROID, IT’S ZEROCONF
HOW DOES IT WORK?
▸ Each part must start with _ (underscore)
▸ The second part only allows _tcp or _udp
_ServiceType._TransportProtocolName.
List of common services goo.gl/EXh1g
BONJOUR ANDROID, IT’S ZEROCONF
WHAT ABOUT ANDROID?
▸ API FROM 4.1
▸ JMDNS FOR JAVA
▸ APPLE NATIVE (C++) IMPLEMENTATION
BONJOUR ANDROID, IT’S ZEROCONF
JMDNS FOR JAVA
▸ Easy to implement
▸ Runs on the main thread, unless we specify otherwise
▸ Distributed as JAR or via Maven repo
▸ Long start-up time
▸ Compatible with all the Android versions
BONJOUR ANDROID, IT’S ZEROCONF
WHAT ABOUT ANDROID?
▸ API FROM 4.1
▸ JMDNS FOR JAVA
▸ APPLE NATIVE (C++) IMPLEMENTATION
BONJOUR ANDROID, IT’S ZEROCONF
APPLE NATIVE (C++) IMPLEMENTATION
▸ Ported to Android by Apple
▸ Open-sourced
▸ Needs Android NDK
▸ Few projects come with it already packed in
▸ Short startup time
▸ More complex logic
BONJOUR ANDROID, IT’S ZEROCONF
WHAT ABOUT ANDROID?
▸ API FROM 4.1
▸ JMDNS FOR JAVA
▸ APPLE NATIVE (C++) IMPLEMENTATION
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API
▸ From Android 4.1, custom attributes added with 5.1 (API 21)
▸ Already asynchronous, with return on the main thread
▸ Verbose, but easy to implement
▸ Based on two steps: discovery and resolution
▸ Only one service can be resolved at a time
http://developer.android.com/training/connect-devices-wirelessly/nsd.html
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - SERVER
NsdServiceInfo serviceInfo = new NsdServiceInfo();
serviceInfo.setServiceName("DroidConService");
serviceInfo.setServiceType("_http._tcp.");
serviceInfo.setPort(randomPort);
nsdManager = Context.getSystemService(Context.NSD_SERVICE);
nsdManager.registerService(serviceInfo,
NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
Remember to unregister the service upon app closing!
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class Resolver extends NsdManager.ResolveListener {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
// here we can use our resolved service
}
};
Resolve resolveListener = new Resolve();
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class Resolver extends NsdManager.ResolveListener {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
// here we can use our resolved service
}
};
Resolve resolveListener = new Resolve();
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class SimpleDiscoveryListener extends NsdManager.DiscoveryListener {
@Override public void onDiscoveryStarted(String regType) {}
@Override public void onServiceFound(NsdServiceInfo service) {
if (service.getServiceName().contains(“DroidConService")){
nsdManager.resolveService(service, resolveListener);
}
}
@Override public void onServiceLost(NsdServiceInfo service) {}
@Override public void onDiscoveryStopped(String serviceType) {}
@Override public void onStartDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}
@Override public void onStopDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}};
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class SimpleDiscoveryListener extends NsdManager.DiscoveryListener {
@Override public void onDiscoveryStarted(String regType) {}
@Override public void onServiceFound(NsdServiceInfo service) {
if (service.getServiceName().contains(“DroidConService")){
nsdManager.resolveService(service, resolveListener);
}
}
@Override public void onServiceLost(NsdServiceInfo service) {}
@Override public void onDiscoveryStopped(String serviceType) {}
@Override public void onStartDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}
@Override public void onStopDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}};
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener();
nsdManager.discoverServices(SERVICE_TYPE,
NsdManager.PROTOCOL_DNS_SD, discoveryListener);
nsdManager.stopServiceDiscovery(discoveryListener);
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener();
nsdManager.discoverServices(SERVICE_TYPE,
NsdManager.PROTOCOL_DNS_SD, discoveryListener);
nsdManager.stopServiceDiscovery(discoveryListener);
ARE THERE BETTER
WAYS OF DOING IT?
YES, THERE ARE!
ARE THERE BETTER WAYS OF DOING IT
BONJOUR ANDROID, IT’S ZEROCONF
BETTER WAYS OF DOING IT
▸ better-zeroconf
▸ RxDNSSD
▸ RxBonjour
▸ ZeRxConf
▸ android-mdns
▸ JmDNS
▸ Apple mDNS
▸ Apple mDNS
▸ JmDNS + Android Native APIs
▸ Apple mDNS
DEMO TIME!
Q & A
CHECK THE REPO @ GITHUB.COM/ENNOVA-IT/DROIDCON-DEMO
BONJOUR ANDROID, IT’S ZEROCONF
THANKS FOR WATCHING!

More Related Content

What's hot

Kamailio World 2018: Having fun with new stuff
Kamailio World 2018: Having fun with new stuffKamailio World 2018: Having fun with new stuff
Kamailio World 2018: Having fun with new stuffOlle E Johansson
 
Packet Tracer: Nat protocol
Packet Tracer: Nat protocolPacket Tracer: Nat protocol
Packet Tracer: Nat protocolRafat Khandaker
 
Data communication part 7
Data communication part 7Data communication part 7
Data communication part 7Alex Fernandez
 
Ipo spaces calling document-v1
Ipo spaces calling document-v1Ipo spaces calling document-v1
Ipo spaces calling document-v1ManmeetShandilya2
 
X-Device Service Discovery
X-Device Service DiscoveryX-Device Service Discovery
X-Device Service DiscoveryTekObserver
 
Network Address Translation (NAT)
Network Address Translation (NAT)Network Address Translation (NAT)
Network Address Translation (NAT)Joud Khattab
 
Astricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsAstricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsOlle E Johansson
 
Cisco asa dhcp services
Cisco asa dhcp servicesCisco asa dhcp services
Cisco asa dhcp servicesIT Tech
 
WebRTC and Janus intro for FOSS Stockholm January 2019
WebRTC and Janus intro for FOSS Stockholm January 2019WebRTC and Janus intro for FOSS Stockholm January 2019
WebRTC and Janus intro for FOSS Stockholm January 2019Olle E Johansson
 
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/HeartbeatBuild HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/HeartbeatSanjay Willie
 
Network address translations
Network address translations Network address translations
Network address translations Shahzad shareef
 
SWIFT: Tango's Infrastructure For Real-Time Video Call Service
SWIFT: Tango's Infrastructure For Real-Time Video Call ServiceSWIFT: Tango's Infrastructure For Real-Time Video Call Service
SWIFT: Tango's Infrastructure For Real-Time Video Call ServiceMeng ZHANG
 
Chapter11ccna
Chapter11ccnaChapter11ccna
Chapter11ccnarobertoxe
 
NAT (network address translation) & PAT (port address translation)
NAT (network address translation) & PAT (port address translation)NAT (network address translation) & PAT (port address translation)
NAT (network address translation) & PAT (port address translation)Netwax Lab
 

What's hot (20)

Kamailio World 2018: Having fun with new stuff
Kamailio World 2018: Having fun with new stuffKamailio World 2018: Having fun with new stuff
Kamailio World 2018: Having fun with new stuff
 
Otto AI
Otto AIOtto AI
Otto AI
 
Packet Tracer: Nat protocol
Packet Tracer: Nat protocolPacket Tracer: Nat protocol
Packet Tracer: Nat protocol
 
Data communication part 7
Data communication part 7Data communication part 7
Data communication part 7
 
Ipo spaces calling document-v1
Ipo spaces calling document-v1Ipo spaces calling document-v1
Ipo spaces calling document-v1
 
X-Device Service Discovery
X-Device Service DiscoveryX-Device Service Discovery
X-Device Service Discovery
 
Nat
NatNat
Nat
 
NAT Scneario
NAT ScnearioNAT Scneario
NAT Scneario
 
Network Address Translation (NAT)
Network Address Translation (NAT)Network Address Translation (NAT)
Network Address Translation (NAT)
 
Astricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsAstricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installations
 
Cisco asa dhcp services
Cisco asa dhcp servicesCisco asa dhcp services
Cisco asa dhcp services
 
Nat pat
Nat patNat pat
Nat pat
 
WebRTC and Janus intro for FOSS Stockholm January 2019
WebRTC and Janus intro for FOSS Stockholm January 2019WebRTC and Janus intro for FOSS Stockholm January 2019
WebRTC and Janus intro for FOSS Stockholm January 2019
 
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/HeartbeatBuild HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
 
Network address translations
Network address translations Network address translations
Network address translations
 
Asterisk Deployments
Asterisk DeploymentsAsterisk Deployments
Asterisk Deployments
 
SWIFT: Tango's Infrastructure For Real-Time Video Call Service
SWIFT: Tango's Infrastructure For Real-Time Video Call ServiceSWIFT: Tango's Infrastructure For Real-Time Video Call Service
SWIFT: Tango's Infrastructure For Real-Time Video Call Service
 
Chapter11ccna
Chapter11ccnaChapter11ccna
Chapter11ccna
 
Static NAT
Static NATStatic NAT
Static NAT
 
NAT (network address translation) & PAT (port address translation)
NAT (network address translation) & PAT (port address translation)NAT (network address translation) & PAT (port address translation)
NAT (network address translation) & PAT (port address translation)
 

Similar to ZeroConf explained: What is it and how to use it on Android

Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020 Bogusz Jelinski
 
Introduction to Cordova
Introduction to CordovaIntroduction to Cordova
Introduction to CordovaRaymond Camden
 
Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...Kevin Poorman
 
Ionic Hybrid Mobile Application
Ionic Hybrid Mobile ApplicationIonic Hybrid Mobile Application
Ionic Hybrid Mobile ApplicationAl Sayed Gamal
 
Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)Giacomo Bergami
 
Cross platform mobile apps using .NET
Cross platform mobile apps using .NETCross platform mobile apps using .NET
Cross platform mobile apps using .NETJonas Follesø
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...Hafez Kamal
 
Droidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introductionDroidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introductionMichelantonio Trizio
 
Android wear SDK introduction
Android wear SDK introductionAndroid wear SDK introduction
Android wear SDK introductionTiziano Basile
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack7mind
 
6-ZeroLab_decentralized_applications-2008.pptx
6-ZeroLab_decentralized_applications-2008.pptx6-ZeroLab_decentralized_applications-2008.pptx
6-ZeroLab_decentralized_applications-2008.pptxClaudioTebaldi2
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introductionVisuality
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhoneErin Dees
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONESoftware AG
 
FRIDA 101 Android
FRIDA 101 AndroidFRIDA 101 Android
FRIDA 101 AndroidTony Thomas
 

Similar to ZeroConf explained: What is it and how to use it on Android (20)

Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020
 
Introduction to Cordova
Introduction to CordovaIntroduction to Cordova
Introduction to Cordova
 
Android
AndroidAndroid
Android
 
Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...
 
React Native
React NativeReact Native
React Native
 
Ionic Hybrid Mobile Application
Ionic Hybrid Mobile ApplicationIonic Hybrid Mobile Application
Ionic Hybrid Mobile Application
 
Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)
 
Cross platform mobile apps using .NET
Cross platform mobile apps using .NETCross platform mobile apps using .NET
Cross platform mobile apps using .NET
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
 
Droidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introductionDroidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introduction
 
Android wear SDK introduction
Android wear SDK introductionAndroid wear SDK introduction
Android wear SDK introduction
 
Webinar on Google Android SDK
Webinar on Google Android SDKWebinar on Google Android SDK
Webinar on Google Android SDK
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
 
6-ZeroLab_decentralized_applications-2008.pptx
6-ZeroLab_decentralized_applications-2008.pptx6-ZeroLab_decentralized_applications-2008.pptx
6-ZeroLab_decentralized_applications-2008.pptx
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introduction
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONE
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
 
FRIDA 101 Android
FRIDA 101 AndroidFRIDA 101 Android
FRIDA 101 Android
 
Binding android piece by piece
Binding android piece by pieceBinding android piece by piece
Binding android piece by piece
 

Recently uploaded

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Recently uploaded (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

ZeroConf explained: What is it and how to use it on Android

  • 1. IT’S ZEROCONF Bonjour Android Roberto Orgiu Giuseppe Mariniello Android Developer Backend Developer
  • 3. “ZERO-CONFIGURATION NETWORKING IS A SET OF TECHNOLOGIES THAT AUTOMATICALLY CREATES A USABLE COMPUTER NETWORK BASED ON THE INTERNET PROTOCOL SUITE (TCP/IP) WHEN COMPUTERS OR NETWORK PERIPHERALS ARE INTERCONNECTED.“ WHAT IS ZEROCONF
  • 4. WHAT IS ZEROCONF “IT DOES NOT REQUIRE MANUAL OPERATOR INTERVENTION OR SPECIAL CONFIGURATION SERVERS.“
  • 5. WHERE CAN WE FIND ZEROCONF?
  • 7. BONJOUR ANDROID, IT’S ZEROCONF THINK “DIFFERENT” ▸ ZeroConf is a standard ▸ UPnP/DLNA are somehow similar, but different people and ideas ▸ Apple has its own implementation, called Bonjour (once Rendezvous) ▸ On Android, we have very different solutions for using it
  • 8. APPLE OFTEN REFERS TO ZEROCONF AS BONJOUR, GIVING THEIR OWN DEFINITION OF THE CONCEPTS BONJOUR ANDROID, IT’S ZEROCONF FUN FACT
  • 9. Wut? Why do you even…?
  • 10. BONJOUR ANDROID, IT’S ZEROCONF HOW DOES IT WORK? Ehy! I am 192.168.1.50 and I have the service DroidConService running on port 56472! Great! Exactly what I was looking for!
  • 11. BONJOUR ANDROID, IT’S ZEROCONF ▸ No infrastructure needed ▸ Simplicity over scalability ▸ 4 areas: IP interface configuration, translation between host name and IP address, IP multicast address allocation, service discovery ▸ Aware of network changes ▸ Still a draft HOW DOES IT WORK?
  • 12. BONJOUR ANDROID, IT’S ZEROCONF ▸ Configure netmask ▸ Allocate unique IP address IP INTERFACE CONFIGURATION
  • 13. BONJOUR ANDROID, IT’S ZEROCONF ▸ Allows hostnames to be mapped to IP addresses and back ▸ Failure proof with retry mechanism ▸ Conflict detection TRANSLATION BETWEEN HOST NAME AND IP ADDRESS
  • 14. BONJOUR ANDROID, IT’S ZEROCONF IP MULTICAST ADDRESS ALLOCATION ▸ List which of the scopes (local, site-local, link-local) are available ▸ Select a multicast address preventing conflicts
  • 15. BONJOUR ANDROID, IT’S ZEROCONF SERVICE DISCOVERY ▸ Service must be discoverable via identifier and/or type ▸ Discovery without the use of a service-specific protocol and should complete in a timely manner (10s of seconds) ▸ Prompt detection of new services in a timely manner (10s of seconds) D R A F T
  • 16. BONJOUR ANDROID, IT’S ZEROCONF HOW DOES IT WORK? ▸ Each part must start with _ (underscore) ▸ The second part only allows _tcp or _udp _ServiceType._TransportProtocolName. List of common services goo.gl/EXh1g
  • 17. BONJOUR ANDROID, IT’S ZEROCONF WHAT ABOUT ANDROID? ▸ API FROM 4.1 ▸ JMDNS FOR JAVA ▸ APPLE NATIVE (C++) IMPLEMENTATION
  • 18. BONJOUR ANDROID, IT’S ZEROCONF JMDNS FOR JAVA ▸ Easy to implement ▸ Runs on the main thread, unless we specify otherwise ▸ Distributed as JAR or via Maven repo ▸ Long start-up time ▸ Compatible with all the Android versions
  • 19. BONJOUR ANDROID, IT’S ZEROCONF WHAT ABOUT ANDROID? ▸ API FROM 4.1 ▸ JMDNS FOR JAVA ▸ APPLE NATIVE (C++) IMPLEMENTATION
  • 20. BONJOUR ANDROID, IT’S ZEROCONF APPLE NATIVE (C++) IMPLEMENTATION ▸ Ported to Android by Apple ▸ Open-sourced ▸ Needs Android NDK ▸ Few projects come with it already packed in ▸ Short startup time ▸ More complex logic
  • 21. BONJOUR ANDROID, IT’S ZEROCONF WHAT ABOUT ANDROID? ▸ API FROM 4.1 ▸ JMDNS FOR JAVA ▸ APPLE NATIVE (C++) IMPLEMENTATION
  • 22. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API ▸ From Android 4.1, custom attributes added with 5.1 (API 21) ▸ Already asynchronous, with return on the main thread ▸ Verbose, but easy to implement ▸ Based on two steps: discovery and resolution ▸ Only one service can be resolved at a time http://developer.android.com/training/connect-devices-wirelessly/nsd.html
  • 23. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - SERVER NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setServiceName("DroidConService"); serviceInfo.setServiceType("_http._tcp."); serviceInfo.setPort(randomPort); nsdManager = Context.getSystemService(Context.NSD_SERVICE); nsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener); Remember to unregister the service upon app closing!
  • 24. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class Resolver extends NsdManager.ResolveListener { @Override public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {} @Override public void onServiceResolved(NsdServiceInfo serviceInfo) { // here we can use our resolved service } }; Resolve resolveListener = new Resolve();
  • 25. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class Resolver extends NsdManager.ResolveListener { @Override public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {} @Override public void onServiceResolved(NsdServiceInfo serviceInfo) { // here we can use our resolved service } }; Resolve resolveListener = new Resolve();
  • 26. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class SimpleDiscoveryListener extends NsdManager.DiscoveryListener { @Override public void onDiscoveryStarted(String regType) {} @Override public void onServiceFound(NsdServiceInfo service) { if (service.getServiceName().contains(“DroidConService")){ nsdManager.resolveService(service, resolveListener); } } @Override public void onServiceLost(NsdServiceInfo service) {} @Override public void onDiscoveryStopped(String serviceType) {} @Override public void onStartDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); } @Override public void onStopDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); }};
  • 27. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class SimpleDiscoveryListener extends NsdManager.DiscoveryListener { @Override public void onDiscoveryStarted(String regType) {} @Override public void onServiceFound(NsdServiceInfo service) { if (service.getServiceName().contains(“DroidConService")){ nsdManager.resolveService(service, resolveListener); } } @Override public void onServiceLost(NsdServiceInfo service) {} @Override public void onDiscoveryStopped(String serviceType) {} @Override public void onStartDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); } @Override public void onStopDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); }};
  • 28. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener(); nsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, discoveryListener); nsdManager.stopServiceDiscovery(discoveryListener);
  • 29. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener(); nsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, discoveryListener); nsdManager.stopServiceDiscovery(discoveryListener);
  • 30. ARE THERE BETTER WAYS OF DOING IT?
  • 31. YES, THERE ARE! ARE THERE BETTER WAYS OF DOING IT
  • 32. BONJOUR ANDROID, IT’S ZEROCONF BETTER WAYS OF DOING IT ▸ better-zeroconf ▸ RxDNSSD ▸ RxBonjour ▸ ZeRxConf ▸ android-mdns ▸ JmDNS ▸ Apple mDNS ▸ Apple mDNS ▸ JmDNS + Android Native APIs ▸ Apple mDNS
  • 34. Q & A CHECK THE REPO @ GITHUB.COM/ENNOVA-IT/DROIDCON-DEMO
  • 35. BONJOUR ANDROID, IT’S ZEROCONF THANKS FOR WATCHING!