model: Fixing bug with wire format handling
When decoding Data/Interest packets, wire format was set and then
immediately (indirectly) reset to 0, leading to incorrect tracing
results (and, most likely, unnecessary performance regression).
Thanks to Tun Tun Oo for reporting the bug!
diff --git a/model/wire/ccnb/wire-ccnb-data.cc b/model/wire/ccnb/wire-ccnb-data.cc
index 0cb0b81..3b18717 100644
--- a/model/wire/ccnb/wire-ccnb-data.cc
+++ b/model/wire/ccnb/wire-ccnb-data.cc
@@ -165,13 +165,14 @@
static DataTrailer trailer;
Ptr<ndn::Data> data = Create<ndn::Data> ();
- data->SetWire (packet->Copy ());
+ Ptr<Packet> wire = packet->Copy ();
Data wireEncoding (data);
packet->RemoveHeader (wireEncoding);
packet->RemoveTrailer (trailer);
data->SetPayload (packet);
+ data->SetWire (wire);
return data;
}
diff --git a/model/wire/ccnb/wire-ccnb-interest.cc b/model/wire/ccnb/wire-ccnb-interest.cc
index f1711f8..af4fc0f 100644
--- a/model/wire/ccnb/wire-ccnb-interest.cc
+++ b/model/wire/ccnb/wire-ccnb-interest.cc
@@ -100,12 +100,13 @@
Interest::FromWire (Ptr<Packet> packet)
{
Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- interest->SetWire (packet->Copy ());
+ Ptr<Packet> wire = packet->Copy ();
Interest wireEncoding (interest);
packet->RemoveHeader (wireEncoding);
interest->SetPayload (packet);
+ interest->SetWire (wire);
return interest;
}
diff --git a/model/wire/ndnsim.cc b/model/wire/ndnsim.cc
index f1bbaf5..4668a79 100644
--- a/model/wire/ndnsim.cc
+++ b/model/wire/ndnsim.cc
@@ -87,12 +87,13 @@
Interest::FromWire (Ptr<Packet> packet)
{
Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- interest->SetWire (packet->Copy ());
+ Ptr<Packet> wire = packet->Copy ();
Interest wireEncoding (interest);
packet->RemoveHeader (wireEncoding);
interest->SetPayload (packet);
+ interest->SetWire (wire);
return interest;
}
@@ -251,12 +252,13 @@
Data::FromWire (Ptr<Packet> packet)
{
Ptr<ndn::Data> data = Create<ndn::Data> ();
- data->SetWire (packet->Copy ());
+ Ptr<Packet> wire = packet->Copy ();
Data wireEncoding (data);
packet->RemoveHeader (wireEncoding);
data->SetPayload (packet);
+ data->SetWire (wire);
return data;
}