Project

General

Profile

Repo Protocol Specification » History » Version 130

Alex Afanasyev, 07/23/2014 04:17 PM

1 1 Shuo Chen
Repo Protocol Specification
2
===========================
3
4 36 Shuo Chen
A Repo supports the network by preserving content and responding to Interests requesting content that it holds. A Repo can exist in any node, and is recommended if applications in that node need to preserve data. The NDN repo protocol is a specification of repo operations including reading, insertion and deletion of data objects in repo.
5 2 Shuo Chen
6 130 Alex Afanasyev
Repo semantics is based on [[ndn-cxx:SignedInterest|Signed Interests]] with signed components an the end of the name and basic common semantics of NDN. 
7 2 Shuo Chen
8 11 Shuo Chen
When some operation of repo including insertion and deletion of data objects is requested, a command interest is sent. The command interest is the interest as command of insertion and deletion and signed as form of command interest for access control. The repo will response the command with the data object.
9 4 Shuo Chen
10
The repo protocol can be categorized in three sections of reading, insertion and deletion of data objects.
11
12
## Repo Reading Specification
13
14 130 Alex Afanasyev
Repo registers prefixes of data objects it holds into NDN forwarding daemon and the repo will respond the data with such prefixes.
15 6 Shuo Chen
16 11 Shuo Chen
A standard interest is used to fetch content from the repo. The repo will respond when the name of the interest matches the prefix it registered in NFD. If the content in repo matches the interests, it will respond with the data object. When the interest is not matched, it will not respond.
17 6 Shuo Chen
18
The protocol is listed as bellow
19
20
If there is a matching data object:
21
22 7 Shuo Chen
    Requester                     Repo
23
        |                           |
24
        |                           |
25
        |         Interest          |
26
     t1 |-------------------------->|
27
        |                           |
28
        |        Data Object        |
29
     t2 |<==========================|
30 1 Shuo Chen
        |                           |
31 7 Shuo Chen
        |                           |
32 1 Shuo Chen
        |                           |
33 7 Shuo Chen
34
If there is no matching data object:
35 6 Shuo Chen
36
    Requester                     Repo
37
        |                           |
38 1 Shuo Chen
        |                           |
39 7 Shuo Chen
        |         Interest          |
40
     t1 |-------------------------->|
41
        |                           |
42
        |                           |
43
        |                           |
44
45 74 Shuo Chen
46
### About Freshness
47
48 130 Alex Afanasyev
Solution to handle freshness by repo has not been clearly defined, so producer needs to take care of freshness when it puts things into repo, i.e. explicitly delete obsolete content. The `MustBeFresh` selector will be ignored by repo when fetching content from repo or handling repo command by repo.
49 1 Shuo Chen
50
## Repo Command
51 130 Alex Afanasyev
52
For insertion, deletion and other operations of repo, these commands are encoded in the form of [[ndn-cxx:SignedInterest|Signed Interests]]:
53
54
    /<repo-prefix>/<command-verb>/................./.........................................
55
                                  \______  _______/ \__________________  ___________________/
56
                                         \/                            \/
57
                                 RepoCommandParameter   Signed Interest additional components
58
59
The semantics of repo command interest is as follows:
60 14 Shuo Chen
61 8 Shuo Chen
The name semantics is defined to have following components:
62 1 Shuo Chen
63 75 Shuo Chen
* ``<repo prefix>`` refers to specific prefix repo is listening
64 30 Shuo Chen
* ``<command verb>`` refers to the name of command
65 91 Shuo Chen
* ``<RepoCommandParameter>`` refers to parameters of repo command
66 1 Shuo Chen
67 38 Shuo Chen
The following components are components of singed interest for access control:
68 1 Shuo Chen
69
* ``<timestamp>``
70 8 Shuo Chen
* ``<random-value>``
71
* ``<SignatureInfo>``
72
* ``<SignatureValue>``
73
74 75 Shuo Chen
For prefix of repo /ucla/cs/repo/, the command will be defined as this:
75 33 Shuo Chen
76 91 Shuo Chen
    /ucla/cs/repo/<command verb>/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue>
