blob: 8272e86dd17806d7ebdc38e0c3cd6b9b0d3d3ec4 [file] [log] [blame]
Alexander Afanasyeve91ab752011-08-31 19:13:40 -07001#include "ns3/test.h"
2#include "ns3/annotated-topology-reader.h"
3#include "ns3/ccnx-content-object-header.h"
4#include "ns3/uinteger.h"
5#include "ns3/random-variable.h"
6#include <limits>
7#include "ns3/ccnx-header-helper.h"
8#include "ns3/header.h"
9#include "ns3/ccnx-name-components.h"
10#include "ns3/nstime.h"
11#include "ns3/buffer.h"
12#include "ns3/log.h"
13
14using namespace ns3;
15#include <fstream>
16
17NS_LOG_COMPONENT_DEFINE ("ContentObjectHeaderExample");
18
19int
20main (int argc, char *argv[])
21{
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080022 LogComponentEnable ("ContentObjectHeaderExample", LOG_ALL);
23 LogComponentEnable ("Packet", LOG_ALL);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070024
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080025 NS_LOG_INFO ("Test started");
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070026
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080027 Packet::EnablePrinting ();
28 Packet::EnableChecking ();
29 Packet packet (10);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070030
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080031 CcnxContentObjectHeader header;
32 CcnxContentObjectTail trailer;
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070033
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080034 Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> ();
35 (*testname) ("1");
36 header.SetName(testname);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070037
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080038 NS_LOG_INFO ("Source: \n" << header << trailer);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070039
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080040 packet.AddHeader (header);
41 packet.AddTrailer (trailer);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070042
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080043 // NS_LOG_INFO ("Deserialized packet: \n" << packet);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070044
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080045 NS_LOG_INFO ("Removing and deserializing individual headers");
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070046
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080047 CcnxContentObjectHeader dst_header;
48 CcnxContentObjectTail dst_trailer;
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070049
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080050 packet.RemoveHeader (dst_header);
51 packet.RemoveTrailer (dst_trailer);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070052
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080053 NS_LOG_INFO ("Target: \n" << dst_header << dst_trailer);
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070054
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -080055 return 0;
Alexander Afanasyeve91ab752011-08-31 19:13:40 -070056}