Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 1 | #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 | |
| 14 | using namespace ns3; |
| 15 | #include <fstream> |
| 16 | |
| 17 | NS_LOG_COMPONENT_DEFINE ("ContentObjectHeaderExample"); |
| 18 | |
| 19 | int |
| 20 | main (int argc, char *argv[]) |
| 21 | { |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 22 | LogComponentEnable ("ContentObjectHeaderExample", LOG_ALL); |
| 23 | LogComponentEnable ("Packet", LOG_ALL); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 25 | NS_LOG_INFO ("Test started"); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 27 | Packet::EnablePrinting (); |
| 28 | Packet::EnableChecking (); |
| 29 | Packet packet (10); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 30 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 31 | CcnxContentObjectHeader header; |
| 32 | CcnxContentObjectTail trailer; |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 33 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 34 | Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> (); |
| 35 | (*testname) ("1"); |
| 36 | header.SetName(testname); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 37 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 38 | NS_LOG_INFO ("Source: \n" << header << trailer); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 39 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 40 | packet.AddHeader (header); |
| 41 | packet.AddTrailer (trailer); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 42 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 43 | // NS_LOG_INFO ("Deserialized packet: \n" << packet); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 44 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 45 | NS_LOG_INFO ("Removing and deserializing individual headers"); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 46 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 47 | CcnxContentObjectHeader dst_header; |
| 48 | CcnxContentObjectTail dst_trailer; |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 49 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 50 | packet.RemoveHeader (dst_header); |
| 51 | packet.RemoveTrailer (dst_trailer); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 52 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 53 | NS_LOG_INFO ("Target: \n" << dst_header << dst_trailer); |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 54 | |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 55 | return 0; |
Alexander Afanasyev | e91ab75 | 2011-08-31 19:13:40 -0700 | [diff] [blame] | 56 | } |