77 14 Shuo Chen
78 91 Shuo Chen
### RepoCommandParameter
79 29 Shuo Chen
80 91 Shuo Chen
    RepoCommandParameter ::= REPOCOMMANDPARAMETER-TYPE TLV-LENGTH
81 118 Shuo Chen
                               Name?
82 42 Shuo Chen
                               Selectors?
83 1 Shuo Chen
                               StartBlockId?
84
                               EndBlockId?
85 62 Shuo Chen
                               ProcessId?
86 29 Shuo Chen
87 48 Shuo Chen
    Name                  ::= NAME-TYPE TLV-LENGTH NameComponent*
88
    NameComponent         ::= NAME-COMPONENT-TYPE TLV-LENGTH BYTE+
89 43 Shuo Chen
90
    Selectors             ::= SELECTORS-TYPE TLV-LENGTH
91
                               MinSuffixComponents?
92
                               MaxSuffixComponents?
93
                               PublisherPublicKeyLocator?
94
                               Exclude?
95 47 Shuo Chen
                               ChildSelector?
96 43 Shuo Chen
97
    MinSuffixComponents   ::= MIN-SUFFIX-COMPONENTS-TYPE TLV-LENGTH
98
                               nonNegativeInteger
99
100
    MaxSuffixComponents   ::= MAX-SUFFIX-COMPONENTS-TYPE TLV-LENGTH
101
                               nonNegativeInteger
102
103
    PublisherPublicKeyLocator ::= KeyLocator
104
105
    Exclude               ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
106
    Any                   ::= ANY-TYPE TLV-LENGTH(=0)
107 47 Shuo Chen
108
    ChildSelector         ::= CHILD-SELECTOR-TYPE TLV-LENGTH
109
                               nonNegativeInteger
110 1 Shuo Chen
    
111
    StartBlockId          ::= STARTBLOCKID-TYPE TLV-LENGTH
112 49 Shuo Chen
                               nonNegativeInteger
113 1 Shuo Chen
    
114
    EndBlockId            ::= ENDBLOCKID-TYPE TLV-LENGTH
115 49 Shuo Chen
                               nonNegativeInteger
116 1 Shuo Chen
117 62 Shuo Chen
    ProcessId            ::= PROCESSID-TYPE TLV-LENGTH
118
                               nonNegativeInteger
