dissect-wireshark: improve NDNLPv2 support
* Support 8-octet NonNegativeInteger.
* Recognize PitToken.
* Recognize CongestionMark.
* Recognize Ack.
* Recognize TxSequence.
refs #4463
Change-Id: I3b003400726df975d067ff46a5ebe645ea774b8b
diff --git a/tests/dissect-wireshark/README.md b/tests/dissect-wireshark/README.md
index afc497b..cf43e61 100644
--- a/tests/dissect-wireshark/README.md
+++ b/tests/dissect-wireshark/README.md
@@ -116,18 +116,28 @@
Expected result of the dissection:
- data packet is dissected at packet 12 without Lua error.
-### 9. NDNLPv2 Basic
+### 9. NDNLPv2
Trace file: `ndnlpv2.pcap`
-Trace summary: Short capture, containing NDN interest that was NACKed with the reason "NoRoute"
+Trace summary: Handcrafted NDNLPv2 packets.
+(`xxd -p -r < ndnlpv2.hex > ndnlpv2.pcap`).
-Expected result of the dissection:
-- interest packet is dissected from packet 1
-- from packet 2, an NDNLPv2 packet is dissected which includes a NACK with the code "NoRoute" and
- a fragment that includes an interest packet
+Expected result of the dissection: 12 "Ethernet (NDN)" frames.
+1. LpPacket contains 12 unrecognized fields. The 10th and 12th fields are labelled "ignored".
+2. No special requirements.
+3. "Sequence: 12732154106453800448". "FragIndex: 0". "FragCount: 2". Fragment exists.
+4. "Sequence: 12732154106453800449". "FragIndex: 1". "FragCount: 2". Fragment exists.
+5. "NackReason: Congestion".
+6. "NackReason: Duplicate".
+7. "NackReason: NoRoute".
+8. "NackReason: 1".
+9. Nack exists, but NackReason does not exist.
+10. "PitToken: 15047039637272254167".
+11. "CongestionMark: 1". "TxSequence: 16204482402681480935".
+12. There are eight Ack fields. First is "Ack: 16204482402681480704". Eighth is "Ack: 16204482402681480711".
-### 10. NDNLPv2 Extended
+### 10. NDNLPv2 (random)
Trace file: `ndnlpv2-more.pcap`
@@ -145,7 +155,7 @@
Trace file: `packet03.pcap`
-Trace summary: Hand-crafted packets in NDN Packet Format v0.3
+Trace summary: Handcrafted packets in NDN Packet Format v0.3
(`xxd -p -r < packet03.hex > packet03.pcap`).
All packets are valid and do not contain unrecognized TLV elements.
@@ -159,7 +169,7 @@
Trace file: `nameuri.pcap`
-Trace summary: Hand-crafted packet for testing URI encoding in Name and FinalBlockId
+Trace summary: Handcrafted packet for testing URI encoding in Name and FinalBlockId
(`xxd -p -r < nameuri.hex > nameuri.pcap`).
Expected results of the dissection:
diff --git a/tests/dissect-wireshark/ndnlpv2.hex b/tests/dissect-wireshark/ndnlpv2.hex
new file mode 100644
index 0000000..ee192bd
--- /dev/null
+++ b/tests/dissect-wireshark/ndnlpv2.hex
@@ -0,0 +1,218 @@
+A1B2C3D4
+00020004
+00000000
+00000000
+00010000
+00000001
+
+# packet 1
+00000000
+00000000
+00000030
+00000030
+
+01005E0017AA
+000000000000
+8624
+
+## LpPacket with unrecognized headers
+6420
+5500
+5600
+5700
+5800
+5900
+6000
+6100
+6300
+FD032400
+FD032500
+FD032600
+FD032700
+
+# packet 2
+00000000
+00000000
+00000029
+00000029
+
+01005E0017AA
+000000000000
+8624
+
+## LpPacket with reordered headers
+6419
+530102
+5108B0B1B2B3B4B5B600
+5007 050B0703080141
+520100
+
+# packet 3
+00000000
+00000000
+00000029
+00000029
+
+01005E0017AA
+000000000000
+8624
+
+## first half of fragmented Interest
+6419
+5108B0B1B2B3B4B5B600
+520100
+530102
+5007
+050B0703080141
+
+# packet 4
+00000000
+00000000
+00000028
+00000028
+
+01005E0017AA
+000000000000
+8624
+
+## second half of fragmented Interest
+6418
+5108B0B1B2B3B4B5B601
+520101
+530102
+5006
+0A04A0A1A2A3
+
+# packet 5
+00000000
+00000000
+00000028
+00000028
+
+01005E0017AA
+000000000000
+8624
+
+## Nack~Congestion
+6418
+FD032005 FD03210132
+500D
+050B07030801410A04A0A1A2A3
+
+# packet 6
+00000000
+00000000
+00000028
+00000028
+
+01005E0017AA
+000000000000
+8624
+
+## Nack~Duplicate
+6418
+FD032005 FD03210164
+500D
+050B07030801410A04A0A1A2A3
+
+# packet 7
+00000000
+00000000
+00000028
+00000028
+
+01005E0017AA
+000000000000
+8624
+
+## Nack~NoRoute
+6418
+FD032005 FD03210196
+500D
+050B07030801410A04A0A1A2A3
+
+# packet 8
+00000000
+00000000
+00000028
+00000028
+
+01005E0017AA
+000000000000
+8624
+
+## Nack unrecognized reason
+6418
+FD032005 FD03210101
+500D
+050B07030801410A04A0A1A2A3
+
+# packet 9
+00000000
+00000000
+00000023
+00000023
+
+01005E0017AA
+000000000000
+8624
+
+## Nack no reason
+6413
+FD032000
+500D
+050B07030801410A04A0A1A2A3
+
+# packet 10
+00000000
+00000000
+00000029
+00000029
+
+01005E0017AA
+000000000000
+8624
+
+## Interest with PIT token
+6419
+6208D0D1D2D3D4D5D6D7
+500D
+050B07030801410A04A0A1A2A3
+
+# packet 11
+00000000
+00000000
+0000004E
+0000004E
+
+01005E0017AA
+000000000000
+8624
+
+## Data with CongestionMark=1 and TxSequence
+643E
+FD03400101
+FD034808E0E1E2E3E4E5E6E7
+502B
+0629 0700 16031B0100 1720612A79399E60304A9F701C1ECAC7956BF2F1B046E6C6F0D6C29B3FE3A29BAD76
+
+# packet 12
+00000000
+00000000
+00000070
+00000070
+
+01005E0017AA
+000000000000
+8624
+
+## IDLE packet with Acks
+6460
+FD034408E0E1E2E3E4E5E600
+FD034408E0E1E2E3E4E5E601
+FD034408E0E1E2E3E4E5E602
+FD034408E0E1E2E3E4E5E603
+FD034408E0E1E2E3E4E5E604
+FD034408E0E1E2E3E4E5E605
+FD034408E0E1E2E3E4E5E606
+FD034408E0E1E2E3E4E5E607
diff --git a/tests/dissect-wireshark/ndnlpv2.pcap b/tests/dissect-wireshark/ndnlpv2.pcap
index 66ca127..697d742 100644
--- a/tests/dissect-wireshark/ndnlpv2.pcap
+++ b/tests/dissect-wireshark/ndnlpv2.pcap
Binary files differ
diff --git a/tools/dissect-wireshark/ndn.lua b/tools/dissect-wireshark/ndn.lua
index 91ab21c..9cedb4a 100755
--- a/tools/dissect-wireshark/ndn.lua
+++ b/tools/dissect-wireshark/ndn.lua
@@ -42,6 +42,13 @@
return b.tvb(b.offset + b.typeLen + b.lengthLen, b.length)
end
+function getNonNegativeInteger(b)
+ if b.length == 1 or b.length == 2 or b.length == 4 or b.length == 8 then
+ return getValue(b):uint64()
+ end
+ return UInt64.max()
+end
+
function getUriFromImplicitSha256DigestComponent(b)
s = "sha256digest="
for i = 0, (b.length - 1) do
@@ -101,11 +108,10 @@
function getNackReasonDetail(b)
local code = getNonNegativeInteger(b)
- if (code == 0) then return "None"
- elseif (code == 50) then return "Congestion"
- elseif (code == 100) then return "Duplicate"
- elseif (code == 150) then return "NoRoute"
- else return "Unknown"
+ if code == UInt64(50) then return "Congestion"
+ elseif code == UInt64(100) then return "Duplicate"
+ elseif code == UInt64(150) then return "NoRoute"
+ else return tostring(code)
end
end
@@ -116,17 +122,6 @@
end
end
-function getNonNegativeInteger(b)
- if (b.length == 1 or b.length == 2 or b.length == 4) then
- return getValue(b):uint()
- -- Something strange with uint64, not supporting it for now
- -- elseif (b.length == 8) then
- -- return b.tvb(b.offset + b.typeLen + b.lengthLen, 8):uint64()
- else
- return 0xFFFFFFFF;
- end
-end
-
function getNonce(b)
assert(b.type == 10)
if (b.length ~= 4) then
@@ -194,47 +189,51 @@
-- [30] = {name = "ForwardingHint" , summary = true},
-- ForwardingHint and LinkPreference have the same TLV-TYPE number, so we can't recognize both for now (see #4185).
[31] = {name = "LinkDelegation" , summary = true},
- [30] = {name = "LinkPreference" , field = ProtoField.uint32("ndn.link_preference", "LinkPreference", base.DEC) , value = getNonNegativeInteger},
+ [30] = {name = "LinkPreference" , field = ProtoField.uint64("ndn.link_preference", "LinkPreference", base.DEC) , value = getNonNegativeInteger},
[10] = {name = "Nonce" , field = ProtoField.uint32("ndn.nonce", "Nonce", base.HEX) , value = getNonce},
- [12] = {name = "InterestLifetime" , field = ProtoField.uint32("ndn.interestlifetime", "InterestLifetime", base.DEC) , value = getNonNegativeInteger},
- [34] = {name = "HopLimit" , field = ProtoField.uint32("ndn.hoplimit", "HopLimit", base.DEC) , value = getNonNegativeInteger},
+ [12] = {name = "InterestLifetime" , field = ProtoField.uint64("ndn.interestlifetime", "InterestLifetime", base.DEC) , value = getNonNegativeInteger},
+ [34] = {name = "HopLimit" , field = ProtoField.uint64("ndn.hoplimit", "HopLimit", base.DEC) , value = getNonNegativeInteger},
[35] = {name = "Parameters" , field = ProtoField.string("ndn.parameters", "Parameters")},
-- Data and its sub-elements in Packet Format v0.3
[6] = {name = "Data" , summary = true},
[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},
+ [24] = {name = "ContentType" , field = ProtoField.uint64("ndn.contenttype", "Content Type", base.DEC) , value = getNonNegativeInteger},
+ [25] = {name = "FreshnessPeriod" , field = ProtoField.uint64("ndn.freshnessperiod", "FreshnessPeriod", base.DEC) , value = getNonNegativeInteger},
[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},
+ [27] = {name = "SignatureType" , field = ProtoField.uint64("ndn.signaturetype", "SignatureType", base.DEC) , value = getNonNegativeInteger},
[28] = {name = "KeyLocator" , summary = true},
[29] = {name = "KeyDigest" , field = ProtoField.bytes("ndn.keydigest", "KeyDigest")},
[23] = {name = "SignatureValue" , field = ProtoField.bytes("ndn.signaturevalue", "SignatureValue")},
-- NDNLPv2 headers
[80] = {name = "Fragment" },
- [81] = {name = "Sequence" , field = ProtoField.uint32("ndn.sequence", "Sequence", base.DEC), value = getNonNegativeInteger},
- [82] = {name = "FragIndex" , field = ProtoField.uint32("ndn.fragindex", "FragIndex", base.DEC), value = getNonNegativeInteger},
- [83] = {name = "FragCount" , field = ProtoField.uint32("ndn.fragcount", "FragCount", base.DEC), value = getNonNegativeInteger},
+ [81] = {name = "Sequence" , field = ProtoField.uint64("ndn.sequence", "Sequence", base.DEC) , value = getNonNegativeInteger},
+ [82] = {name = "FragIndex" , field = ProtoField.uint64("ndn.fragindex", "FragIndex", base.DEC) , value = getNonNegativeInteger},
+ [83] = {name = "FragCount" , field = ProtoField.uint64("ndn.fragcount", "FragCount", base.DEC) , value = getNonNegativeInteger},
+ [98] = {name = "PitToken" , field = ProtoField.uint64("ndn.pit_token", "PitToken", base.DEC) , value = getNonNegativeInteger},
[100] = {name = "LpPacket" , summary = true},
[800] = {name = "Nack" , summary = true},
- [801] = {name = "NackReason" , field = ProtoField.string("ndn.nack_reason", "NackReason"), value = getNackReasonDetail},
- [816] = {name = "NextHopFaceId" , field = ProtoField.uint32("ndn.nexthop_faceid", "NextHopFaceId", base.DEC), value = getNonNegativeInteger},
- [817] = {name = "IncomingFaceId" , field = ProtoField.uint32("ndn.incoming_faceid", "IncomingFaceId", base.DEC), value = getNonNegativeInteger},
+ [801] = {name = "NackReason" , field = ProtoField.string("ndn.nack_reason", "NackReason") , value = getNackReasonDetail},
+ [816] = {name = "NextHopFaceId" , field = ProtoField.uint64("ndn.nexthop_faceid", "NextHopFaceId", base.DEC) , value = getNonNegativeInteger},
+ [817] = {name = "IncomingFaceId" , field = ProtoField.uint64("ndn.incoming_faceid", "IncomingFaceId", base.DEC) , value = getNonNegativeInteger},
[820] = {name = "CachePolicy" , summary = true},
- [821] = {name = "CachePolicyType" , field = ProtoField.string("ndn.cachepolicy_type", "CachePolicyType"), value = getCachePolicyDetail},
+ [821] = {name = "CachePolicyType" , field = ProtoField.string("ndn.cachepolicy_type", "CachePolicyType") , value = getCachePolicyDetail},
+ [832] = {name = "CongestionMark" , field = ProtoField.uint64("ndn.congestion_mark", "CongestionMark", base.DEC) , value = getNonNegativeInteger},
+ [836] = {name = "Ack" , field = ProtoField.uint64("ndn.ack", "Ack", base.DEC) , value = getNonNegativeInteger},
+ [840] = {name = "TxSequence" , field = ProtoField.uint64("ndn.tx_sequence", "TxSequence", base.DEC) , value = getNonNegativeInteger},
-- Deprecated elements
[9] = {name = "Selectors" , summary = true},
- [13] = {name = "MinSuffixComponents" , field = ProtoField.uint32("ndn.minsuffix", "MinSuffixComponents") , value = getNonNegativeInteger},
- [14] = {name = "MaxSuffixComponents" , field = ProtoField.uint32("ndn.maxsuffix", "MaxSuffixComponents") , value = getNonNegativeInteger},
+ [13] = {name = "MinSuffixComponents" , field = ProtoField.uint64("ndn.minsuffix", "MinSuffixComponents") , value = getNonNegativeInteger},
+ [14] = {name = "MaxSuffixComponents" , field = ProtoField.uint64("ndn.maxsuffix", "MaxSuffixComponents") , value = getNonNegativeInteger},
[15] = {name = "PublisherPublicKeyLocator" , summary = true},
[16] = {name = "Exclude" , field = ProtoField.string("ndn.exclude", "Exclude") , value = getUriFromExclude},
- [17] = {name = "ChildSelector" , field = ProtoField.uint32("ndn.childselector", "ChildSelector", base.DEC) , value = getNonNegativeInteger},
+ [17] = {name = "ChildSelector" , field = ProtoField.uint64("ndn.childselector", "ChildSelector", base.DEC) , value = getNonNegativeInteger},
[19] = {name = "Any" , field = ProtoField.string("ndn.any", "Any") , value = getTrue},
- [32] = {name = "SelectedDelegation" , field = ProtoField.uint32("ndn.selected_delegation", "SelectedDelegation", base.DEC), value = getNonNegativeInteger},
+ [32] = {name = "SelectedDelegation" , field = ProtoField.uint64("ndn.selected_delegation", "SelectedDelegation", base.DEC), value = getNonNegativeInteger},
}
-- -- Add protofields in NDN protocol