src/internet/model/ipv4-header.cc
author Adrian S Tam <adrian.sw.tam@gmail.com>
Wed, 07 Dec 2011 11:22:10 -0500
changeset 7619 b4dee6307aa7
parent 7566 aa5b5f290a0d
child 8829 b425987e55df
permissions -rw-r--r--
Nagle's algorithm in TCP (closes bug 1039)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7315
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005 INRIA
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
286
57e6a2006962 convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 235
diff changeset
    21
#include "ns3/assert.h"
7315
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
    22
#include "ns3/abort.h"
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1236
diff changeset
    23
#include "ns3/log.h"
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "ns3/header.h"
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include "ipv4-header.h"
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1236
diff changeset
    27
NS_LOG_COMPONENT_DEFINE ("Ipv4Header");
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
1236
cfa5e0b39281 rework the NS_XX_ENSURE_REGISTERED macros and make sure we typecheck the input to TraceContext::Add and TraceContext::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1234
diff changeset
    29
namespace ns3 {
1152
1d06449f0a98 macros to ensure proper initialization
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1151
diff changeset
    30
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
    31
NS_OBJECT_ENSURE_REGISTERED (Ipv4Header);
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
Ipv4Header::Ipv4Header ()
3235
c2f34dac1b9e add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3234
diff changeset
    34
  : m_calcChecksum (false),
c2f34dac1b9e add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3234
diff changeset
    35
    m_payloadSize (0),
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
    m_identification (0),
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
    m_tos (0),
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
    m_ttl (0),
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
    m_protocol (0),
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
    m_flags (0),
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
    m_fragmentOffset (0),
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
    42
    m_checksum (0),
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
    m_goodChecksum (true)
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    44
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    45
}
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    47
void
3235
c2f34dac1b9e add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3234
diff changeset
    48
Ipv4Header::EnableChecksum (void)
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  m_calcChecksum = true;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    53
void
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
Ipv4Header::SetPayloadSize (uint16_t size)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
  m_payloadSize = size;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    58
