A Discrete-Event Network Simulator
API
ethernet-header.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 Emmanuelle Laprise
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: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
19  */
20 
21 #ifndef ETHERNET_HEADER_H
22 #define ETHERNET_HEADER_H
23 
24 #include "ns3/header.h"
25 #include <string>
26 #include "ns3/mac48-address.h"
27 
28 namespace ns3 {
29 
37  LENGTH,
39  VLAN,
40  QINQ
41 };
52 class EthernetHeader : public Header
53 {
54 public:
55 
61  EthernetHeader (bool hasPreamble);
66  EthernetHeader ();
70  void SetLengthType (uint16_t size);
74  void SetSource (Mac48Address source);
78  void SetDestination (Mac48Address destination);
82  void SetPreambleSfd (uint64_t preambleSfd);
86  uint16_t GetLengthType (void) const;
90  ethernet_header_t GetPacketType (void) const;
94  Mac48Address GetSource (void) const;
98  Mac48Address GetDestination (void) const;
102  uint64_t GetPreambleSfd () const;
106  uint32_t GetHeaderSize () const;
107 
112  static TypeId GetTypeId (void);
113  virtual TypeId GetInstanceTypeId (void) const;
114  virtual void Print (std::ostream &os) const;
115  virtual uint32_t GetSerializedSize (void) const;
116  virtual void Serialize (Buffer::Iterator start) const;
117  virtual uint32_t Deserialize (Buffer::Iterator start);
118 private:
119  static const int PREAMBLE_SIZE = 8;
120  static const int LENGTH_SIZE = 2;
121  static const int MAC_ADDR_SIZE = 6;
122 
127  uint64_t m_preambleSfd;
128  uint16_t m_lengthType;
131 };
132 
133 } // namespace ns3
134 
135 
136 #endif /* ETHERNET_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:99
Packet header for Ethernet.
uint16_t m_lengthType
Length or type of the packet.
uint32_t GetHeaderSize() const
bool m_enPreambleSfd
If false, the preamble/sfd are not serialised/deserialised.
Mac48Address m_destination
Destination address.
void SetDestination(Mac48Address destination)
static TypeId GetTypeId(void)
Get the type ID.
static const int PREAMBLE_SIZE
size of the preamble_sfd header field
static const int MAC_ADDR_SIZE
size of src/dest addr header fields
Mac48Address m_source
Source address.
virtual void Print(std::ostream &os) const
void SetLengthType(uint16_t size)
void SetSource(Mac48Address source)
EthernetHeader()
Construct a null ethernet header By default, does not add or remove an ethernet preamble.
Mac48Address GetDestination(void) const
virtual uint32_t GetSerializedSize(void) const
Mac48Address GetSource(void) const
uint16_t GetLengthType(void) const
ethernet_header_t GetPacketType(void) const
uint64_t m_preambleSfd
Value of the Preamble/SFD fields.
void SetPreambleSfd(uint64_t preambleSfd)
virtual void Serialize(Buffer::Iterator start) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
static const int LENGTH_SIZE
size of the length_type header field
uint64_t GetPreambleSfd() const
Protocol header serialization and deserialization.
Definition: header.h:43
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
an EUI-48 address
Definition: mac48-address.h:44
a unique identifier for an interface.
Definition: type-id.h:59
ethernet_header_t
Types of ethernet packets.
@ LENGTH
Basic ethernet packet, no tags, type/length field indicates packet length or IP/ARP packet.
@ VLAN
Single tagged packet.
@ QINQ
Double tagged packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853