119
120 44 Shuo Chen
#### Repo Command Selectors
121 38 Shuo Chen
122 52 Shuo Chen
Repo command supports parts of interest selectors of interest to indicate which contents to process. The definition of standard NDN selectors is described in [NDN Selectors Doc](http://named-data.net/doc/ndn-tlv/interest.html#selectors). The concrete definitions of both standard NDN selectors and repo command selectors are the same.
123
124
The difference between standard NDN interest and Repo Deletion Command interest that, the standard NDN selectors just matches **one** data packet that conforms to the selector conditions, but repo command selectors would matches **any** data packets. For example, if Interest is expressed for /ndn/edu and Exclude specifies one name component ucla, in standard NDN interest, the data producers will first exclude all the data packets with prefix /ndn/edu but not /ndn/edu/ucla, and then just selects one data packet. In repo deletion command interest, it will select all the data packets with prefix /ndn/edu but not /ndn/edu/ucla. However, in repo insert command, the repo will fetch one data just like standard interest selectors.
125 38 Shuo Chen
126 124 Shuo Chen
Repo command supports parts of standard NDN interests including MinSuffixComponents, MaxSuffixComponents, PublisherPublicKeyLocator, and Exclude. ChildSelector is supported in insertion command but not deletion command. If command contains other selectors, repo will ignore these not supported selectors. In addition, selectors are just supported in delete command. If other commands contains selectors, repo will ignore selectors when processing these commands.
127 38 Shuo Chen
128
The form of selectors is as follows:
129
130
    Selectors             ::= SELECTORS-TYPE TLV-LENGTH
131
                               MinSuffixComponents?
132
                               MaxSuffixComponents?
133
                               PublisherPublicKeyLocator?
134 1 Shuo Chen
                               Exclude?
135 51 Shuo Chen
                               ChildSelector?
136 38 Shuo Chen
    
137
    MinSuffixComponents   ::= MIN-SUFFIX-COMPONENTS-TYPE TLV-LENGTH
138
                               nonNegativeInteger
139
140
    MaxSuffixComponents   ::= MAX-SUFFIX-COMPONENTS-TYPE TLV-LENGTH
141
                               nonNegativeInteger
142
143
    PublisherPublicKeyLocator ::= KeyLocator
144
    
145
    Exclude               ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
146 1 Shuo Chen
    Any                   ::= ANY-TYPE TLV-LENGTH(=0)
147 51 Shuo Chen
148
    ChildSelector         ::= CHILD-SELECTOR-TYPE TLV-LENGTH
149
                               nonNegativeInteger
150 46 Shuo Chen
151
#### StartBlockId, EndBlockId
152 38 Shuo Chen
153 54 Shuo Chen
StartBlockId and EndBlockId are used to process segmented data. StartBlockId indicate the first segment number and EndBlockId indicate the last segment number. Repo will process segment data whose segment id between StartBlockId and EndBlockId. If StartBlockId is missing, the first segment id the repo process is 0; If EndBlockId is missing, this scenario is described in specific process in Repo Insertion Command section and Repo Deletion Command section.
154 62 Shuo Chen
155 68 Shuo Chen
#### Conflict of Selectors and StartBlockId, EndBlockId
156 67 Shuo Chen
157 91 Shuo Chen
Repo cannot process command with both selectors and StartBlockId, EndBlockId in RepoCommandParameter. If the RepoCommandParameter carries both, repo will ignore this command interest and return with error code of 405.
158 67 Shuo Chen
159 62 Shuo Chen
#### ProcessId
160 53 Shuo Chen
161 63 Shuo Chen
ProcessId is used by insertion and deletion check command to indicate specific insertion and deletion process. The ProcessId is fetched by repo command response of insertion and deletion command.
162
163 30 Shuo Chen
## Repo Command Response
164 1 Shuo Chen
165 30 Shuo Chen
Repo command response is the response data packet of repo command interest. The response contains statuscode to indicate the status of command process and other information. A TLV-encoded block called ``RepoCommandResponse`` is encoded in content of the data packet.
166 1 Shuo Chen
167 30 Shuo Chen
    RepoCommandResponse   ::= INSERTSTATUS-TYPE TLV-LENGTH
168 61 Shuo Chen
                               ProcessId?
169 117 Shuo Chen
                               StatusCode
170 1 Shuo Chen
                               StartBlockId?
171
                               EndBlockId?
172
                               InsertNum?
173 117 Shuo Chen
                               DeleteNum?
174 1 Shuo Chen
175 61 Shuo Chen
    ProcessId            ::= PROCESSID-TYPE TLV-LENGTH
176 55 Shuo Chen
                                nonNegativeInteger 
177
    
178 1 Shuo Chen
    StatusCode            ::= STATUSCODE-TYPE TLV-LENGTH
179
                                nonNegativeInteger    
180
181
    StartBlockId          ::= STARTBLOCKID-TYPE TLV-LENGTH
182
                                nonNegativeInteger
183
    
184
    EndBlockId            ::= ENDBLOCKID-TYPE TLV-LENGTH
185
                                nonNegativeInteger
186 17 Shuo Chen
187
    InsertNum             ::= INSERTNUM-TYPE TLV-LENGTH
188
                                nonNegativeInteger
189
190 30 Shuo Chen
    DeleteNum             ::= DELETENUM-TYPE TLV-LENGTH
191
                                nonNegativeInteger
192 17 Shuo Chen
193 113 Shuo Chen
### Name
194
Name indicates the Name in repocommandparameter of repo command
195
196
197 61 Shuo Chen
### ProcessId
198
ProcessId is a random number generated by repo to indicate the number of the command process. Client could use this ProcessId to check the status of specific command.
199 59 Shuo Chen
200
### StatusCode
201
202 64 Shuo Chen
StatusCode indicates the status of repo command process. The statuscodes of insert and deletion command are described in following insertion and deletion specification.
203
204 59 Shuo Chen
### StartBlockId, EndBlockId
205
206 65 Shuo Chen
StartBlockId and EndBlockId are the same as those of RepoCommandParameter. If either of those in RepoCommandParameter is missing, repo will set them as the Id known for now. For example, if StartBlockId is missing in RepoCommandParameter, StartBlockId in response will be set 0. If EndBlockId is missing in RepoCommandParameter, EndBlockId will be set null untill Repo get FinalBlockId in data packet. If FinalBlockId in returned data packet is less than EndBlockId, the EndBlockId will be set FinalBlockId.
207
208 59 Shuo Chen
### InsertNum, DeleteNum
209 66 Shuo Chen
InsertNum is used in reponse of insertion status check to indicate how many data packets have been successfully inserted into the repo. DeleteNum is used in response of deletion command and deletion check command. DeleteNum indicates how many data packets have been successfully inserted from repo.
210 59 Shuo Chen
211 119 Shuo Chen
## Repo TLV Type Encoding Number
212 120 Shuo Chen
213
Type                  | Number
214
----------------------| -------
215
RepoCommandParameter  | 201
216
StartBlockId          | 204
217
EndBlockId            | 205
218
ProcessId             | 206
219
RepoCommandResponse   | 207
220
StatusCode            | 208
221
InsertNum             | 209
222
DeleteNum             | 210
223 119 Shuo Chen
224 58 Shuo Chen
## Repo Trust Model
225 57 Shuo Chen
226
The trust model of repo depends on people who deploy the repo service, such as PKI. Repo can specify their own verification policies, and data consumers can specify their own trust anchors. The NDN [FAQ](http://named-data.net/project/faq/#How_does_NDN8217s_8220trust_management8221_work) shows how NDN trust managment works.
227
228 30 Shuo Chen
## Repo Insertion Specification
229
230 69 Shuo Chen
Repo insertion command requests that the repo retrieve and store content. This command interest is a signed interest and will be validated with access control policy defined by the repo. When the interested is validated and name of the data is not existed in the repo. The repository will reponse with a data object containing OK status and start to send the interest to fetch the data to insert.
231 30 Shuo Chen
232 121 Shuo Chen
Segmented data insertion is also supported in the insertion protocol. Segmantation info is defined in RepoCommandParameter. If the content is segmented, the final segment id will be encoded in this block.
233 30 Shuo Chen
234
### Insertion command interest semantics
235
236 122 Shuo Chen
The name semantics follows the format of the repo command. The <command verb> is defined as ``insert``.
237 76 Shuo Chen
For example, for ``<repo prefix>`` as ``/ucla/cs/repo``, the following is an example:
238 1 Shuo Chen
239 92 Shuo Chen
    /ucla/cs/repo/insert/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue>
240 30 Shuo Chen
241
### Insertion status check
242
243
During the insertion progress, the requester could send insertion status check command to check the status of the insertion progress. This status check command is also signed interest. The semantics of insertion status check command is shown as follows:
244
245
<command verb> equals to ``insert check``. For example:
246 1 Shuo Chen
247 93 Shuo Chen
    /ucla/cs/repo/insert check/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue>
248 69 Shuo Chen
249
### RepoCommandParameter
250
251 70 Shuo Chen
RepoCommandParameter of insertion and insertion check command follows that in Repo Command section. Name, Selectors, StartBlockId, EndBlockId are used in insertion. Name and ProcessId are used in insertion check command.
252 69 Shuo Chen
253 70 Shuo Chen
In insertion command, Name represents the name or prefix of data for repo to fetch. If selectors are set, repo will use these selectors to fetch the data. If StartBlockId or EndBlockId is set, the repo will retrieve segmented data with segment number between StartBlockId and EndBlockId. If Repo Insert Command carries both Selectors and StartBlockId, EndBlockId, repo would ignore it and response with statuscode of 405.
254
255
In insertion check command, Name represents name or prefix of data for repo to fetch. ProcessId is set by the RepoCommandResponse to indicate specified process.
256 30 Shuo Chen
257
### Insertatation status response
258
259
This insert status data object could be the response data object of both insert command and insert check command. It will follow the format of repo command response.
260
261 77 Shuo Chen
StatusCode indicates the status of insertion. InsertNum represents how many data has been intersted into the repo. StartBlockId and EndBlockId is the start and end segment id of data inserted. InsertNum is the how many data segments have been inserted. ProcessId indicates an ID of process, a random number gernerated by repo.
262 30 Shuo Chen
263 77 Shuo Chen
For insert cammand, status code will be set according to definition below, StartBlockId and EndBlockId will be set according to the insert command. If StartBlockId in RepoCommandParameter is missing, it will be set 0 in response. If EndBlockId is missing, it will not be set.
264 30 Shuo Chen
265 77 Shuo Chen
For insert check command, status code will be set according to definition below, StartBlockId and EndBlockId will be set according to the StartBlockId and EndBlockId that repo is using, insertnum will be set according to insertion progress. ProcessId is set according to the ID of process checked. If EndBlockId has not been decided, this EndBlockId will not be set in response.
266 30 Shuo Chen
267 1 Shuo Chen
StatusCode Definition:
268 17 Shuo Chen
269
``StatusCode`` | Description
270
-------------- | ----------------------------------------------
271 19 Shuo Chen
``100``        | The command is OK. can start to fetch the data
272
``200``        | All the data has been inserted
273 17 Shuo Chen
``300``        | This insertion is in progress
274 102 Shuo Chen
``401``        | This insertion command or insertion check command is invalidated
275
``402``        | Selectors and BlockId both present
276 105 Shuo Chen
``403``        | Malformed Command
277 17 Shuo Chen
``404``        | No such this insertion is in progress
278 102 Shuo Chen
``405``        | EndBlockId Missing Timeout
279 17 Shuo Chen
280 83 Shuo Chen
### EndBlockId Missing Timeout
281
282
If StartBlockId presents but EndBlockId is missing, and returned data packets do not contain FinalBlockId, the repo will continuosly fetch the data. An EndBlockId missing timeout is set to prevent this ocassion. The repo will start a timer when StartBlockId presents but EndBlockId is missing. When timeout happens, repo will stop fetching data to store and end insert process. If an insert check command arrives during this insert process, the time of timer is set to 0. If data packet containing FinalBlockId arrives, this timeout timer will be dismissed.
283
284 22 Alex Afanasyev
### Protocol Process
285
286 20 Alex Afanasyev
1. start to authorize the command; if authorization does not fail immediately, go to step 3
287 17 Shuo Chen
288 107 Shuo Chen
2. send a negative response indicating authorization failure, and abort these steps, insert process ends (StatusCode: 401)
289 14 Shuo Chen
290 100 Shuo Chen
3. if  both StartBlockId and EndBlockId are missing, go to step 7
291 14 Shuo Chen
292 109 Shuo Chen
4. if either StartBlockId or EndBlockId is present, and one of supported selectors is present. send negative reponse back and abort steps, insert process ends (StatusCode: 402)
293 14 Shuo Chen
294 78 Shuo Chen
5. if both StartBlockId and EndBlockId are present, and StartBlockId is less than or equal to EndBlockId, go to step 7
295 14 Shuo Chen
296 107 Shuo Chen
6. send a negative response indicating malformed command, and abort these steps, insert process ends (StatusCode: 403)
297 14 Shuo Chen
298 78 Shuo Chen
7. wait for authorization completion
299 14 Shuo Chen
300 107 Shuo Chen
8. if authorization fails, go to step 2 (StatusCode: 401)
301 14 Shuo Chen
302 107 Shuo Chen
9. send a positive response indicating insert is in progress (StatusCode: 200)
303 14 Shuo Chen
304 78 Shuo Chen
10. if either StartBlockId or EndBlockId is present, go to step 16
305 14 Shuo Chen
306 78 Shuo Chen
11. start to retrieve Name with selectors in insert command
307 14 Shuo Chen
308 78 Shuo Chen
12. wait for retrieval completion
309 1 Shuo Chen
310 84 Shuo Chen
13. if retrieval fails, go to step 27
311 1 Shuo Chen
312 78 Shuo Chen
14. store retrieved Data packet
313 20 Alex Afanasyev
314 84 Shuo Chen
15. abort these steps, insert process ends
315 1 Shuo Chen
316 84 Shuo Chen
16. if StartBlockId is missing, set StartBlockId 0. If EndBlockId is missing, EndBlockId will be missing unless get FinalBlockId in comming data packets, start EndBlockId Misiing Timeout timer.
317 14 Shuo Chen
318 78 Shuo Chen
17. append StartBlockId to Name
319 1 Shuo Chen
320 78 Shuo Chen
18. start to retrieve Name
321 14 Shuo Chen
322 78 Shuo Chen
19. wait for retrieval completion
323 14 Shuo Chen
324 81 Shuo Chen
20. if retrieval fails, go to step 26
325 14 Shuo Chen
326 78 Shuo Chen
21. store retrieved Data packet
327
328
22. if retrieved Data packet contains FinalBlockId, and FinalBlockId is less than EndBlockId or EndBlockId is missing, let EndBlockId be FinalBlockId
329
330 84 Shuo Chen
23. if the last component of Name is greater than or equal to EndBlockId, abort these steps, insert process ends
331 1 Shuo Chen
332 82 Shuo Chen
24. increment the last component of Name
333 15 Shuo Chen
334 82 Shuo Chen
25. go to step 17
335 1 Shuo Chen
336 129 Shuo Chen
26. retrieve data with this data another 2 times. If these 2 retrieval both failes, abort these steps. if success, go to step 21
337 15 Shuo Chen
338 129 Shuo Chen
27. retrieve data with this data another 2 times. If these 2 retrieval both failes, abort these steps. if success, go to step 14
339 84 Shuo Chen
340
If EndBlockId Missing Timeout timer starts, repo will monitor this timer during step 17~26. If this timeout occurs, abort insert command process immediately.
341 15 Shuo Chen
342 20 Alex Afanasyev
Implementation MAY pipeline the Interests.
343 1 Shuo Chen
344 85 Shuo Chen
### Repo insert check command progress
345 16 Shuo Chen
346 20 Alex Afanasyev
Implementation MAY publish a notification of status regarding insert progress. The process of status check is as follows:
347 18 Shuo Chen
348 110 Shuo Chen
1. start to authorize the insert status command, if fails go to 2, if success, go to 3
349 1 Shuo Chen
350 110 Shuo Chen
2. send a negative response indicating authorization failure, and abort these steps (StatusCode: 401)
351 18 Shuo Chen
352 20 Alex Afanasyev
3. start to check the progress of the insert with the data name in the command. If no such progress is found, go to 4. or go to 5.
353 18 Shuo Chen
354 110 Shuo Chen
4. reponse status with status code, abort check process. (StatusCode: 404)
355 18 Shuo Chen
356 110 Shuo Chen
5. ckeck the status of insertion. return the status of insertion progress. If a EndBlockId Missing Timeour timer is running, set this timer to 0. About check process. (StatusCode: 300)
357 20 Alex Afanasyev
358 17 Shuo Chen
### Protocol diagram:
359 10 Alex Afanasyev
360
    Requester                     Repo                          Data producer
361
        |                           |                                 |
362
        |                           |                                 |
363
      +---+  Insert command       +---+                               |
364
      |   | --------------------> |   |                               |
365
      +---+                       |   |                               |
366
        |                         |   |                               |
367
      +---+   Confirm start       |   |                               |
368
      |   | <==================== |   |                               |
369
      +---+   Reject command      +---+                               |
370
        |     (with status code)    |                                 |
371
        |                         +---+     Interest for Data       +---+
372 1 Shuo Chen
        |                         |   | --------------------------> |   |
373
        |                         +---+                             |   |
374 10 Alex Afanasyev
        |                           |                               |   |
375
        |                         +---+       Data segment          |   |
376
        |                         |   | <========================== |   |
377
        |                         +---+                             +---+
378
        |                           |                                 |
379
        |                           ~                                 ~
380
        |                           ~                                 ~
381
        |                           |                                 |
382
        |                         +---+     Interest for Data       +---+
383
        |                         |   | --------------------------> |   |
384
        |                         +---+                             |   |
385 1 Shuo Chen
        |                           |                               |   |
386
        |                         +---+       Data segment          |   |
387
        |                         |   | <========================== |   |
388
        |                         +---+                             +---+
389
        |                           |                                 |
390
        |                           |                                 |
391 17 Shuo Chen
        |                           ~                                 ~
392 1 Shuo Chen
        |                           ~                                 ~
393
        |                           |                                 |
394 30 Shuo Chen
        |                           |                                 |
395 19 Shuo Chen
        |                           |                                 |
396 30 Shuo Chen
      +---+   Status interest     +---+                               |
397 19 Shuo Chen
      |   | --------------------> |   |                               |
398
      +---+                       |   |                               |
399
        |                         |   |                               |
400
      +---+    Status response    |   |                               |
401
      |   | <==================== |   |                               |
402
      +---+                       +---+                               |
403
        |                           |                                 |
404
        |                           |                                 |
405
406
## Repo Deletion Specification
407
408 87 Shuo Chen
Deletion of one content object or content objects under certain prefix are both supported in repo specification. Selectors are used to select multiple content objects. These selectors are different from conventional [selectors](http://named-data.net/doc/ndn-tlv/interest.html#selectors) of interest packet. The conventional selecors of interest would select one data packet of repo. Selecors of delete command will return any data packets which applies for these selectors. Deletion of segmented data is also supported.
409 19 Shuo Chen
410
### Deletion command interest semantics
411
412 1 Shuo Chen
Deletion command interest follows the format of the repo command. For example:
413 19 Shuo Chen
414 94 Shuo Chen
    /ucla/cs/repo/delete/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue
415 19 Shuo Chen
416 88 Shuo Chen
### Deletion Command RepoCommandParameter
417
418 96 Shuo Chen
Format of deletion command RepoCommandParameter follows that of Repo Command. Name, Selector, StartBlockId, EndBlockId, ProcessId are used to construct RepoCommandParameter.
419 88 Shuo Chen
420 96 Shuo Chen
Name is the name or the prefix of data repo will delete.
421
422 127 Shuo Chen
Selector is used to select data. ChildSelector is **not** supported in deletion command.
423 96 Shuo Chen
424
StartBlockId and EndBlockId are used to delete segment data. Data of segment id between StartBlockId and EndBlockId will be deleted by repo.
425
426
ProcessId is a random number generated by client to indicate the deletion process. Repo will match this ProcessId with this deletion process.
427 88 Shuo Chen
428 19 Shuo Chen
### Deletion Command Selectors
429
430 39 Shuo Chen
Deletion command selectors follows the [repo command selectors](http://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Selectors).
431
432 19 Shuo Chen
### Deletion status check
433
434 30 Shuo Chen
During the deletion progress, the requester could send deletion status check command to check the status of the deletion progress. This status check command is also signed interest. The semantics of deletion status check command follows the format of repo command. ``<command verb>`` equals to ``delete check``. For example:
435 1 Shuo Chen
436 95 Shuo Chen
    /ucla/cs/repo/delete/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue>
437 19 Shuo Chen
438 97 Shuo Chen
### Deletion status check RepoCommandParameter
439
440
Name and ProcessId are used to indicate certain deletion process. Repo uses Name and ProcessId to match certain deletion process. If it matches, repo will respond progress of deletion. If just one of Name or ProcessId matches, it fails.
441
442 41 Shuo Chen
### Deletion Check Command Selectors
443
444
Selectors are not supported. Repo will ignore selectors when processing deletion status check command.
445
446 19 Shuo Chen
### Deletion status response
447
448 98 Shuo Chen
Deletion status response is used as response of repo deletion command and repo deletion check command.
449 1 Shuo Chen
450 99 Shuo Chen
Name, StatusCode, Selector, StartBlockId, EndBlockId, ProcessId, DeletenNum are used in deletion status response. Name, ProcessId, Selector is the same as that of delete command. StatusCode indicates the status of deletion. DeleteNum indicates how many data packets have been deleted.
451 98 Shuo Chen
452
In Repo Deletion Command, if just StartBlockId presents, EndBlockId may be the largest segment ID repo holds. If just EndBlockId presents, StartBlockId will be set 0
453 19 Shuo Chen
454
StatusCode Definition:
455
456
``StatusCode`` | Description
457
-------------- | --------------------------------------
458
``200``        | All the data has been deleted
459
``300``        | This deletion is in progress
460 104 Shuo Chen
``401``        | This deletion or deletion check is invalidated
461
``402``        | Selectors and BlockId both present
462 106 Shuo Chen
``403``        | Malformed Command
463 30 Shuo Chen
``404``        | No such this deletion is in progress
464 19 Shuo Chen
465 17 Shuo Chen
### Protocol process
466 1 Shuo Chen
467 101 Shuo Chen
1. start to authorize the command; if authorization does not fail, go to step 3
468 1 Shuo Chen
469 108 Shuo Chen
2. send a negative response indicating authorization failure, and abort these steps, end deletion process. (StatusCode: 401)
470 1 Shuo Chen
471 101 Shuo Chen
3. check whether a deletion process of same RepoCommandParameter exists, waiting for deletion process ends.
472 1 Shuo Chen
473 108 Shuo Chen
4. If selectors and one of StartBlockId and EndBlockId presents, send a negative response and abort these steps, end deletion process. (StatusCode: 402)
474 1 Shuo Chen
475 101 Shuo Chen
5. If selectors present, go to step 8
476 1 Shuo Chen
477 108 Shuo Chen
6. check whether StartBlockId or EndBlockId presents. If both presents but StartBlockId is larger than EndBlockId, return negative response and end deletion process. (StatusCode: 403) Or go to step 9
478 1 Shuo Chen
479 101 Shuo Chen
7. If StartBlockId, EndBlockId and selectors are all missing, go to step 10
480 1 Shuo Chen
481 101 Shuo Chen
8. delete all the data that conforms to the name and selectors, go to step 11
482
483
9. delete all the data packets of segment id between StartBlockId and EndBlockId. If StartBlockId is missing, StartBlockId is set to be 0. If EndBlockId is missing, EndBlockId is set to be the largest segment id that repo holds. go to step 11
484
485 128 Shuo Chen
10. delete all the data with prefix same as name. got to step 11
486 101 Shuo Chen
487 108 Shuo Chen
11. If lifetime of interest does not expire, return status response of positive statuscode. If lifetime of interest has expired, wait for interest the same RepoCommandParameter and return this status response. End Deletion process. (StatusCode: 200)
488 101 Shuo Chen
489
Client will set deletion command with big lifetime. If life time expires, client will re-express the command.
490 19 Shuo Chen
491 21 Alex Afanasyev
Implementation MAY publish a notification of status regarding delete progress. The process of status check is as follows:
492 19 Shuo Chen
493 21 Alex Afanasyev
1. start to authorize the delete status command
494 19 Shuo Chen
495 108 Shuo Chen
2. send a negative response indicating authorization failure, and abort these steps (StatusCode: 401)
496 19 Shuo Chen
497 21 Alex Afanasyev
3. start to check the progress of the delete with the data name in the command. If no such progress is found, go to 4. or go to 5.
498 19 Shuo Chen
499 108 Shuo Chen
4. reponse status with status code of 404 (StatusCode: 404)
500 21 Alex Afanasyev
501 108 Shuo Chen
5. ckeck te status of delete. return the status data content (StatusCode: 300)
502 19 Shuo Chen
503
### Protocol diagram:
504
505
    Requester                     Repo 
506
        |                           |                                 
507
        |                           |                                 
508
      +---+  Delete command       +---+                               
509
      |   | --------------------> |   |                               
510
      +---+                       +---+                               
511
        |                           |                                 
512
        |                           |                                 
513
        |                           |                                 
514
      +---+   Status interest     +---+                               
515
      |   | --------------------> |   |                               
516
      +---+                       |   |                               
517
        |                         |   |                               
518
      +---+    Status response    |   |                               
519
      |   | <==================== |   |                               
520
      +---+                       +---+                               
521
        |                           |                                 
522
        |                           |                                 
523
        |                           |                                 
524
      +---+   Confirm Deletion    +---+                               
525
      |   | <==================== |   |                               
526
      +---+   Reject command      +---+                               
527
        |     (with status code)    |    
528 20 Alex Afanasyev
        |                           |