ns-3
ns3::EthernetHeader Class Reference

Packet header for Ethernet. More...

#include <ethernet-header.h>

Inheritance diagram for ns3::EthernetHeader:
Collaboration diagram for ns3::EthernetHeader:

List of all members.

Public Member Functions

 EthernetHeader (bool hasPreamble)
 Construct a null ethernet header.
 EthernetHeader ()
 Construct a null ethernet header By default, does not add or remove an ethernet preamble.
void SetLengthType (uint16_t size)
void SetSource (Mac48Address source)
void SetDestination (Mac48Address destination)
void SetPreambleSfd (uint64_t preambleSfd)
uint16_t GetLengthType (void) const
ethernet_header_t GetPacketType (void) const
Mac48Address GetSource (void) const
Mac48Address GetDestination (void) const
uint64_t GetPreambleSfd () const
uint32_t GetHeaderSize () const
virtual TypeId GetInstanceTypeId (void) const
virtual void Print (std::ostream &os) const
virtual uint32_t GetSerializedSize (void) const
virtual void Serialize (Buffer::Iterator start) const
virtual uint32_t Deserialize (Buffer::Iterator start)

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::EthernetHeader.

Detailed Description

Packet header for Ethernet.

This class can be used to add a header to an ethernet packet that will specify the source and destination addresses and the length of the packet. Eventually the class will be improved to also support VLAN tags in packet headers.


Constructor & Destructor Documentation

ns3::EthernetHeader::EthernetHeader ( bool  hasPreamble)

Construct a null ethernet header.

Parameters:
hasPreambleif true, insert and remove an ethernet preamble from the packet, if false, does not insert and remove it.

Member Function Documentation

uint32_t ns3::EthernetHeader::Deserialize ( Buffer::Iterator  start)
virtual
Parameters:
startan iterator which points to where the header should written.
Returns:
the number of bytes read.

This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet. The data read is expected to match bit-for-bit the representation of this header in real networks.

Implements ns3::Header.

References GetSerializedSize(), ns3::Buffer::Iterator::ReadNtohU16(), and ns3::Buffer::Iterator::ReadU64().

Mac48Address ns3::EthernetHeader::GetDestination ( void  ) const
Returns:
The destination address of this packet

Referenced by ns3::CsmaNetDevice::Receive().

uint32_t ns3::EthernetHeader::GetHeaderSize ( void  ) const
Returns:
The size of the header

References GetSerializedSize().

TypeId ns3::EthernetHeader::GetInstanceTypeId ( void  ) const
virtual
Returns:
the TypeId associated to the most-derived type of this instance.

This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.

Implements ns3::ObjectBase.

References GetTypeId().

uint16_t ns3::EthernetHeader::GetLengthType ( void  ) const
Returns:
The size of the payload in bytes

Referenced by ns3::CsmaNetDevice::Receive().

ethernet_header_t ns3::EthernetHeader::GetPacketType ( void  ) const
Returns:
The type of packet (only basic Ethernet is currently supported)

References ns3::LENGTH.

uint64_t ns3::EthernetHeader::GetPreambleSfd ( void  ) const
Returns:
The value of the PreambleSfd field
uint32_t ns3::EthernetHeader::GetSerializedSize ( void  ) const
virtual
Returns:
the expected size of the header.

This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. This method should return the number of bytes which are needed to store the full header data by Serialize.

Implements ns3::Header.

Referenced by Deserialize(), and GetHeaderSize().

Mac48Address ns3::EthernetHeader::GetSource ( void  ) const
Returns:
The source address of this packet

Referenced by ns3::CsmaNetDevice::Receive().

TypeId ns3::EthernetHeader::GetTypeId ( void  )
static

This method returns the TypeId associated to ns3::EthernetHeader.

No Attributes defined for this type.
No TraceSources defined for this type.

Reimplemented from ns3::Header.

References ns3::TypeId::SetParent().

Referenced by GetInstanceTypeId().

void ns3::EthernetHeader::Print ( std::ostream &  os) const
virtual
Parameters:
osoutput stream This method is used by Packet::Print to print the content of a trailer as ascii data to a c++ output stream. Although the trailer is free to format its output as it wishes, it is recommended to follow a few rules to integrate with the packet pretty printer: start with flags, small field values located between a pair of parens. Values should be separated by whitespace. Follow the parens with the important fields, separated by whitespace. i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5

Implements ns3::Header.

void ns3::EthernetHeader::Serialize ( Buffer::Iterator  start) const
virtual
Parameters:
startan iterator which points to where the header should be written.

This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. The data written is expected to match bit-for-bit the representation of this header in a real network.

Implements ns3::Header.

References ns3::Buffer::Iterator::WriteHtonU16(), and ns3::Buffer::Iterator::WriteU64().

void ns3::EthernetHeader::SetDestination ( Mac48Address  destination)
Parameters:
destinationThe destination address of this packet.

Referenced by ns3::CsmaNetDevice::AddHeader(), and ns3::EmuNetDevice::SendFrom().

void ns3::EthernetHeader::SetLengthType ( uint16_t  size)
Parameters:
sizeThe size of the payload in bytes

Referenced by ns3::CsmaNetDevice::AddHeader(), and ns3::EmuNetDevice::SendFrom().

void ns3::EthernetHeader::SetPreambleSfd ( uint64_t  preambleSfd)
Parameters:
preambleSfdThe value that the preambleSfd field should take
void ns3::EthernetHeader::SetSource ( Mac48Address  source)
Parameters:
sourceThe source address of this packet

Referenced by ns3::CsmaNetDevice::AddHeader(), and ns3::EmuNetDevice::SendFrom().


The documentation for this class was generated from the following files: