Hi Andrew,
>>>>>> I'd have to tweek this since packets *can* arrive out of order
>>>>>> (within
>>>>>> contraints) in the normal course of operation. And, you'd also have
>>>>>> to consider the case of re-requesting a "lost packet" (what counter
>>>>>> value does it merit?).
>>>>>
>>>>> Use the same counter value it was originally sent with.
>>>>
>>>> Which means the "counter value" (avoiding the use of the term
>>>> "sequence number") checking has to be done upstream of the
>>>> "replay prevention" logic.
>>>
>>> In simple terms they are the same test.
>>
>> No. They address different issues.
>>
>> The "sequence number" of a packet determines its place in the
>> "source stream". I.e., the contents of packets bearing the
>> sequence numbers N-1, N, N+1 are "played"/"displayed" in
>> exactly that sequence. (similar arguments apply to the
>> sequence of "control messages")
>>
>> The "counter value(s)" exist solely to prevent replay attacks.
>
> The same counter will do both jobs. If you get N 3 times you keep the
> first and throw away the other two.
Server wants to send a control message to that client.
What value does it use for "sequence number" (which you
claim shall be equivalent to "replay counter value")?
Remember, N-1, N and N+1 are already spoken for...
Then, send a control message to some *other* client...
And, eventually get around to emitting packet N+2...
Client #2 never sees the control message that was
directed to Client #1. So, it doesn't know that
the value you chose for the "sequence counter"
was NOT related to the actual sequencing of the
source content. *It* thinks it has lost a packet!
(because you have opted to hijack the "sequence
number" functionality for "replay prevention" -- of
ALL MESSAGES from the server!)
>>> In a simple system you are
>>> probably discarding packets after the missing packet, more sophisticated
>>> systems can queue the packets.
>>
>> I *never* drop a packet -- unless its deadline has passed
>> (stale data). If I receive 3, 8, 5, 7, 2... then I enqueue
>> them so that *when* they are supposed to be "played", they
>> are ready and waiting.
>
> You drop on power down. Every body does. Recovery by requesting a
> retransmission.
When a client is off, it doesn't exist. Powering up can't
be as simple as requesting retransmission because a
rogue can replay a stale packet and you wouldn't KNOW
that it wasn't "current".
I.e., powering up has to be a controlled protocol
before a client joins the "mesh".
Yup. So how many should I be able to track? Remember, this
isn't a PC. It's an appliance. Limited resources. Low
cost (e.g., the audio client is ~2 cu in -- CPU, network interface,
power supply, D/AC, audio amplifier, memory, etc. -- and costs
less than $20). I don't have "surplus" horsepower, memory,
etc. E.g., 100KB of RAM for *everything* -- the RTOS, process
control blocks, pushdown stacks, CODEC, control system, error
handling, decoding buffers, communications system, signal
processing, etc.
Should I set aside 2KB of that *just* for "replay counters"?
1KB? 3KB? Will "16 bytes" be *all* that is required to
track the state of a "communication path"? Or, will it
also need to record an associated unicast/multicast address?
Or "client ID"?
I.e., if I have to number messages, then I need to be able to
control the number of nodes with which I must interact. This
means another protocol (and the resources to implement it).
My current implementation doesn't have that "problem" (but
is insecure/vulnerable)
>> Every "communication pair" -- i.e., (sender,receiver) -- that
>> is active (or POTENTIALLY active) would need such a counter
>> in each receiver (I think you can lump all of the "receivers"
>> for a particular sender into a single "sender-side" counter).
>
> Only if it is a multi-drop (like a radio broadcast) and everybody
> listens to everything.
The server(s) broadcast source content. Clients pick the packets
associated with whichever source "channels" they want (based on what
they have previously been *told* to want! -- from control messages)
and keep track of what they *need* to satisfy their deadlines.
If they think they have missed a packet, they request it (from
a peer since requesting from the server would scale poorly). If
they think a packet that they need wont arrive in time, they
begin planning for its absence (so there are no abrupt
discontinuities in "playback")
Since all of the clients (plus the servers) represent a single
cooperating "system", they are constantly talking to each other
(exchanging performance statistics, synchronizing clocks,
rerequesting dropped/corrupt packets, etc)
Having all of this intercommunication be BROADCAST would
quickly swamp the network. So exchanges between peers
are typically unicast (though some of the discovery
protocols use multicast/broadcast)
If client 1 and client 2 are to talk to each other, they
surely can't use the same "sequence counter" that the
server was using to talk to all of them -- since the
server could be changing it "as they speak".
Likewise, client 2 and client 3 can't use the counter
that client 1 and 32 are using.
>> E.g., if a particular client subscribes to two source streams
>> provided by two different servers, then it must maintain a
>> "replay counter" for each of those "connections" -- in
>> addition to the two "sequence counters" for those two *streams*.
>
> Correct.
And, by extension, to any (sender,receiver) pair -- any
communication path that could exist.
>> If control is provided by another server, then that adds
>> a third replay counter that th client must track.
>>
>> Additionally, any peer relations that it relies upon would
>> require counters -- one for each peer. (I *think* you
>> only need to have a "receiver" counter for each such
>> relationship... I suspect a single "sender" counter could
>> be shared among all OUTBOUND connections from the client).
>
> See above
See above. :>
>> Without the security burdens, I currently can accommodate
>> an unlimited number of peers -- I don't have to maintain
>> *any* state for these connections as I can consider them
>> "temporary"/transitory (i.e., I don't even have to
>> track them in ARP cache). All I have to do is make sure
>> my "sequence count" can't wrap in the TTL of a packet on
>> the wire...
>>
>> If I have to carry lots of state for each potential connection,
>> then I need to develop a protocol whereby each client can
>> establish -- and register -- the peer relationships that
>> it will track going forward. And, a mechanism for reseeding
>> those relationships over time (.e., when clients are powered
>> up/down or move to alternate "source subscriptions")
>
> This depends on the level of reliability your network needs. Does it
> matter to your clients that they get an entire song?
Does it matter if the people in YOUR part of the building hear
the evacuation announcement?