A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aloha-noack-mac-header.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 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: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #include <ns3/log.h>
22 #include "aloha-noack-mac-header.h"
23 
24 
25 NS_LOG_COMPONENT_DEFINE ("AlohaNoackMacHeader");
26 
27 namespace ns3 {
28 
29 NS_OBJECT_ENSURE_REGISTERED (AlohaNoackMacHeader);
30 
31 TypeId
33 {
34  static TypeId tid = TypeId ("ns3::AlohaNoackMacHeader")
35  .SetParent<Header> ()
36  .AddConstructor<AlohaNoackMacHeader> ()
37  ;
38  return tid;
39 }
40 
41 TypeId
43 {
44  return GetTypeId ();
45 }
46 
47 
48 
49 uint32_t
51 {
52  return 12;
53 }
54 
55 
56 
57 void
59 {
60  WriteTo (start, m_destination);
61  WriteTo (start, m_source);
62 }
63 
64 uint32_t
66 {
67  ReadFrom (start, m_destination);
68  ReadFrom (start, m_source);
69  return GetSerializedSize ();
70 }
71 
72 
73 void
74 AlohaNoackMacHeader::Print (std::ostream &os) const
75 {
76  os << "src=" << m_source
77  << "dst=" << m_destination;
78 }
79 
80 
81 void
83 {
84  m_source = source;
85 }
86 
89 {
90  return m_source;
91 }
92 
93 void
95 {
96  m_destination = dst;
97 }
98 
101 {
102  return m_destination;
103 }
104 
105 
106 
107 
108 } // namespace ns3
109 
110 
Protocol header serialization and deserialization.
Definition: header.h:42
virtual void Serialize(Buffer::Iterator start) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
virtual uint32_t GetSerializedSize(void) const
virtual void Print(std::ostream &os) const
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
iterator in a Buffer instance
Definition: buffer.h:98
virtual uint32_t Deserialize(Buffer::Iterator start)
void SetDestination(Mac48Address destination)
an EUI-48 address
Definition: mac48-address.h:41
Mac48Address GetSource() const
virtual TypeId GetInstanceTypeId(void) const
void SetSource(Mac48Address source)
Mac48Address GetDestination() const
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610