dissect-wireshark: show Name and FinalBlockId as URIs

refs #3106

Change-Id: I0c43bb07588839b553f4584ce2ca44b3819e3d78
This commit is contained in:
Junxiao Shi authored and Alex Afanasyev committed 2018-05-06 16:35:38 -07:00
1 parent 4a43e87b5a
commit c687af62d1
5 files changed
+121 -28

No files matched your search

+26 -3
View File
@@ -150,6 +150,29 @@ Trace summary: Hand-crafted packets in NDN Packet Format v0.3
All packets are valid and do not contain unrecognized TLV elements.
Expected results of the dissection:
- Packet 1 is recognized as "Interest" type, and has "CanBePrefix: Yes", "MustBeFresh: Yes",
"HopLimit: 214", and "Parameters" field.
- Packet 3 is recognized as "Data" type.
- Packet 1 is recognized as "Interest" type, and has `CanBePrefix: Yes`, `MustBeFresh: Yes`,
`HopLimit: 214`, as well as a "Parameters" field.
- Packet 2 is recognized as "Interest" type, and has `Name: /2=A/7=B/C/252=D/256=E/65535=E/sha256digest=ee357c5791dcaa4494d9b301047b875d8833caa76dada3e95837bbc3eaf7b300`.
- Packet 3 is recognized as "Data" type, and has `Name: /`.
### 12. URI Scheme
Trace file: `nameuri.pcap`
Trace summary: Hand-crafted packet for testing URI encoding in Name and FinalBlockId
(`xxd -p -r < nameuri.hex > nameuri.pcap`).
Expected results of the dissection:
- Packet 1 is recognized as "Data" type.
- Its name has eight components.
- First name component is `NameComponent: ...`.
- Second name component is `NameComponent: ....`.
- Third name component is `NameComponent: .....`.
- Fourth name component is `NameComponent: .A`.
- Fifth name component is `NameComponent: %00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F`.
Notice that digits, HYPHEN (`-`), and PERIOD (`.`) are not percent-encoded.
- Sixth name component is `NameComponent: %40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F`.
Notice that upper case letters, lower case letters, UNDERSCORE (`_`), and TILDE (`~`) are not percent-encoded.
- Seventh name component is `NameComponent: %80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF`.
- Eighth name component is `NameComponent: %C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF`.
- FinalBlockId and its nested NameComponent are both `%02`.
+41
View File
@@ -0,0 +1,41 @@
A1B2C3D4
00020004
00000000
00000000
00010000
00000001
# packet 1
00000000
00000000
00000159
00000159
01005E0017AA
000000000000
8624
## Data
06FD0147
## Name
07FD0115
0800
08012E
08022E2E
08022E41
0840000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F
0840404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F
0840808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF
0840C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
## MetaInfo
1405
1A03080102
## SignatureInfo
1603
1B0100
## SignatureValue
1720612A79399E60304A9F701C1ECAC7956BF2F1B046E6C6F0D6C29B3FE3A29BAD76
Binary file not shown.
+6
View File
@@ -5,6 +5,7 @@ A1B2C3D4
00010000
00000001
# packet 1
00000000
00000000
00000039
@@ -14,6 +15,7 @@ A1B2C3D4
000000000000
8624
## Interest with CanBePrefix, MustBeFresh, HopLimit, Parameters
0529
0703080149
2100
@@ -24,6 +26,7 @@ A1B2C3D4
2201D6
2304C0C1C2C3
# packet 2
00000000
00000000
00000050
@@ -33,10 +36,12 @@ A1B2C3D4
000000000000
8624
## Interest Name contains typed name components
0540
0738 020141 070142 080143 FC0144 FD01000145 FDFFFF0145 0120EE357C5791DCAA4494D9B301047B875D8833CAA76DADA3E95837BBC3EAF7B300
0A044ACB1E4C
# packet 3
00000000
00000000
00000039
@@ -46,6 +51,7 @@ A1B2C3D4
000000000000
8624
## Data without MetaInfo or Content
0629
0700
16031B0100
+48 -25
View File
@@ -37,38 +37,61 @@ ndn = Proto("ndn", "Named Data Networking (NDN)")
-----------------------------------------------------
-- Field formatting helpers
-- Borrowed from http://lua-users.org/wiki/StringRecipes
function escapeString(str)
if (str) then
str = string.gsub(str, "\n", "\r\n")
str = string.gsub(str, "([^%w %-%_%.%~])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub(str, " ", "+")
end
return str
end
-- @return TLV-VALUE portion of a TLV block
function getValue(b)
return b.tvb(b.offset + b.typeLen + b.lengthLen, b.length)
end
function getUriFromNameComponent(b)
-- @todo Implement proper proper URL escaping
return getValue(b):string()
function getUriFromImplicitSha256DigestComponent(b)
s = "sha256digest="
for i = 0, (b.length - 1) do
byte = b.tvb(b.offset + b.typeLen + b.lengthLen + i, 1)
s = s .. string.format("%02x", byte:uint())
end
return s
end
function getUriFromName(nameBlock)
if (nameBlock.elements == nil) then
return ""
else
components = {}
for i, block in pairs(nameBlock.elements) do
table.insert(components, getUriFromNameComponent(block))
end
return "/" .. table.concat(components, "/")
function getUriFromNameComponent(b)
if b.type == 1 then
return getUriFromImplicitSha256DigestComponent(b)
end
s = ""
if b.type ~= 8 then
s = string.format("%d=", b.type)
end
hasNonPeriod = false
for i = 0, (b.length - 1) do
byte = b.tvb(b.offset + b.typeLen + b.lengthLen + i, 1)
ch = byte:uint()
hasNonPeriod = hasNonPeriod or ch ~= 0x2E
if (ch >= 0x41 and ch <= 0x5A) or (ch >= 0x61 and ch <= 0x7A) or (ch >= 0x30 and ch <= 0x39) or ch == 0x2D or ch == 0x2E or ch == 0x5F or ch == 0x7E then
s = s .. byte:string()
else
s = s .. string.format("%%%02X", ch)
end
end
if not hasNonPeriod then
s = s .. "..."
end
return s
end
function getUriFromName(b)
if b.elements == nil then
return "/"
end
components = {}
for i, comp in pairs(b.elements) do
table.insert(components, getUriFromNameComponent(comp))
end
return "/" .. table.concat(components, "/")
end
function getUriFromFinalBlockId(b)
if b.elements == nil then
return "/"
end
return getUriFromNameComponent(b.elements[1])
end
function getUriFromExclude(block)
@@ -182,7 +205,7 @@ local NDN_DICT = {
[20] = {name = "MetaInfo" , summary = true},
[24] = {name = "ContentType" , field = ProtoField.uint32("ndn.contenttype", "Content Type", base.DEC) , value = getNonNegativeInteger},
[25] = {name = "FreshnessPeriod" , field = ProtoField.uint32("ndn.freshnessperiod", "FreshnessPeriod", base.DEC) , value = getNonNegativeInteger},
[26] = {name = "FinalBlockId" , field = ProtoField.string("ndn.finalblockid", "FinalBlockId") , value = getUriFromNameComponent},
[26] = {name = "FinalBlockId" , field = ProtoField.string("ndn.finalblockid", "FinalBlockId") , value = getUriFromFinalBlockId},
[21] = {name = "Content" , field = ProtoField.string("ndn.content", "Content")},
[22] = {name = "SignatureInfo" , summary = true},
[27] = {name = "SignatureType" , field = ProtoField.uint32("ndn.signaturetype", "SignatureType", base.DEC) , value = getNonNegativeInteger},