uint16_t
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
Ipv4Header::GetPayloadSize (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
  return m_payloadSize;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    64
uint16_t
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
Ipv4Header::GetIdentification (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
  return m_identification;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    69
void
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
Ipv4Header::SetIdentification (uint16_t identification)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
  m_identification = identification;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
Ipv4Header::SetTos (uint8_t tos)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
  m_tos = tos;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
}
7566
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    80
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    81
void
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    82
Ipv4Header::SetDscp (DscpType dscp)
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    83
{
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    84
  m_tos &= 0x3; // Clear out the DSCP part, retain 2 bits of ECN
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    85
  m_tos |= dscp;
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    86
}
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    87
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    88
void
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    89
Ipv4Header::SetEcn (EcnType ecn)
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    90
{
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    91
  m_tos &= 0xFC; // Clear out the ECN part, retain 6 bits of DSCP
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    92
  m_tos |= ecn;
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    93
}
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    94
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    95
Ipv4Header::DscpType 
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    96
Ipv4Header::GetDscp (void) const
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    97
{
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    98
  // Extract only first 6 bits of TOS byte, i.e 0xFC
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
    99
  return DscpType (m_tos & 0xFC);
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   100
}
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   101
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   102
std::string 
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   103
Ipv4Header::DscpTypeToString (DscpType dscp) const
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   104
{
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   105
  switch (dscp)
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   106
    {
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   107
      case DscpDefault:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   108
        return "Default";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   109
      case CS1:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   110
        return "CS1";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   111
      case AF11:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   112
        return "AF11";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   113
      case AF12:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   114
        return "AF12";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   115
      case AF13:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   116
        return "AF13";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   117
      case CS2:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   118
        return "CS2";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   119
      case AF21:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   120
        return "AF21";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   121
      case AF22:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   122
        return "AF22";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   123
      case AF23:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   124
        return "AF23";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   125
      case CS3:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   126
        return "CS3";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   127
      case AF31:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   128
        return "AF31";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   129
      case AF32:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   130
        return "AF32";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   131
      case AF33:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   132
        return "AF33";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   133
      case CS4:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   134
        return "CS4";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   135
      case AF41:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   136
        return "AF41";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   137
      case AF42:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   138
        return "AF42";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   139
      case AF43:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   140
        return "AF43";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   141
      case CS5:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   142
        return "CS5";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   143
      case EF:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   144
        return "EF";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   145
      case CS6:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   146
        return "CS6";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   147
      case CS7:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   148
        return "CS7";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   149
      default:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   150
        return "Unrecognized DSCP";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   151
    };
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   152
}
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   153
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   154
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   155
Ipv4Header::EcnType 
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   156
Ipv4Header::GetEcn (void) const
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   157
{
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   158
  // Extract only last 2 bits of TOS byte, i.e 0x3
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   159
  return EcnType (m_tos & 0x3);
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   160
}
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   161
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   162
std::string 
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   163
Ipv4Header::EcnTypeToString (EcnType ecn) const
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   164
{
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   165
  switch (ecn)
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   166
    {
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   167
      case NotECT:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   168
        return "Not-ECT";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   169
      case ECT1:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   170
        return "ECT (1)";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   171
      case ECT0:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   172
        return "ECT (0)";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   173
      case CE:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   174
        return "CE";      
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   175
      default:
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   176
        return "Unknown ECN";
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   177
    };
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   178
}
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   179
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180
uint8_t 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
Ipv4Header::GetTos (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   182
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   183
  return m_tos;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   185
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
Ipv4Header::SetMoreFragments (void)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
  m_flags |= MORE_FRAGMENTS;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   189
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
void
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
Ipv4Header::SetLastFragment (void)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
  m_flags &= ~MORE_FRAGMENTS;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   195
bool 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   196
Ipv4Header::IsLastFragment (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   197
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
  return !(m_flags & MORE_FRAGMENTS);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
Ipv4Header::SetDontFragment (void)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
  m_flags |= DONT_FRAGMENT;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   205
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
Ipv4Header::SetMayFragment (void)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   208
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   209
  m_flags &= ~DONT_FRAGMENT;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
bool 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
Ipv4Header::IsDontFragment (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   213
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
  return (m_flags & DONT_FRAGMENT);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   215
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
void 
7315
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   218
Ipv4Header::SetFragmentOffset (uint16_t offsetBytes)
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
{
7315
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   220
  // check if the user is trying to set an invalid offset
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   221
  NS_ABORT_MSG_IF ((offsetBytes & 0x7), "offsetBytes must be multiple of 8 bytes");
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   222
  m_fragmentOffset = offsetBytes;
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   223
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
uint16_t 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
Ipv4Header::GetFragmentOffset (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
{
7315
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   227
  if ((m_fragmentOffset+m_payloadSize+5*4) > 65535)
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   228
    {
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   229
      NS_LOG_WARN("Fragment will exceed the maximum packet size once reassembled");
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   230
    }
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   231
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
  return m_fragmentOffset;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   233
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   236
Ipv4Header::SetTtl (uint8_t ttl)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   237
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
  m_ttl = ttl;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   239
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
uint8_t 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   241
Ipv4Header::GetTtl (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   242
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
  return m_ttl;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   244
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
   245
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   246
uint8_t 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   247
Ipv4Header::GetProtocol (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   248
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
  return m_protocol;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   251
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
Ipv4Header::SetProtocol (uint8_t protocol)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
  m_protocol = protocol;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   258
Ipv4Header::SetSource (Ipv4Address source)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
  m_source = source;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
Ipv4Address
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
Ipv4Header::GetSource (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   265
  return m_source;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   268
void 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   269
Ipv4Header::SetDestination (Ipv4Address dst)
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   270
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   271
  m_destination = dst;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   272
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   273
Ipv4Address
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   274
Ipv4Header::GetDestination (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   275
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   276
  return m_destination;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   277
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   278
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   279
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   280
bool
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   281
Ipv4Header::IsChecksumOk (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   282
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   283
  return m_goodChecksum;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   284
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   285
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   286
TypeId 
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   287
Ipv4Header::GetTypeId (void)
795
cd108c9817d0 add Chunk::GetName and implement it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
   288
{
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   289
  static TypeId tid = TypeId ("ns3::Ipv4Header")
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   290
    .SetParent<Header> ()
2650
3de4cacb8981 make sure all headers and trailers gets a constructor registered in their TypeId.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2646
diff changeset
   291
    .AddConstructor<Ipv4Header> ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
   292
  ;
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   293
  return tid;
795
cd108c9817d0 add Chunk::GetName and implement it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
   294
}
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   295
TypeId 
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   296
Ipv4Header::GetInstanceTypeId (void) const
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   297
{
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   298
  return GetTypeId ();
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
   299
}
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   300
void 
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1152
diff changeset
   301
Ipv4Header::Print (std::ostream &os) const
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   302
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   303
  // ipv4, right ?
900
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   304
  std::string flags;
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   305
  if (m_flags == 0)
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   306
    {
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   307
      flags = "none";
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   308
    }
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   309
  else if (m_flags & MORE_FRAGMENTS &&
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   310
           m_flags & DONT_FRAGMENT)
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   311
    {
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   312
      flags = "MF|DF";
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   313
    }
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   314
  else if (m_flags & DONT_FRAGMENT)
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   315
    {
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   316
      flags = "DF";
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   317
    }
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   318
  else if (m_flags & MORE_FRAGMENTS)
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   319
    {
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   320
      flags = "MF";
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   321
    }
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   322
  else
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   323
    {
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   324
      flags = "XX";
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   325
    }
2653
b8eff7186c5c improve pretty-printing output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2650
diff changeset
   326
  os << "tos 0x" << std::hex << m_tos << std::dec << " "
7566
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   327
     << "DSCP " << DscpTypeToString (GetDscp ()) << " "
aa5b5f290a0d Bug 1186 - Ipv4Header lacks DSCP and ECN
John Abraham <john.abraham@gatech.edu>
parents: 7386
diff changeset
   328
     << "ECN " << EcnTypeToString (GetEcn ()) << " "
900
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   329
     << "ttl " << m_ttl << " "
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   330
     << "id " << m_identification << " "
3769
a0946f209866 bug 278: print protocol number from Ipv4Header::Print
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3363
diff changeset
   331
     << "protocol " << m_protocol << " "
7315
8bf3aba819f2 Bug 1102: IPv4 fragment offset
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7256
diff changeset
   332
     << "offset (bytes) " << m_fragmentOffset << " "
900
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   333
     << "flags [" << flags << "] "
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   334
     << "length: " << (m_payloadSize + 5 * 4)
2653
b8eff7186c5c improve pretty-printing output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2650
diff changeset
   335
     << " " 
900
2087082ba3ed change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 795
diff changeset
   336
     << m_source << " > " << m_destination
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
   337
  ;
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   338
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   339
uint32_t 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   340
Ipv4Header::GetSerializedSize (void) const
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   341
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   342
  return 5 * 4;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   343
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   344
463
c2082308e01a merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 287
diff changeset
   345
void
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1152
diff changeset
   346
Ipv4Header::Serialize (Buffer::Iterator start) const
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   347
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   348
  Buffer::Iterator i = start;
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
   349
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   350
  uint8_t verIhl = (4 << 4) | (5);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   351
  i.WriteU8 (verIhl);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   352
  i.WriteU8 (m_tos);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   353
  i.WriteHtonU16 (m_payloadSize + 5*4);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   354
  i.WriteHtonU16 (m_identification);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   355
  uint32_t fragmentOffset = m_fragmentOffset / 8;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   356
  uint8_t flagsFrag = (fragmentOffset >> 8) & 0x1f;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   357
  if (m_flags & DONT_FRAGMENT) 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   358
    {
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   359
      flagsFrag |= (1<<6);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   360
    }
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   361
  if (m_flags & MORE_FRAGMENTS) 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   362
    {
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   363
      flagsFrag |= (1<<5);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   364
    }
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   365
  i.WriteU8 (flagsFrag);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   366
  uint8_t frag = fragmentOffset & 0xff;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   367
  i.WriteU8 (frag);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   368
  i.WriteU8 (m_ttl);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   369
  i.WriteU8 (m_protocol);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   370
  i.WriteHtonU16 (0);
3179
1763f7ac8e80 bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   371
  i.WriteHtonU32 (m_source.Get ());
1763f7ac8e80 bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   372
  i.WriteHtonU32 (m_destination.Get ());
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   373
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   374
  if (m_calcChecksum) 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   375
    {
3234
aabbcb2cba71 Add ipv4 header checksum support.
Florian Westphal <fw@strlen.de>
parents: 3221
diff changeset
   376
      i = start;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   377
      uint16_t checksum = i.CalculateIpChecksum (20);
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1236
diff changeset
   378
      NS_LOG_LOGIC ("checksum=" <<checksum);
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   379
      i = start;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   380
      i.Next (10);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   381
      i.WriteU16 (checksum);
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   382
    }
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   383
}
463
c2082308e01a merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 287
diff changeset
   384
uint32_t
1232
2e8c3f8bb77f remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1152
diff changeset
   385
Ipv4Header::Deserialize (Buffer::Iterator start)
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   386
{
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   387
  Buffer::Iterator i = start;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   388
  uint8_t verIhl = i.ReadU8 ();
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   389
  uint8_t ihl = verIhl & 0x0f; 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   390
  uint16_t headerSize = ihl * 4;
286
57e6a2006962 convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 235
diff changeset
   391
  NS_ASSERT ((verIhl >> 4) == 4);
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   392
  m_tos = i.ReadU8 ();
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   393
  uint16_t size = i.ReadNtohU16 ();
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   394
  m_payloadSize = size - headerSize;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   395
  m_identification = i.ReadNtohU16 ();
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   396
  uint8_t flags = i.ReadU8 ();
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   397
  m_flags = 0;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   398
  if (flags & (1<<6)) 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   399
    {
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   400
      m_flags |= DONT_FRAGMENT;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   401
    }
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   402
  if (flags & (1<<5)) 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   403
    {
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   404
      m_flags |= MORE_FRAGMENTS;
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   405
    }
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   406
  i.Prev ();
3221
bd02183f788b fix bug 208 for true.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3217
diff changeset
   407
  m_fragmentOffset = i.ReadU8 () & 0x1f;
bd02183f788b fix bug 208 for true.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3217
diff changeset
   408
  m_fragmentOffset <<= 8;
bd02183f788b fix bug 208 for true.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3217
diff changeset
   409
  m_fragmentOffset |= i.ReadU8 ();
bd02183f788b fix bug 208 for true.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3217
diff changeset
   410
  m_fragmentOffset <<= 3;
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   411
  m_ttl = i.ReadU8 ();
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   412
  m_protocol = i.ReadU8 ();
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   413
  m_checksum = i.ReadU16 ();
3363
33d1ca2e4ba4 bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3235
diff changeset
   414
  /* i.Next (2); // checksum */
3179
1763f7ac8e80 bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   415
  m_source.Set (i.ReadNtohU32 ());
1763f7ac8e80 bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   416
  m_destination.Set (i.ReadNtohU32 ());
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   417
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   418
  if (m_calcChecksum) 
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   419
    {
3234
aabbcb2cba71 Add ipv4 header checksum support.
Florian Westphal <fw@strlen.de>
parents: 3221
diff changeset
   420
      i = start;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   421
      uint16_t checksum = i.CalculateIpChecksum (headerSize);
3234
aabbcb2cba71 Add ipv4 header checksum support.
Florian Westphal <fw@strlen.de>
parents: 3221
diff changeset
   422
      NS_LOG_LOGIC ("checksum=" <<checksum);
aabbcb2cba71 Add ipv4 header checksum support.
Florian Westphal <fw@strlen.de>
parents: 3221
diff changeset
   423
aabbcb2cba71 Add ipv4 header checksum support.
Florian Westphal <fw@strlen.de>
parents: 3221
diff changeset
   424
      m_goodChecksum = (checksum == 0);
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   425
    }
463
c2082308e01a merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 287
diff changeset
   426
  return GetSerializedSize ();
235
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   427
}
190d5bef3254 add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   428
7386
2310ed220a61 standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents: 7385
diff changeset
   429
} // namespace ns3