From: rtrimana Date: Fri, 15 Jul 2016 22:03:42 +0000 (-0700) Subject: Adding collision resolution entry - preserved by checking against last sequence numbe... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=commitdiff_plain;h=239ae4c4cacc2b3378634ad07c9033c57a6dc6c8 Adding collision resolution entry - preserved by checking against last sequence numbers of all clients --- diff --git a/doc/iotcloud.tex b/doc/iotcloud.tex index 24afdf1..db89d2b 100644 --- a/doc/iotcloud.tex +++ b/doc/iotcloud.tex @@ -56,7 +56,7 @@ e.g. 50 and 70, the client knows that when it sees 50, it should expect at most 50 slots in the queue and after it sees 70, it should expect 50 slots before that queue state entry slot 50 and at most 70 slots. The queue state entry slot 70 is counted as slot number 51 in the queue.} -\item Collision resolution entry: Machine id + message identifier of +\item Collision resolution entry: message identifier + machine id of a collision winner \newline {The purpose of this is to keep keep track of the winner of all the collisions until all clients have seen the particular entry.} @@ -185,7 +185,9 @@ $kv$ is a key-value entry $\tuple{k,v}$, $kv \in D$ \\ $ss$ is a slot sequence entry $\tuple{id,s_{last}}$, id + last s of a machine, $ss \in D$ \\ $qs$ is a queue state entry, $qs \in D$ \\ -$D = \{kv,ss,qs\}$ \\ +$cr$ is a collision resolution entry $\tuple{s_{col},id_{col}}$, +s + id of a machine that wins a collision, $cr \in D$ \\ +$D = \{kv,ss,qs,cr\}$ \\ $DE = \{de \mid de \in D\}$ \\ \\ $s \in SN$ is a sequence number set\\ $id$ is a machine ID\\ @@ -201,6 +203,8 @@ $sv_s = \tuple{s, E(Dat_s)} = (initially empty)} \\ \textit{$MS_c$ = set MS to save all $\tuple{id, s_{last}}$ pairs while traversing DT after a request to server (initially empty)} \\ +\textit{$SM$ = set of $\tuple{s, id}$ of all slots in a previous read +(initially empty)} \\ \textit{$max_c$ = maximum number of slots (initially $max_c > 0$)} \\ \textit{m = number of slots on client (initially $m = 0 and m \leq n$)} \\ \textit{$hmac_p$ = the HMAC value of the previous slot ($hmac_p = \emptyset$ @@ -217,20 +221,21 @@ $Slot(SL_s,s_s)= \tuple{s, sv}$ \textit{such that} $\tuple{s, sv} $SeqN(\tuple{s, sv})=s$ \\ $SlotVal(\tuple{s, sv})=sv$ \\ $Decrypt(SK_s,sv_s)=Dat_s=\tuple{s,id,hmac_p,DE,hmac_c}$ \\ -$ComputeHash(bit_s)$ is a hash function that generates hash value on $bit_s$ \\ -$ComputeHmac(bit_s,SK_s)$ is a HMAC function that generates HMAC value on $bit_s$ -based on key $SK_s$\\ $GetSeqN(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=s$ \\ $GetMacId(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=id$ \\ $GetPrevHmac(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=hmac_p$ \\ $GetCurrHmac(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=hmac_c$ \\ $GetDatEnt(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=DE$ \\ -$GetQS(de_s$ \textit{such that} $de_s \in D \land de_s = qs)=qs$ \\ -$GetSS(de_s$ \textit{such that} $de_s \in D \land de_s = ss)=ss$ \\ -$GetKV(de_s$ \textit{such that} $de_s \in D \land de_s = kv)=kv=\tuple{k,v}$ \\ +$GetKV(de_s$ \textit{such that} $de_s \in D \land de_s = kv)=\tuple{k_s,v_s}$ \\ +$GetSS(de_s$ \textit{such that} $de_s \in D \land de_s = ss)=\tuple{id,s_{last}}$ \\ +$GetQS(de_s$ \textit{such that} $de_s \in D \land de_s = qs)=qs_s$ \\ +$GetCR(de_s$ \textit{such that} $de_s \in D \land de_s = cr)=\tuple{s_s,id_s}$ \\ $GetLastSeqN(MS_s,id_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} -\in MS_s \wedge \forall \tuple{id_s, s_{s_{last}}} \in MS_s, -id = id_s$ \\ +\in MS_s \wedge \forall \tuple{id_s, s_{s_{last}}} \in MS_s, id = id_s$ \\ +$GetMachineId(SM_s,s_s)= id$ \textit{such that} $\tuple{s, id} +\in SM_s \wedge \forall \tuple{s_s, id_s} \in SM_s, s = s_s$ \\ +$GetS(\tuple{s, id})=s$ \\ +$GetId(\tuple{s, id})=id$ \\ $GetKey(\tuple{k, v})=k$ \\ $GetVal(\tuple{k, v})=v$ \\ $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} @@ -291,7 +296,7 @@ $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \State $DE_s \gets GetDatEnt(Dat_s)$ \State $de_{ss} \gets de_s$ \textit{such that} $de_s \in DE_s, de_s \in D \land de_s = ss$ -\If{$\tuple{id_{ret},s_{last_{ret}}} \neq \emptyset$} +\If{$de_{ss} \neq \emptyset$} \State $\tuple{id_{ret},s_{last_{ret}}} \gets GetSS(de_{ss})$ \Else \State $\tuple{id_{ret},s_{last_{ret}}} \gets \emptyset$ @@ -300,6 +305,21 @@ $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \EndFunction \end{algorithmic} +\begin{algorithmic}[1] +\Function{GetColRes}{$Dat_s$} +\State $DE_s \gets GetDatEnt(Dat_s)$ +\State $de_{cr} \gets de_s$ \textit{such that} $de_s \in DE_s, + de_s \in D \land de_s = cr$ +\If{$de_{cr} \neq \emptyset$} + \State $\tuple{s_{ret},id_{ret}} \gets GetCR(de_{cr})$ +\Else + \State $\tuple{s_{ret},id_{ret}} + \gets \emptyset$ +\EndIf +\State \Return{$\tuple{s_{ret},id_{ret}}$} +\EndFunction +\end{algorithmic} + \begin{algorithmic}[1] \Function{UpdateLastSeqN}{$id_s,s_s,MS_s$} \State $s_t \gets GetLastSeqN(MS_s,id_s)$ @@ -337,6 +357,17 @@ $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \EndProcedure \end{algorithmic} +\begin{algorithmic}[1] +\Procedure{CheckColRes}{$SM_s,\tuple{s_t,id_t}$}\Comment{Check $id_s$ in $SM_s$} +\State $s_t \gets GetS(\tuple{s_t,id_t})$ +\State $id_t \gets GetId(\tuple{s_t,id_t})$ +\State $id_s \gets GetMachineId(SM_s,s_t)$ +\If{$id_s \neq id_t$} + \State \Call{ReportError}{'Invalid $id_s$ for this slot update'} +\EndIf +\EndProcedure +\end{algorithmic} + \begin{algorithmic}[1] \Function{UpdateDT}{$DT_s,Dat_s$} \State $DE_s \gets GetDatEnt(Dat_s)$ @@ -361,13 +392,15 @@ $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \Function{GetKVPairs}{$s$} \State $SL_c \gets \Call{GetSlot}{s}$ \State $MS_c \gets \emptyset$ +\State $SM_{curr} \gets \emptyset$ \State $\tuple{s_{c_{max}},sv_{c_{max}}} \gets MaxSlot(SL_c)$ \State $s_{c_{max}} \gets SeqN(\tuple{s_{c_{max}},sv_{c_{max}}})$ \State $\tuple{s_{c_{min}},sv_{c_{min}}} \gets MinSlot(SL_c)$ \State $s_{c_{min}} \gets SeqN(\tuple{s_{c_{min}},sv_{c_{min}}})$ -%\For{$\{\tuple{s_c,sv_c} \mid \tuple{s_c,sv_c} \in SL_c\}$} -\For{$s_c \gets s_{c_{min}}$ \textbf{to} $s_{c_{max}}$} +\For{$s_c \gets s_{c_{min}}$ \textbf{to} $s_{c_{max}}$}\Comment{Process slots + in $SL_c$ in order} \State $\tuple{s_c,sv_c} \gets Slot(SL_c,s_c)$ + \State $SM_{curr} \gets SM_{curr} \cup \{\tuple{s_c,sv_c}\}$ \State $s_c \gets SeqN(\tuple{s_c,sv_c})$ \State $sv_c \gets SlotVal(\tuple{s_c,sv_c})$ \State $Dat_c \gets Decrypt(SK,sv_c)$ @@ -394,14 +427,25 @@ $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \If{$\tuple{id_d,s_{d_{last}}} \neq \emptyset$} \State $MS_c \gets \Call{UpdateLastSeqN}{id_d,s_{d_{last}},MS_c}$ \EndIf + \State $\tuple{s_e,id_e} \gets + \Call{GetColRes}{Dat_c}$\Comment{Handle cr} + \If{$\tuple{s_e,id_e} \neq \emptyset$} + \State $s_e \gets GetS(\tuple{s_e,id_e})$ + \State $id_e \gets GetId(\tuple{s_e,id_e})$ + \State $s_{c_{last}} \gets GetLastSeqN(MS,id_e)$ + \If{$s_{c_{last}} < s_e$} + \State $\Call{CheckColRes}{SM,\tuple{s_e,id_e}}$ + \EndIf + \EndIf \State $DT \gets \Call{UpdateDT}{DT,Dat_c}$ \EndFor +\State $SM \gets SM_{curr}$ \If{$m + |SL_c| \leq max_c$}\Comment{Check actual size against $max_c$} \State $m \gets m + |SL_c|$ \Else \State \Call{ReportError}{'Actual queue size exceeds $max_c$'} \EndIf - \State $\Call{CheckLastSeqN}{MS_c,MS}$ +\State $\Call{CheckLastSeqN}{MS_c,MS}$ \State \Return{$DT$} \EndFunction \end{algorithmic}