I'd like to talk about how to discover Kimchi peers.

Now I just talk about  discover a peer in a same network here.

I will use a local multicast subnetwork address to find peers in one network.
Choose as the kimchi multicast address, and 8000 as the port.

For cross network  that need the router support multicast, so I give up discover a peer cross network.
I will let user add the remote peers manully.

In the whole system all peers are equal. There will not be a center discover service.

We will define two kinds of multicast message Notify and Search.
the format as follow.
        #  ____________________________________________
        # |        head       |  message body   | tail |
        # |___________________|_________________|______|
        # |sizeof(messageBody)|  json message   | EOL  |
        # |___________________|_________________|______|

the flow of  discover Kimchi peers:
1. one host multicast a "search" message. in this message it tell himself information, and ask others tell their information.
Like this:
   {"search": {"domain": "kimchi-host1", "IP": "", "httpport": "8000", "httpsport": "8001"}}
   this means "hello, I'm a kimchi host, this is my information, can you tell me who you are?"
2. others received a search will response an "notify" message.
Like this:
   {"notify": {"domain": "kimchi-host1", "IP": "", "httpport": "8000", "httpsport": "8001"}}
    this tells others that "hi, I'm a kimchi host, I'm alive and this is my information"

o (user)  1 is "search"
/\  -------->                                        2 is "notify"
              | 1                        _____                ________________
    kimchi-host1 ------2-<---| DB |<----2-----|multicast listen |<--2--
                              |           |____|               |_______________|         |
                              ----------------------1------------------------------->  |
                                                                                           _____ |_____
                                                                                          |                 |
                                                                                          |  switch     |
                                                                                          |                 |
o   (user)                                                                                       |
/\  ---------               -----------------------------2----------------------- --->|
              |             |            _____                ________________           |
    kimchi-host3 ------1<---| DB |<---1------|multicast listen |<---1--|
                                        |____|                |_______________|          

we need to discuss:
1. should we support beat heart?
every kimchi host will send periodic notify to tell others himself information?

2. should we support a "quit" message?
"quit" message tell other peers, that this kimchi quit normally. others can remove this from peers list.
But the kimchi can not send "quit" when aborting abnormally.
3. Do we store the local peers information in DB?
we can collection the local peers and send them immediately when user need to discover the peers.

We will extend to support remote peers, these information need to be stored in DB.

Thanks and best regards!

Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com>
IBM Linux Technology Center