Introduction

This text is not about YourRadio, it's about its backend: network of taste (not). YourRadio is a simple command line frontend for not and its code should be straight forward. This text is a technical overview and is only understandable by programmers.

What is a not?

not is a peer-to-peer network. Every client in the network holds a playlist wich is a list of ContendUnifiers and its points. In the network there is a a difference define between two playlists. The difference between playlist p1 and p2 is:

set_equalContend = ContendUnifiers equal in p1 and p2
diff = sum(abs(set_equalContend_p1.points - set_equalContend_p2.points))/count(set_equalContend)

see: int com.netoftaste.util.PlayListOperator.difference(PlayList,PlayList)

the definition of a difference allows to sort the network. In a sorted network every Client is connected to a number (Global.get().setMaxConnections(int)) of other Clients (called neighbors) which have a minimal difference to the Client. The Client knows the playList of its neighbor (they are exchanged at connect). The Client can then build a set of ContendUnifiers which are known by its neighbors but not by him. This Contend can then be downloaded (in yourradio this is done by LimeWire). This way the files are slowly spread over the network. The higher the point of a ContendUnifier the faster. If a Contend in the network is corrupt, its spreading is stopt.

How is the network sorted?

At the start of every Client, the Client is connected to some nodes somewhere in the network.

           (7)----(1)----(2)---(3) 
                   Ś
      (4)-------(you)----(5)----(8)
                  Ś
                 (6)

The client (you) sends a proposePing every 5 minutes (NewConnectionThread) to all its Neighbors. Every neighbor know the playlist of you and its neighbors. Every neighbor callculates the difference between you.playlist and all of its neighbors playlists and send the info (NodeUnifier: ip,port,name,id) about the best (deepest difference) back to you (ProposePongMessage). If a propose made by a neighbor is better then the worst connection holded by you, you disconnects from worst and connects to the propsed Node. Over time this sorts the network, not global perfect, but good enough.

lets make an example:
node    difference btw node and (you)
1       10
2       13
3       1
4       40
5       12
6       5
7       14
8       14
after a propose ping
1 sends back node 2 diff 13
4 sends back null
5 sends back node 8 diff 14
6 sends back null
node 2 is better then worst node 4 so (you) will disconnect from 4 and connect to 2

            (7)----(1)-----(2)----(3)
                    Ś     /
                     \   /
   (4)               (you)----(5)----(8)
                       Ś
                      (6)

now the worst connection has a difference of 13 wich is better than the connection with node 8. After 5 minutes this is done again for ever. (at the next run you will connect to 3 and disconnect from 2).