From: rtrimana Date: Tue, 9 Aug 2016 16:43:42 +0000 (-0700) Subject: Adding more error messages for slots range X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5e2908a0686e5dc0b415e2f2a77af7ffe1f50e20;p=iotcloud.git Adding more error messages for slots range --- diff --git a/doc/iotcloud.tex b/doc/iotcloud.tex index 9e213b3..b96f391 100644 --- a/doc/iotcloud.tex +++ b/doc/iotcloud.tex @@ -200,6 +200,7 @@ $Dat_s = \tuple{s,id,hmac_p,DE,hmac_c}$ \\ $slot_s = \tuple{s, E(Dat_s)} = \tuple{s, E(\tuple{s,id,hmac_p,DE,hmac_c})}$ \\ \\ \textbf{States} \\ +\textit{$d$ = delta between the last $s$ recorded and the first $s$ received} \\ \textit{$id_{self}$ = machine Id of this client} \\ \textit{$max_g$ = maximum number of slots (initially $max_g > 0$)} \\ \textit{m = number of slots stored on client (initially $m = 0$)} \\ @@ -258,6 +259,8 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \wedge \forall \tuple{id_s, s_{s_{last}}} \in MS_s, s_{last} \leq s_{s_{last}}$ \\ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \wedge \forall \tuple{s_s, id_s} \in CR_s, s \leq s_s$ \\ +$MaxSMSeqN(SM_s)= s$ \textit{such that} $\tuple{s, id} \in SM_s + \wedge \forall \tuple{s_s, id_s} \in SM_s, s \geq s_s$ \\ \begin{algorithmic}[1] \Procedure{Error}{$msg$} @@ -394,13 +397,13 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \end{algorithmic} \begin{algorithmic}[1] -\Procedure{CheckLastSeqN}{$MS_s,MS_t$} +\Procedure{CheckLastSeqN}{$MS_s,MS_t,d$} \For {$\tuple{id, s_t}$ in $MS_t$}\Comment{Check $MS_t$ based on the newer $MS_s$} \State $s_s \gets MS_s[id]$ - \If{$s_s = \emptyset$} - \Call{Error}{'No $s$ for machine $id$'} + \If{$d \land s_s = \emptyset$} + \State \Call{Error}{'Missing $s$ for machine $id$'} \ElsIf{$id = id_{self}$ and $s_s \neq s_t$} - \State \Call{Error}{'Invalid last $s$ for this machine'} + \State \Call{Error}{'Invalid last $s$ for this machine'} \ElsIf{$id \neq id_{self}$ and $s_{s_{last}} < s_{t_{last}}$} \State \Call{Error}{'Invalid last $s$ for machine $id$'} \Else @@ -427,22 +430,25 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \end{algorithmic} \begin{algorithmic}[1] -\Procedure{CheckSlotsRange}{$|SL_s|,s_{s_{min}},s_{s_{max}}$} +\Function{ValidSlotsRange}{$|SL_s|,s_{s_{min}},s_{s_{max}}$} \State $sz_{SL} \gets s_{s_{max}} - s_{s_{min}} + 1$ \If{$sz_{SL} \neq |SL_s|$} - \State \Call{Error}{'Sequence numbers range does not match slots set'} + \State \Call{Error}{'Sequence numbers range does not match actual set'} \EndIf -\State $s_{min} \gets MinLastSeqN(MS)$ -\State $s_{max} \gets MaxLastSeqN(MS)$ -\If{$s_{s_{min}} \leq s_{min}$} - \State \Call{Error}{'Server sent old slot'} +\State $s_{s_{last}} \gets MaxSMSeqN(SM)$ +\If{$s_{s_{min}} \leq s_{s_{last}}$} + \State \Call{Error}{'Server sent old slots'} \EndIf -\If{$s_{s_{max}} > s_{max}$} - \State \Call{Error}{'Server sent out-of-range slot'} -\EndIf -\State $s_{self} \gets MS_s[id_{self}]$ -\State $sz_{expected} \gets s_{max} - s_{self} + 1$ -\If{$sz_{SL} \neq sz_{expected}$} +\State \Return{$s_{s_{min}} > s_{s_{last}} + 1$} +\EndFunction +\end{algorithmic} + +\begin{algorithmic}[1] +\Procedure{CheckSlotsRange}{$|SL_s|$} +\State $s_{s_{max}} \gets MaxLastSeqN(MS)$ +\State $s_{self} \gets MS[id_{self}]$ +\State $sz_{expected} \gets s_{s_{max}} - s_{self} + 1$ +\If{$|SL_s| \neq sz_{expected}$} \State \Call{Error}{'Actual number of slots does not match expected'} \EndIf \EndProcedure @@ -482,6 +488,7 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \State $MS_g \gets \emptyset$ \State $\tuple{s_{g_{min}},sv_{g_{min}}} \gets MinSlot(SL_g)$ \State $\tuple{s_{g_{max}},sv_{g_{max}}} \gets MaxSlot(SL_g)$ +\State $d \gets \Call{ValidSlotsRange}{|SL_g|,s_{g_{min}},s_{g_{max}}}$ \For{$s_g \gets s_{g_{min}}$ \textbf{to} $s_{g_{max}}$}\Comment{Process slots in $SL_g$ in order} \State $\tuple{s_g,sv_g} \gets Slot(SL_g,s_g)$ @@ -534,8 +541,8 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \Else \State \Call{Error}{'Actual $SL$ size on server exceeds $max_g$'} \EndIf -\State $\Call{CheckSlotsRange}{|SL_g|,s_{g_{min}},s_{g_{max}}}$ -\State $\Call{CheckLastSeqN}{MS_g,MS}$ +\State $\Call{CheckLastSeqN}{MS_g,MS,d}$ +\State $\Call{CheckSlotsRange}{|SL_g|}$ \State $\Call{UpdateSSLivEnt}{SS_{live},MS}$ \State $\Call{UpdateCRLivEnt}{CR_{live},MS}$ \State $\Call{UpdateSM}{SM,CR_{live}}$