A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
test-asn1-encoding.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Lluis Parcerisa <lparcerisa@cttc.cat>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/string.h"
23 #include "ns3/double.h"
24 #include "ns3/enum.h"
25 #include "ns3/boolean.h"
26 #include "ns3/test.h"
27 #include "ns3/ptr.h"
28 #include "ns3/packet.h"
29 
30 #include "ns3/lte-rrc-header.h"
31 #include "ns3/lte-rrc-sap.h"
32 
33 NS_LOG_COMPONENT_DEFINE ("Asn1EncodingTest");
34 
35 namespace ns3 {
36 
37 class TestUtils
38 {
39 public:
40  // Function to convert packet contents in hex format
41  static std::string sprintPacketContentsHex (Ptr<Packet> pkt)
42  {
43  uint32_t psize = pkt->GetSize ();
44  uint8_t buffer[psize];
45  char sbuffer[psize * 3];
46  pkt->CopyData (buffer, psize);
47  for (uint32_t i = 0; i < psize; i++)
48  {
49  sprintf (&sbuffer[i * 3],"%02x ",buffer[i]);
50  }
51  return std::string (sbuffer);
52  }
53 
54  // Function to convert packet contents in binary format
55  static std::string sprintPacketContentsBin (Ptr<Packet> pkt)
56  {
57  uint32_t psize = pkt->GetSize ();
58  uint8_t buffer[psize];
59  std::ostringstream oss (std::ostringstream::out);
60  pkt->CopyData (buffer, psize);
61  for (uint32_t i = 0; i < psize; i++)
62  {
63  oss << (std::bitset<8> (buffer[i]));
64  }
65  return std::string (oss.str () + "\n");
66  }
67 
68  // Function to log packet contents
69  static void LogPacketContents (Ptr<Packet> pkt)
70  {
71  NS_LOG_DEBUG ("---- SERIALIZED PACKET CONTENTS (HEX): -------");
74  }
75 
76  template <class T>
77  static void LogPacketInfo (T source,std::string s)
78  {
79  NS_LOG_DEBUG ("--------- " << s.data () << " INFO: -------");
80  std::ostringstream oss (std::ostringstream::out);
81  source.Print (oss);
82  NS_LOG_DEBUG (oss.str ());
83  }
84 };
85 
86 // --------------------------- CLASS RrcHeaderTestCase -----------------------------
92 {
93 public:
94  RrcHeaderTestCase (std::string s);
95  virtual void DoRun (void) = 0;
98 
99 protected:
101 };
102 
104 {
105 }
106 
109 {
111 
112  rrd.drbToReleaseList = std::list<uint8_t> (4,2);
113 
114  LteRrcSap::SrbToAddMod srbToAddMod;
115  srbToAddMod.srbIdentity = 2;
116 
117  LteRrcSap::LogicalChannelConfig logicalChannelConfig;
118  logicalChannelConfig.priority = 9;
119  logicalChannelConfig.prioritizedBitRateKbps = 128;
120  logicalChannelConfig.bucketSizeDurationMs = 100;
121  logicalChannelConfig.logicalChannelGroup = 3;
122  srbToAddMod.logicalChannelConfig = logicalChannelConfig;
123 
124  rrd.srbToAddModList.insert (rrd.srbToAddModList.begin (),srbToAddMod);
125 
126  LteRrcSap::DrbToAddMod drbToAddMod;
127  drbToAddMod.epsBearerIdentity = 1;
128  drbToAddMod.drbIdentity = 1;
129  drbToAddMod.logicalChannelIdentity = 5;
130  LteRrcSap::RlcConfig rlcConfig;
132  drbToAddMod.rlcConfig = rlcConfig;
133 
134  LteRrcSap::LogicalChannelConfig logicalChannelConfig2;
135  logicalChannelConfig2.priority = 7;
136  logicalChannelConfig2.prioritizedBitRateKbps = 256;
137  logicalChannelConfig2.bucketSizeDurationMs = 50;
138  logicalChannelConfig2.logicalChannelGroup = 2;
139  drbToAddMod.logicalChannelConfig = logicalChannelConfig2;
140 
141  rrd.drbToAddModList.insert (rrd.drbToAddModList.begin (),drbToAddMod);
142 
143  rrd.havePhysicalConfigDedicated = true;
144  LteRrcSap::PhysicalConfigDedicated physicalConfigDedicated;
145  physicalConfigDedicated.haveSoundingRsUlConfigDedicated = true;
147  physicalConfigDedicated.soundingRsUlConfigDedicated.srsBandwidth = 2;
148  physicalConfigDedicated.soundingRsUlConfigDedicated.srsConfigIndex = 12;
149 
150  physicalConfigDedicated.haveAntennaInfoDedicated = true;
151  physicalConfigDedicated.antennaInfo.transmissionMode = 2;
152 
153  rrd.physicalConfigDedicated = physicalConfigDedicated;
154 
155  return rrd;
156 }
157 
158 void
160 {
161  NS_TEST_ASSERT_MSG_EQ (rrcd1.srbToAddModList.size (), rrcd2.srbToAddModList.size (),"SrbToAddModList different sizes");
162 
163  std::list<LteRrcSap::SrbToAddMod> srcSrbToAddModList = rrcd1.srbToAddModList;
164  std::list<LteRrcSap::SrbToAddMod>::iterator it1 = srcSrbToAddModList.begin ();
165  std::list<LteRrcSap::SrbToAddMod> dstSrbToAddModList = rrcd2.srbToAddModList;
166  std::list<LteRrcSap::SrbToAddMod>::iterator it2 = dstSrbToAddModList.begin ();
167 
168  for (; it1 != srcSrbToAddModList.end (); it1++, it2++)
169  {
170  NS_TEST_ASSERT_MSG_EQ (it1->srbIdentity,it2->srbIdentity, "srbIdentity");
171  NS_TEST_ASSERT_MSG_EQ (it1->logicalChannelConfig.priority,it2->logicalChannelConfig.priority, "logicalChannelConfig.priority");
172  NS_TEST_ASSERT_MSG_EQ (it1->logicalChannelConfig.prioritizedBitRateKbps,it2->logicalChannelConfig.prioritizedBitRateKbps, "logicalChannelConfig.prioritizedBitRateKbps");
173  NS_TEST_ASSERT_MSG_EQ (it1->logicalChannelConfig.bucketSizeDurationMs,it2->logicalChannelConfig.bucketSizeDurationMs, "logicalChannelConfig.bucketSizeDurationMs");
174  NS_TEST_ASSERT_MSG_EQ (it1->logicalChannelConfig.logicalChannelGroup,it2->logicalChannelConfig.logicalChannelGroup, "logicalChannelConfig.logicalChannelGroup");
175  }
176 
177  NS_TEST_ASSERT_MSG_EQ (rrcd1.drbToAddModList.size (), rrcd2.drbToAddModList.size (),"DrbToAddModList different sizes");
178 
179  std::list<LteRrcSap::DrbToAddMod> srcDrbToAddModList = rrcd1.drbToAddModList;
180  std::list<LteRrcSap::DrbToAddMod>::iterator it3 = srcDrbToAddModList.begin ();
181  std::list<LteRrcSap::DrbToAddMod> dstDrbToAddModList = rrcd2.drbToAddModList;
182  std::list<LteRrcSap::DrbToAddMod>::iterator it4 = dstDrbToAddModList.begin ();
183 
184  for (; it3 != srcDrbToAddModList.end (); it3++, it4++)
185  {
186  NS_TEST_ASSERT_MSG_EQ (it3->epsBearerIdentity,it4->epsBearerIdentity, "epsBearerIdentity");
187  NS_TEST_ASSERT_MSG_EQ (it3->drbIdentity,it4->drbIdentity, "drbIdentity");
188  NS_TEST_ASSERT_MSG_EQ (it3->rlcConfig.choice,it4->rlcConfig.choice, "rlcConfig.choice");
189  NS_TEST_ASSERT_MSG_EQ (it3->logicalChannelIdentity,it4->logicalChannelIdentity, "logicalChannelIdentity");
190  NS_TEST_ASSERT_MSG_EQ (it3->epsBearerIdentity,it4->epsBearerIdentity, "epsBearerIdentity");
191 
192  NS_TEST_ASSERT_MSG_EQ (it3->logicalChannelConfig.priority,it4->logicalChannelConfig.priority, "logicalChannelConfig.priority");
193  NS_TEST_ASSERT_MSG_EQ (it3->logicalChannelConfig.prioritizedBitRateKbps,it4->logicalChannelConfig.prioritizedBitRateKbps, "logicalChannelConfig.prioritizedBitRateKbps");
194  NS_TEST_ASSERT_MSG_EQ (it3->logicalChannelConfig.bucketSizeDurationMs,it4->logicalChannelConfig.bucketSizeDurationMs, "logicalChannelConfig.bucketSizeDurationMs");
195  NS_TEST_ASSERT_MSG_EQ (it3->logicalChannelConfig.logicalChannelGroup,it4->logicalChannelConfig.logicalChannelGroup, "logicalChannelConfig.logicalChannelGroup");
196  }
197 
198  NS_TEST_ASSERT_MSG_EQ (rrcd1.drbToReleaseList.size (), rrcd2.drbToReleaseList.size (),"DrbToReleaseList different sizes");
199 
200  std::list<uint8_t> srcDrbToReleaseList = rrcd1.drbToReleaseList;
201  std::list<uint8_t> dstDrbToReleaseList = rrcd2.drbToReleaseList;
202  std::list<uint8_t>::iterator it5 = srcDrbToReleaseList.begin ();
203  std::list<uint8_t>::iterator it6 = dstDrbToReleaseList.begin ();
204 
205  for (; it5 != srcDrbToReleaseList.end (); it5++, it6++)
206  {
207  NS_TEST_ASSERT_MSG_EQ (*it5, *it6,"element != in DrbToReleaseList");
208  }
209 
210  NS_TEST_ASSERT_MSG_EQ (rrcd1.havePhysicalConfigDedicated,rrcd2.havePhysicalConfigDedicated, "HavePhysicalConfigDedicated");
211 
212  if (rrcd1.havePhysicalConfigDedicated)
213  {
216  "haveSoundingRsUlConfigDedicated");
217 
220  "soundingRsUlConfigDedicated.type");
223  "soundingRsUlConfigDedicated.srsBandwidth");
224 
227  "soundingRsUlConfigDedicated.srsConfigIndex");
228 
231  "haveAntennaInfoDedicated");
232 
234  {
237  "antennaInfo.transmissionMode");
238  }
239  }
240 }
241 
242 // --------------------------- CLASS RrcConnectionRequestTestCase -----------------------------
244 {
245 public:
247  virtual void DoRun (void);
248 };
249 
251 {
252 }
253 
254 void
256 {
257  packet = Create<Packet> ();
258  NS_LOG_DEBUG ("============= RrcConnectionRequestTestCase ===========");
259 
261  msg.ueIdentity = 0x83fecafecaULL;
262 
264  source.SetMessage (msg);
265 
266  // Log source info
267  TestUtils::LogPacketInfo<RrcConnectionRequestHeader> (source,"SOURCE");
268 
269  // Add header
270  packet->AddHeader (source);
271 
272  // Log serialized packet contents
274 
275  // Remove header
276  RrcConnectionRequestHeader destination;
277  packet->RemoveHeader (destination);
278 
279  // Log destination info
280  TestUtils::LogPacketInfo<RrcConnectionRequestHeader> (destination,"DESTINATION");
281 
282  // Check that the destination and source headers contain the same values
283  NS_TEST_ASSERT_MSG_EQ (source.GetMmec (),destination.GetMmec (), "Different m_mmec!");
284  NS_TEST_ASSERT_MSG_EQ (source.GetMtmsi (),destination.GetMtmsi (), "Different m_mTmsi!");
285 
286  packet = 0;
287 }
288 
289 // --------------------------- CLASS RrcConnectionSetupTestCase -----------------------------
291 {
292 public:
294  virtual void DoRun (void);
295 };
296 
298 {
299 }
300 
301 void
303 {
304  packet = Create<Packet> ();
305  NS_LOG_DEBUG ("============= RrcConnectionSetupTestCase ===========");
306 
308  msg.rrcTransactionIdentifier = 3;
310 
312  source.SetMessage (msg);
313 
314  // Log source info
315  TestUtils::LogPacketInfo<RrcConnectionSetupHeader> (source,"SOURCE");
316 
317  // Add header
318  packet->AddHeader (source);
319 
320  // Log serialized packet contents
322 
323  // remove header
324  RrcConnectionSetupHeader destination;
325  packet->RemoveHeader (destination);
326 
327  // Log destination info
328  TestUtils::LogPacketInfo<RrcConnectionSetupHeader> (destination,"DESTINATION");
329 
330  // Check that the destination and source headers contain the same values
331  NS_TEST_ASSERT_MSG_EQ (source.GetRrcTransactionIdentifier (),destination.GetRrcTransactionIdentifier (), "RrcTransactionIdentifier");
332 
333  AssertEqualRadioResourceConfigDedicated (source.GetRadioResourceConfigDedicated (),destination.GetRadioResourceConfigDedicated ());
334 
335  packet = 0;
336 }
337 
338 // --------------------------- CLASS RrcConnectionSetupCompleteTestCase -----------------------------
340 {
341 public:
343  virtual void DoRun (void);
344 };
345 
347 {
348 }
349 
350 void
352 {
353  packet = Create<Packet> ();
354  NS_LOG_DEBUG ("============= RrcConnectionSetupCompleteTestCase ===========");
355 
357  msg.rrcTransactionIdentifier = 3;
358 
360  source.SetMessage (msg);
361 
362  // Log source info
363  TestUtils::LogPacketInfo<RrcConnectionSetupCompleteHeader> (source,"SOURCE");
364 
365  // Add header
366  packet->AddHeader (source);
367 
368  // Log serialized packet contents
370 
371  // Remove header
373  packet->RemoveHeader (destination);
374 
375  // Log destination info
376  TestUtils::LogPacketInfo<RrcConnectionSetupCompleteHeader> (destination,"DESTINATION");
377 
378  // Check that the destination and source headers contain the same values
379  NS_TEST_ASSERT_MSG_EQ (source.GetRrcTransactionIdentifier (),destination.GetRrcTransactionIdentifier (), "RrcTransactionIdentifier");
380 
381  packet = 0;
382 }
383 
384 // --------------------------- CLASS RrcConnectionReconfigurationCompleteTestCase -----------------------------
386 {
387 public:
389  virtual void DoRun (void);
390 };
391 
393  : RrcHeaderTestCase ("Testing RrcConnectionReconfigurationCompleteTestCase")
394 {
395 }
396 
397 void
399 {
400  packet = Create<Packet> ();
401  NS_LOG_DEBUG ("============= RrcConnectionReconfigurationCompleteTestCase ===========");
402 
404  msg.rrcTransactionIdentifier = 2;
405 
407  source.SetMessage (msg);
408 
409  // Log source info
410  TestUtils::LogPacketInfo<RrcConnectionReconfigurationCompleteHeader> (source,"SOURCE");
411 
412  // Add header
413  packet->AddHeader (source);
414 
415  // Log serialized packet contents
417 
418  // remove header
420  packet->RemoveHeader (destination);
421 
422  // Log destination info
423  TestUtils::LogPacketInfo<RrcConnectionReconfigurationCompleteHeader> (destination,"DESTINATION");
424 
425  // Check that the destination and source headers contain the same values
426  NS_TEST_ASSERT_MSG_EQ (source.GetRrcTransactionIdentifier (),destination.GetRrcTransactionIdentifier (), "RrcTransactionIdentifier");
427 
428  packet = 0;
429 }
430 
431 // --------------------------- CLASS RrcConnectionReconfigurationTestCase -----------------------------
433 {
434 public:
436  virtual void DoRun (void);
437 };
438 
440  : RrcHeaderTestCase ("Testing RrcConnectionReconfigurationTestCase")
441 {
442 }
443 
444 void
446 {
447  packet = Create<Packet> ();
448  NS_LOG_DEBUG ("============= RrcConnectionReconfigurationTestCase ===========");
449 
451  msg.rrcTransactionIdentifier = 2;
452 
453  msg.haveMeasConfig = true;
454 
455  msg.measConfig.haveQuantityConfig = true;
458 
459  msg.measConfig.haveMeasGapConfig = true;
463 
464  msg.measConfig.haveSmeasure = true;
465  msg.measConfig.sMeasure = 57;
466 
467  msg.measConfig.haveSpeedStatePars = true;
475 
476  msg.measConfig.measObjectToRemoveList.push_back (23);
477  msg.measConfig.measObjectToRemoveList.push_back (13);
478 
479  msg.measConfig.reportConfigToRemoveList.push_back (7);
480  msg.measConfig.reportConfigToRemoveList.push_back (16);
481 
482  msg.measConfig.measIdToRemoveList.push_back (4);
483  msg.measConfig.measIdToRemoveList.push_back (18);
484 
485  // TODO: Test the following:
486  // std::list<MeasObjectToAddMod> measObjectToAddModList;
487  // std::list<ReportConfigToAddMod> reportConfigToAddModList;
488  // std::list<MeasIdToAddMod> measIdToAddModList;
489 
490  msg.haveMobilityControlInfo = true;
505 
507 
509 
511  source.SetMessage (msg);
512 
513  // Log source info
514  TestUtils::LogPacketInfo<RrcConnectionReconfigurationHeader> (source,"SOURCE");
515 
516  // Add header
517  packet->AddHeader (source);
518 
519  // Log serialized packet contents
521 
522  // remove header
524  packet->RemoveHeader (destination);
525 
526  // Log destination info
527  TestUtils::LogPacketInfo<RrcConnectionReconfigurationHeader> (destination,"DESTINATION");
528 
529  // Check that the destination and source headers contain the same values
530  NS_TEST_ASSERT_MSG_EQ (source.GetRrcTransactionIdentifier (),destination.GetRrcTransactionIdentifier (), "RrcTransactionIdentifier");
531  NS_TEST_ASSERT_MSG_EQ (source.GetHaveMeasConfig (),destination.GetHaveMeasConfig (), "GetHaveMeasConfig");
532  NS_TEST_ASSERT_MSG_EQ (source.GetHaveMobilityControlInfo (),destination.GetHaveMobilityControlInfo (), "GetHaveMobilityControlInfo");
533  NS_TEST_ASSERT_MSG_EQ (source.GetHaveRadioResourceConfigDedicated (),destination.GetHaveRadioResourceConfigDedicated (), "GetHaveRadioResourceConfigDedicated");
534 
535  if ( source.GetHaveMobilityControlInfo () )
536  {
537  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().targetPhysCellId,destination.GetMobilityControlInfo ().targetPhysCellId, "GetMobilityControlInfo().targetPhysCellId");
538  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().haveCarrierFreq,destination.GetMobilityControlInfo ().haveCarrierFreq, "GetMobilityControlInfo().haveCarrierFreq");
539  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().haveCarrierBandwidth,destination.GetMobilityControlInfo ().haveCarrierBandwidth, "GetMobilityControlInfo().haveCarrierBandwidth");
540  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().newUeIdentity,destination.GetMobilityControlInfo ().newUeIdentity, "GetMobilityControlInfo().newUeIdentity");
541  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().haveRachConfigDedicated,destination.GetMobilityControlInfo ().haveRachConfigDedicated, "GetMobilityControlInfo().haveRachConfigDedicated");
542 
543  if (source.GetMobilityControlInfo ().haveCarrierFreq)
544  {
545  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().carrierFreq.dlCarrierFreq,
546  destination.GetMobilityControlInfo ().carrierFreq.dlCarrierFreq,
547  "GetMobilityControlInfo().carrierFreq.dlCarrierFreq");
548  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().carrierFreq.ulCarrierFreq,
549  destination.GetMobilityControlInfo ().carrierFreq.ulCarrierFreq,
550  "GetMobilityControlInfo().carrierFreq.ulCarrierFreq");
551  }
552 
553  if (source.GetMobilityControlInfo ().haveCarrierBandwidth)
554  {
555  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().carrierBandwidth.dlBandwidth,
556  destination.GetMobilityControlInfo ().carrierBandwidth.dlBandwidth,
557  "GetMobilityControlInfo().carrierBandwidth.dlBandwidth");
558  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().carrierBandwidth.ulBandwidth,
559  destination.GetMobilityControlInfo ().carrierBandwidth.ulBandwidth,
560  "GetMobilityControlInfo().carrierBandwidth.ulBandwidth");
561  }
562 
563  if (source.GetMobilityControlInfo ().haveRachConfigDedicated)
564  {
565  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().rachConfigDedicated.raPreambleIndex,
566  destination.GetMobilityControlInfo ().rachConfigDedicated.raPreambleIndex,
567  "GetMobilityControlInfo().rachConfigDedicated.raPreambleIndex");
568  NS_TEST_ASSERT_MSG_EQ (source.GetMobilityControlInfo ().rachConfigDedicated.raPrachMaskIndex,
569  destination.GetMobilityControlInfo ().rachConfigDedicated.raPrachMaskIndex,
570  "GetMobilityControlInfo().rachConfigDedicated.raPrachMaskIndex");
571  }
572  }
573 
574  if (source.GetHaveRadioResourceConfigDedicated ())
575  {
576  AssertEqualRadioResourceConfigDedicated (source.GetRadioResourceConfigDedicated (), destination.GetRadioResourceConfigDedicated ());
577  }
578 
579  packet = 0;
580 }
581 
582 // --------------------------- CLASS HandoverPreparationInfoTestCase -----------------------------
584 {
585 public:
587  virtual void DoRun (void);
588 };
589 
591 {
592 }
593 
594 void
596 {
597  packet = Create<Packet> ();
598  NS_LOG_DEBUG ("============= HandoverPreparationInfoTestCase ===========");
599 
602  msg.asConfig.sourceUeIdentity = 11;
606 
611 
617 
622 
624  source.SetMessage (msg);
625 
626  // Log source info
627  TestUtils::LogPacketInfo<HandoverPreparationInfoHeader> (source,"SOURCE");
628 
629  // Add header
630  packet->AddHeader (source);
631 
632  // Log serialized packet contents
634 
635  // remove header
636  HandoverPreparationInfoHeader destination;
637  packet->RemoveHeader (destination);
638 
639  // Log destination info
640  TestUtils::LogPacketInfo<HandoverPreparationInfoHeader> (destination,"DESTINATION");
641 
642  // Check that the destination and source headers contain the same values
643  AssertEqualRadioResourceConfigDedicated (source.GetAsConfig ().sourceRadioResourceConfig, destination.GetAsConfig ().sourceRadioResourceConfig);
644  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceUeIdentity, destination.GetAsConfig ().sourceUeIdentity, "sourceUeIdentity");
645  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceMasterInformationBlock.dlBandwidth,destination.GetAsConfig ().sourceMasterInformationBlock.dlBandwidth, "dlBandwidth");
646  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceMasterInformationBlock.systemFrameNumber, destination.GetAsConfig ().sourceMasterInformationBlock.systemFrameNumber, "systemFrameNumber");
647  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity, destination.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity, "plmnIdentity");
648  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIndication, destination.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIndication, "csgIndication");
649  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.cellIdentity, destination.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.cellIdentity, "cellIdentity");
650  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIdentity, destination.GetAsConfig ().sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIdentity, "csgIdentity");
651  NS_TEST_ASSERT_MSG_EQ (source.GetAsConfig ().sourceDlCarrierFreq, destination.GetAsConfig ().sourceDlCarrierFreq, "sourceDlCarrierFreq");
652 
653  packet = 0;
654 }
655 
656 // --------------------------- CLASS RrcConnectionReestablishmentRequestTestCase -----------------------------
658 {
659 public:
661  virtual void DoRun (void);
662 };
663 
665 {
666 }
667 
668 void
670 {
671  packet = Create<Packet> ();
672  NS_LOG_DEBUG ("============= RrcConnectionReestablishmentRequestTestCase ===========");
673 
675  msg.ueIdentity.cRnti = 12;
676  msg.ueIdentity.physCellId = 21;
678 
680  source.SetMessage (msg);
681 
682  // Log source info
683  TestUtils::LogPacketInfo<RrcConnectionReestablishmentRequestHeader> (source,"SOURCE");
684 
685  // Add header
686  packet->AddHeader (source);
687 
688  // Log serialized packet contents
690 
691  // remove header
693  packet->RemoveHeader (destination);
694 
695  // Log destination info
696  TestUtils::LogPacketInfo<RrcConnectionReestablishmentRequestHeader> (destination,"DESTINATION");
697 
698  // Check that the destination and source headers contain the same values
699  NS_TEST_ASSERT_MSG_EQ (source.GetUeIdentity ().cRnti, destination.GetUeIdentity ().cRnti, "cRnti");
700  NS_TEST_ASSERT_MSG_EQ (source.GetUeIdentity ().physCellId, destination.GetUeIdentity ().physCellId, "physCellId");
701  NS_TEST_ASSERT_MSG_EQ (source.GetReestablishmentCause (),destination.GetReestablishmentCause (), "ReestablishmentCause");
702 
703  packet = 0;
704 }
705 
706 // --------------------------- CLASS RrcConnectionReestablishmentTestCase -----------------------------
708 {
709 public:
711  virtual void DoRun (void);
712 };
713 
715 {
716 }
717 
718 void
720 {
721  packet = Create<Packet> ();
722  NS_LOG_DEBUG ("============= RrcConnectionReestablishmentTestCase ===========");
723 
725  msg.rrcTransactionIdentifier = 2;
727 
729  source.SetMessage (msg);
730 
731  // Log source info
732  TestUtils::LogPacketInfo<RrcConnectionReestablishmentHeader> (source,"SOURCE");
733 
734  // Add header
735  packet->AddHeader (source);
736 
737  // Log serialized packet contents
739 
740  // remove header
742  packet->RemoveHeader (destination);
743 
744  // Log destination info
745  TestUtils::LogPacketInfo<RrcConnectionReestablishmentHeader> (destination,"DESTINATION");
746 
747  // Check that the destination and source headers contain the same values
748  NS_TEST_ASSERT_MSG_EQ (source.GetRrcTransactionIdentifier (), destination.GetRrcTransactionIdentifier (), "rrcTransactionIdentifier");
749  AssertEqualRadioResourceConfigDedicated (source.GetRadioResourceConfigDedicated (),destination.GetRadioResourceConfigDedicated ());
750 
751  packet = 0;
752 }
753 
754 // --------------------------- CLASS RrcConnectionReestablishmentCompleteTestCase -----------------------------
756 {
757 public:
759  virtual void DoRun (void);
760 };
761 
763 {
764 }
765 
766 void
768 {
769  packet = Create<Packet> ();
770  NS_LOG_DEBUG ("============= RrcConnectionReestablishmentCompleteTestCase ===========");
771 
773  msg.rrcTransactionIdentifier = 3;
774 
776  source.SetMessage (msg);
777 
778  // Log source info
779  TestUtils::LogPacketInfo<RrcConnectionReestablishmentCompleteHeader> (source,"SOURCE");
780 
781  // Add header
782  packet->AddHeader (source);
783 
784  // Log serialized packet contents
786 
787  // remove header
789  packet->RemoveHeader (destination);
790 
791  // Log destination info
792  TestUtils::LogPacketInfo<RrcConnectionReestablishmentCompleteHeader> (destination,"DESTINATION");
793 
794  // Check that the destination and source headers contain the same values
795  NS_TEST_ASSERT_MSG_EQ (source.GetRrcTransactionIdentifier (), destination.GetRrcTransactionIdentifier (), "rrcTransactionIdentifier");
796 
797  packet = 0;
798 }
799 
800 // --------------------------- CLASS RrcConnectionRejectTestCase -----------------------------
802 {
803 public:
805  virtual void DoRun (void);
806 };
807 
809 {
810 }
811 
812 void
814 {
815  packet = Create<Packet> ();
816  NS_LOG_DEBUG ("============= RrcConnectionRejectTestCase ===========");
817 
819  msg.waitTime = 2;
820 
822  source.SetMessage (msg);
823 
824  // Log source info
825  TestUtils::LogPacketInfo<RrcConnectionRejectHeader> (source,"SOURCE");
826 
827  // Add header
828  packet->AddHeader (source);
829 
830  // Log serialized packet contents
832 
833  // remove header
834  RrcConnectionRejectHeader destination;
835  packet->RemoveHeader (destination);
836 
837  // Log destination info
838  TestUtils::LogPacketInfo<RrcConnectionRejectHeader> (destination,"DESTINATION");
839 
840  // Check that the destination and source headers contain the same values
841  NS_TEST_ASSERT_MSG_EQ (source.GetMessage ().waitTime, destination.GetMessage ().waitTime, "Different waitTime!");
842 
843  packet = 0;
844 }
845 
846 // --------------------------- CLASS MeasurementReportTestCase -----------------------------
848 {
849 public:
851  virtual void DoRun (void);
852 };
853 
855 {
856 }
857 
858 void
860 {
861  packet = Create<Packet> ();
862  NS_LOG_DEBUG ("============= MeasurementReportTestCase ===========");
863 
865  msg.measResults.measId = 5;
866  msg.measResults.rsrpResult = 18;
867  msg.measResults.rsrqResult = 21;
869 
870  LteRrcSap::MeasResultEutra mResEutra;
871  mResEutra.physCellId = 9;
872  mResEutra.haveRsrpResult = true;
873  mResEutra.rsrpResult = 33;
874  mResEutra.haveRsrqResult = true;
875  mResEutra.rsrqResult = 22;
876  mResEutra.haveCgiInfo = true;
877  mResEutra.cgiInfo.plmnIdentity = 7;
878  mResEutra.cgiInfo.cellIdentity = 6;
879  mResEutra.cgiInfo.trackingAreaCode = 5;
880  msg.measResults.measResultListEutra.push_back (mResEutra);
881 
882 
884  source.SetMessage (msg);
885 
886  // Log source info
887  TestUtils::LogPacketInfo<MeasurementReportHeader> (source,"SOURCE");
888 
889  // Add header
890  packet->AddHeader (source);
891 
892  // Log serialized packet contents
894 
895  // remove header
896  MeasurementReportHeader destination;
897  packet->RemoveHeader (destination);
898 
899  // Log destination info
900  TestUtils::LogPacketInfo<MeasurementReportHeader> (destination,"DESTINATION");
901 
902  // Check that the destination and source headers contain the same values
903  LteRrcSap::MeasResults srcMeas = source.GetMessage ().measResults;
904  LteRrcSap::MeasResults dstMeas = destination.GetMessage ().measResults;
905 
906  NS_TEST_ASSERT_MSG_EQ (srcMeas.measId, dstMeas.measId, "Different measId!");
907  NS_TEST_ASSERT_MSG_EQ (srcMeas.rsrpResult, dstMeas.rsrpResult, "Different rsrpResult!");
908  NS_TEST_ASSERT_MSG_EQ (srcMeas.rsrqResult, dstMeas.rsrqResult, "Different rsrqResult!");
909  NS_TEST_ASSERT_MSG_EQ (srcMeas.haveMeasResultNeighCells, dstMeas.haveMeasResultNeighCells, "Different haveMeasResultNeighCells!");
910 
911  if (srcMeas.haveMeasResultNeighCells)
912  {
913  std::list<LteRrcSap::MeasResultEutra>::iterator itsrc = srcMeas.measResultListEutra.begin ();
914  std::list<LteRrcSap::MeasResultEutra>::iterator itdst = dstMeas.measResultListEutra.begin ();
915  for (; itsrc != srcMeas.measResultListEutra.end (); itsrc++, itdst++)
916  {
917  NS_TEST_ASSERT_MSG_EQ (itsrc->physCellId, itdst->physCellId, "Different physCellId!");
918 
919  NS_TEST_ASSERT_MSG_EQ (itsrc->haveCgiInfo, itdst->haveCgiInfo, "Different haveCgiInfo!");
920  if (itsrc->haveCgiInfo)
921  {
922  NS_TEST_ASSERT_MSG_EQ (itsrc->cgiInfo.plmnIdentity, itdst->cgiInfo.plmnIdentity, "Different cgiInfo.plmnIdentity!");
923  NS_TEST_ASSERT_MSG_EQ (itsrc->cgiInfo.cellIdentity, itdst->cgiInfo.cellIdentity, "Different cgiInfo.cellIdentity!");
924  NS_TEST_ASSERT_MSG_EQ (itsrc->cgiInfo.trackingAreaCode, itdst->cgiInfo.trackingAreaCode, "Different cgiInfo.trackingAreaCode!");
925  NS_TEST_ASSERT_MSG_EQ (itsrc->cgiInfo.plmnIdentityList.size (), itdst->cgiInfo.plmnIdentityList.size (), "Different cgiInfo.plmnIdentityList.size()!");
926 
927  if (!itsrc->cgiInfo.plmnIdentityList.empty ())
928  {
929  std::list<uint32_t>::iterator itsrc2 = itsrc->cgiInfo.plmnIdentityList.begin ();
930  std::list<uint32_t>::iterator itdst2 = itdst->cgiInfo.plmnIdentityList.begin ();
931  for (; itsrc2 != itsrc->cgiInfo.plmnIdentityList.begin (); itsrc2++, itdst2++)
932  {
933  NS_TEST_ASSERT_MSG_EQ (*itsrc2, *itdst2, "Different plmnId elements!");
934  }
935  }
936  }
937 
938  NS_TEST_ASSERT_MSG_EQ (itsrc->haveRsrpResult, itdst->haveRsrpResult, "Different haveRsrpResult!");
939  if (itsrc->haveRsrpResult)
940  {
941  NS_TEST_ASSERT_MSG_EQ (itsrc->rsrpResult, itdst->rsrpResult, "Different rsrpResult!");
942  }
943 
944  NS_TEST_ASSERT_MSG_EQ (itsrc->haveRsrqResult, itdst->haveRsrqResult, "Different haveRsrqResult!");
945  if (itsrc->haveRsrqResult)
946  {
947  NS_TEST_ASSERT_MSG_EQ (itsrc->rsrqResult, itdst->rsrqResult, "Different rsrqResult!");
948  }
949 
950  }
951  }
952 
953  packet = 0;
954 }
955 
956 // --------------------------- CLASS Asn1EncodingSuite -----------------------------
958 {
959 public:
961 };
962 
964  : TestSuite ("test-asn1-encoding", UNIT)
965 {
966  NS_LOG_FUNCTION (this);
978 }
979 
981 
982 } // namespace ns3
983