Skip to content

araobp/service-discovery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Very simple service discovery protocol

Motivation

My RaspberryPi 3 obtains an IP address from DHCP server on my WiFi router. The IP address changes everytime I boot the Raspberry PI.

I just want a very simple service discovery protocol to find an IP address of my RaspberryPi 3 on the LAN.

Why not use a standard procotol?

I used to be a SIP (Session Initiation Protocol) expert. The protocol basically provides a mean to find serivces on the network, such as a VoIP service or a video broadcasting service. The protocol originated from MBONE project, very dependent on IP multicast and IP broadcast, but the protocol has become very complicated to support plane old telephony services...

If the scope is limited to my LAN at home, such a very complicated protocol is not necessary.

Message sequence diagram

An UDP packet with a service ID in its payload is broadcast to the LAN's broadcast IP address at a certain interval:

  Server                  Client
     |                      |
     |----- UDP 18084 ----->|
     |                      |
     |----- UDP 18084 ----->|
     |                      |
     |----- UDP 18084 ----->|
     |                      |

Source code

Server (C++)

C++ server code implementation that runs as a Linux daemon on Raspberry Pi:

=> Code

And a sample systemd service file is here:

=> Service file

Client (Kotlin)

Kotlin client code for Android smartphones:

=> Code

The GUI also shows its own IP address on its WLAN interface.

About

Very simple service discovery protocol

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published