A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  VLAN,
39 };
50 class EthernetHeader : public Header
51 {
52 public:
53 
59  EthernetHeader (bool hasPreamble);
64  EthernetHeader ();
68  void SetLengthType (uint16_t size);
72  void SetSource (Mac48Address source);
76  void SetDestination (Mac48Address destination);
80  void SetPreambleSfd (uint64_t preambleSfd);
84  uint16_t GetLengthType (void) const;
88  ethernet_header_t GetPacketType (void) const;
92  Mac48Address GetSource (void) const;
96  Mac48Address GetDestination (void) const;
100  uint64_t GetPreambleSfd () const;
104  uint32_t GetHeaderSize () const;
105 
106  static TypeId GetTypeId (void);
107  virtual TypeId GetInstanceTypeId (void) const;
108  virtual void Print (std::ostream &os) const;
109  virtual uint32_t GetSerializedSize (void) const;
110  virtual void Serialize (Buffer::Iterator start) const;
111  virtual uint32_t Deserialize (Buffer::Iterator start);
112 private:
113  static const int PREAMBLE_SIZE = 8;
114  static const int LENGTH_SIZE = 2;
115  static const int MAC_ADDR_SIZE = 6;
116 
121  uint64_t m_preambleSfd;
122  uint16_t m_lengthType;
125 };
126 
127 } // namespace ns3
128 
129 
130 #endif /* ETHERNET_HEADER_H */
Protocol header serialization and deserialization.
Definition: header.h:42
static TypeId GetTypeId(void)
virtual void Print(std::ostream &os) const
static const int PREAMBLE_SIZE
uint16_t GetLengthType(void) const
void SetSource(Mac48Address source)
iterator in a Buffer instance
Definition: buffer.h:98
Single tagged packet.
uint32_t GetHeaderSize() const
virtual void Serialize(Buffer::Iterator start) const
Mac48Address m_destination
Source address.
void SetPreambleSfd(uint64_t preambleSfd)
EthernetHeader()
Construct a null ethernet header By default, does not add or remove an ethernet preamble.
Basic ethernet packet, no tags, type/length field indicates packet length or IP/ARP packet...
an EUI-48 address
Definition: mac48-address.h:41
Packet header for Ethernet.
Double tagged packet.
uint64_t GetPreambleSfd() const
virtual uint32_t Deserialize(Buffer::Iterator start)
Mac48Address GetSource(void) const
Mac48Address GetDestination(void) const
ethernet_header_t
Types of ethernet packets.
virtual TypeId GetInstanceTypeId(void) const
uint16_t m_lengthType
Value of the Preamble/SFD fields.
virtual uint32_t GetSerializedSize(void) const
Mac48Address m_source
Length or type of the packet.
static const int MAC_ADDR_SIZE
size of the length_type header field
static const int LENGTH_SIZE
size of the preamble_sfd header field
void SetLengthType(uint16_t size)
bool m_enPreambleSfd
size of src/dest addr header fields
ethernet_header_t GetPacketType(void) const
void SetDestination(Mac48Address destination)
a unique identifier for an interface.
Definition: type-id.h:49