View | Details | Raw Unified | Return to bug 491
Collapse All | Expand All

(-)a/examples/emu-ping.cc (-4 / +1 lines)
 Lines 103-112   main (int argc, char *argv[]) Link Here 
103
  // Since we are going to be talking to real-world machines, we need to enable
103
  // Since we are going to be talking to real-world machines, we need to enable
104
  // calculation of checksums in our protocols.
104
  // calculation of checksums in our protocols.
105
  //
105
  //
106
  Config::SetDefault ("ns3::Ipv4L3Protocol::CalcChecksum", BooleanValue (true)); 
106
  System ()->SetAttribute ("CalcChecksum", BooleanValue (true));
107
  Config::SetDefault ("ns3::Icmpv4L4Protocol::CalcChecksum", BooleanValue (true)); 
108
  Config::SetDefault ("ns3::TcpL4Protocol::CalcChecksum", BooleanValue (true)); 
109
  Config::SetDefault ("ns3::UdpL4Protocol::CalcChecksum", BooleanValue (true)); 
110
107
111
  //
108
  //
112
  // In such a simple topology, the use of the helper API can be a hindrance
109
  // In such a simple topology, the use of the helper API can be a hindrance
(-)a/src/applications/v4ping/v4ping.cc (+27 lines)
 Lines 1-3    Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 */
16
1
#include "v4ping.h"
17
#include "v4ping.h"
2
#include "ns3/icmpv4.h"
18
#include "ns3/icmpv4.h"
3
#include "ns3/assert.h"
19
#include "ns3/assert.h"
 Lines 9-14    Link Here 
9
#include "ns3/packet.h"
25
#include "ns3/packet.h"
10
#include "ns3/trace-source-accessor.h"
26
#include "ns3/trace-source-accessor.h"
11
#include "ns3/simulator.h"
27
#include "ns3/simulator.h"
28
#include "ns3/system-object.h"
29
#include "ns3/boolean.h"
12
30
13
namespace ns3 {
31
namespace ns3 {
14
32
 Lines 165-170   V4Ping::StartApplication (void) Link Here 
165
  Icmpv4Header header;
183
  Icmpv4Header header;
166
  header.SetType (Icmpv4Header::ECHO);
184
  header.SetType (Icmpv4Header::ECHO);
167
  header.SetCode (0);
185
  header.SetCode (0);
186
187
  BooleanValue b;
188
  System ()->GetAttribute ("CalcChecksum", b);
189
190
  if (b.Get ())
191
    {
192
	header.EnableChecksum ();
193
    }
194
168
  p->AddHeader (header);
195
  p->AddHeader (header);
169
  m_socket->Send (p, 0);
196
  m_socket->Send (p, 0);
170
  
197
  
(-)74983e885cdd (+1 lines)
Added Link Here 
1
exec "`dirname "$0"`"/../../../waf "$@"
(-)74983e885cdd (+60 lines)
Added Link Here 
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2009 University of Washington
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
19
#include "log.h"
20
#include "assert.h"
21
#include "abort.h"
22
#include "singleton.h"
23
#include "object.h"
24
#include "system-object.h"
25
#include "boolean.h"
26
27
namespace ns3 {
28
29
NS_LOG_COMPONENT_DEFINE ("SystemObject");
30
31
Ptr<Object>
32
System (void)
33
{
34
  return Singleton<SystemObject>::Get ();
35
}
36
37
TypeId 
38
SystemObject::GetTypeId (void)
39
{
40
  static TypeId tid = TypeId ("ns3::SystemObject")
41
    .SetParent<Object> ()
42
    .AddAttribute ("CalcChecksum", 
43
                   "Enable (true) or disable (false) calculation of protocol checksums system-wide.",
44
                   BooleanValue (false),
45
                   MakeBooleanAccessor (&SystemObject::m_calcChecksum),
46
                   MakeBooleanChecker ())
47
    ;
48
  return tid;
49
}
50
51
SystemObject::SystemObject ()
52
{
53
}
54
55
SystemObject::~SystemObject ()
56
{
57
}
58
59
} //namespace ns3
60
(-)74983e885cdd (+42 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2009 University of Washington
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
19
#ifndef SYSTEM_OBJECT_H
20
#define SYSTEM_OBJECT_H
21
22
#include "object.h"
23
24
namespace ns3 {
25
26
Ptr<Object> System (void);
27
28
class SystemObject : public Object 
29
{
30
public:
31
  static TypeId GetTypeId (void);
32
33
  SystemObject ();
34
  virtual ~SystemObject ();
35
36
private:
37
  bool m_calcChecksum;
38
};
39
40
} // namespace ns3
41
42
#endif // SYSTEM_OBJECT_H
(-)a/src/core/wscript (+2 lines)
 Lines 78-83   def build(bld): Link Here 
78
        'config.cc',
78
        'config.cc',
79
        'callback.cc',
79
        'callback.cc',
80
        'names.cc',
80
        'names.cc',
81
        'system-object.cc',
81
        ]
82
        ]
82
83
83
    headers = bld.new_task_gen('ns3header')
84
    headers = bld.new_task_gen('ns3header')
 Lines 123-128   def build(bld): Link Here 
123
        'deprecated.h',
124
        'deprecated.h',
124
        'abort.h',
125
        'abort.h',
125
        'names.h',
126
        'names.h',
127
        'system-object.h',
126
        ]
128
        ]
127
129
128
    if sys.platform == 'win32':
130
    if sys.platform == 'win32':
(-)a/src/internet-stack/icmpv4-l4-protocol.cc (-1 / +22 lines)
 Lines 1-3    Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 */
16
1
#include "icmpv4-l4-protocol.h"
17
#include "icmpv4-l4-protocol.h"
2
#include "ipv4-interface.h"
18
#include "ipv4-interface.h"
3
#include "ipv4-l3-protocol.h"
19
#include "ipv4-l3-protocol.h"
 Lines 6-11    Link Here 
6
#include "ns3/node.h"
22
#include "ns3/node.h"
7
#include "ns3/packet.h"
23
#include "ns3/packet.h"
8
#include "ns3/boolean.h"
24
#include "ns3/boolean.h"
25
#include "ns3/system-object.h"
9
26
10
namespace ns3 {
27
namespace ns3 {
11
28
 Lines 80-86   Icmpv4L4Protocol::SendMessage (Ptr<Packe Link Here 
80
  Icmpv4Header icmp;
97
  Icmpv4Header icmp;
81
  icmp.SetType (type);
98
  icmp.SetType (type);
82
  icmp.SetCode (code);
99
  icmp.SetCode (code);
83
  if (m_calcChecksum)
100
101
  BooleanValue b;
102
  System ()->GetAttribute ("CalcChecksum", b);
103
104
  if (m_calcChecksum || b.Get ())
84
    {
105
    {
85
      icmp.EnableChecksum ();
106
      icmp.EnableChecksum ();
86
    }
107
    }
(-)a/src/internet-stack/icmpv4.cc (-1 / +23 lines)
 Lines 1-5    Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 */
16
1
#include "icmpv4.h"
17
#include "icmpv4.h"
2
#include "ns3/packet.h"
18
#include "ns3/packet.h"
19
#include "ns3/system-object.h"
20
#include "ns3/boolean.h"
3
21
4
namespace ns3 {
22
namespace ns3 {
5
23
 Lines 45-51   Icmpv4Header::Serialize (Buffer::Iterato Link Here 
45
  i.WriteU8 (m_type);
63
  i.WriteU8 (m_type);
46
  i.WriteU8 (m_code);
64
  i.WriteU8 (m_code);
47
  i.WriteHtonU16 (0);
65
  i.WriteHtonU16 (0);
48
  if (m_calcChecksum)
66
67
  BooleanValue b;
68
  System ()->GetAttribute ("CalcChecksum", b);
69
70
  if (m_calcChecksum || b.Get ())
49
    {
71
    {
50
      i = start;
72
      i = start;
51
      uint16_t checksum = i.CalculateIpChecksum (i.GetSize ());
73
      uint16_t checksum = i.CalculateIpChecksum (i.GetSize ());
(-)a/src/internet-stack/ipv4-l3-protocol.cc (-2 / +10 lines)
 Lines 31-36    Link Here 
31
#include "ns3/object-vector.h"
31
#include "ns3/object-vector.h"
32
#include "ns3/ipv4-header.h"
32
#include "ns3/ipv4-header.h"
33
#include "ns3/boolean.h"
33
#include "ns3/boolean.h"
34
#include "ns3/system-object.h"
34
#include "arp-l3-protocol.h"
35
#include "arp-l3-protocol.h"
35
36
36
#include "ipv4-l3-protocol.h"
37
#include "ipv4-l3-protocol.h"
 Lines 548-554   Ipv4L3Protocol::Receive( Ptr<NetDevice> Link Here 
548
      index++;
549
      index++;
549
    }
550
    }
550
  Ipv4Header ipHeader;
551
  Ipv4Header ipHeader;
551
  if (m_calcChecksum)
552
553
  BooleanValue b;
554
  System ()->GetAttribute ("CalcChecksum", b);
555
556
  if (m_calcChecksum || b.Get ())
552
    {
557
    {
553
      ipHeader.EnableChecksum ();
558
      ipHeader.EnableChecksum ();
554
    }
559
    }
 Lines 604-610   Ipv4L3Protocol::Send (Ptr<Packet> packet Link Here 
604
609
605
  Ipv4Header ipHeader;
610
  Ipv4Header ipHeader;
606
611
607
  if (m_calcChecksum)
612
  BooleanValue b;
613
  System ()->GetAttribute ("CalcChecksum", b);
614
615
  if (m_calcChecksum || b.Get ())
608
    {
616
    {
609
      ipHeader.EnableChecksum ();
617
      ipHeader.EnableChecksum ();
610
    }
618
    }
(-)a/src/internet-stack/tcp-header.cc (-1 / +6 lines)
 Lines 24-29    Link Here 
24
#include "tcp-header.h"
24
#include "tcp-header.h"
25
#include "ns3/buffer.h"
25
#include "ns3/buffer.h"
26
#include "ns3/address-utils.h"
26
#include "ns3/address-utils.h"
27
#include "ns3/system-object.h"
28
#include "ns3/boolean.h"
27
29
28
namespace ns3 {
30
namespace ns3 {
29
31
 Lines 216-222   void TcpHeader::Serialize (Buffer::Itera Link Here 
216
  i.WriteHtonU16 (0);
218
  i.WriteHtonU16 (0);
217
  i.WriteHtonU16 (m_urgentPointer);
219
  i.WriteHtonU16 (m_urgentPointer);
218
220
219
  if(m_calcChecksum)
221
  BooleanValue b;
222
  System ()->GetAttribute ("CalcChecksum", b);
223
224
  if(m_calcChecksum || b.Get ())
220
  {
225
  {
221
    uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ());
226
    uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ());
222
    i = start;
227
    i = start;
(-)a/src/internet-stack/tcp-l4-protocol.cc (-3 / +16 lines)
 Lines 22-27    Link Here 
22
#include "ns3/log.h"
22
#include "ns3/log.h"
23
#include "ns3/nstime.h"
23
#include "ns3/nstime.h"
24
#include "ns3/boolean.h"
24
#include "ns3/boolean.h"
25
#include "ns3/system-object.h"
25
#include "ns3/object-vector.h"
26
#include "ns3/object-vector.h"
26
27
27
#include "ns3/packet.h"
28
#include "ns3/packet.h"
 Lines 452-458   TcpL4Protocol::Receive (Ptr<Packet> pack Link Here 
452
  NS_LOG_FUNCTION (this << packet << source << destination << incomingInterface);
453
  NS_LOG_FUNCTION (this << packet << source << destination << incomingInterface);
453
454
454
  TcpHeader tcpHeader;
455
  TcpHeader tcpHeader;
455
  if(m_calcChecksum)
456
457
  BooleanValue b;
458
  System ()->GetAttribute ("CalcChecksum", b);
459
460
  if(m_calcChecksum || b.Get ())
456
  {
461
  {
457
    tcpHeader.EnableChecksums();
462
    tcpHeader.EnableChecksums();
458
    tcpHeader.InitializeChecksum (source, destination, PROT_NUMBER);
463
    tcpHeader.InitializeChecksum (source, destination, PROT_NUMBER);
 Lines 504-510   TcpL4Protocol::Send (Ptr<Packet> packet, Link Here 
504
  TcpHeader tcpHeader;
509
  TcpHeader tcpHeader;
505
  tcpHeader.SetDestinationPort (dport);
510
  tcpHeader.SetDestinationPort (dport);
506
  tcpHeader.SetSourcePort (sport);
511
  tcpHeader.SetSourcePort (sport);
507
  if(m_calcChecksum)
512
513
  BooleanValue b;
514
  System ()->GetAttribute ("CalcChecksum", b);
515
516
  if(m_calcChecksum || b.Get ())
508
  {
517
  {
509
    tcpHeader.EnableChecksums();
518
    tcpHeader.EnableChecksums();
510
  }
519
  }
 Lines 538-544   TcpL4Protocol::SendPacket (Ptr<Packet> p Link Here 
538
547
539
  outgoingHeader.SetLength (5); //header length in units of 32bit words
548
  outgoingHeader.SetLength (5); //header length in units of 32bit words
540
  /* outgoingHeader.SetUrgentPointer (0); //XXX */
549
  /* outgoingHeader.SetUrgentPointer (0); //XXX */
541
  if(m_calcChecksum)
550
551
  BooleanValue b;
552
  System ()->GetAttribute ("CalcChecksum", b);
553
554
  if(m_calcChecksum || b.Get ())
542
  {
555
  {
543
    outgoingHeader.EnableChecksums();
556
    outgoingHeader.EnableChecksums();
544
  }
557
  }
(-)a/src/internet-stack/udp-header.cc (-2 / +10 lines)
 Lines 20-25    Link Here 
20
20
21
#include "udp-header.h"
21
#include "udp-header.h"
22
#include "ns3/address-utils.h"
22
#include "ns3/address-utils.h"
23
#include "ns3/system-object.h"
24
#include "ns3/boolean.h"
23
25
24
namespace ns3 {
26
namespace ns3 {
25
27
 Lines 143-149   UdpHeader::Serialize (Buffer::Iterator s Link Here 
143
  i.WriteHtonU16 (start.GetSize ());
145
  i.WriteHtonU16 (start.GetSize ());
144
  i.WriteU16 (0);
146
  i.WriteU16 (0);
145
147
146
  if (m_calcChecksum)
148
  BooleanValue b;
149
  System ()->GetAttribute ("CalcChecksum", b);
150
151
  if (m_calcChecksum || b.Get ())
147
    {
152
    {
148
      uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ());
153
      uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ());
149
      i = start;
154
      i = start;
 Lines 163-169   UdpHeader::Deserialize (Buffer::Iterator Link Here 
163
  m_payloadSize = i.ReadNtohU16 () - GetSerializedSize ();
168
  m_payloadSize = i.ReadNtohU16 () - GetSerializedSize ();
164
  i.Next (2);
169
  i.Next (2);
165
170
166
  if(m_calcChecksum)
171
  BooleanValue b;
172
  System ()->GetAttribute ("CalcChecksum", b);
173
174
  if(m_calcChecksum || b.Get ())
167
  {
175
  {
168
      uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ());
176
      uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ());
169
      i = start;
177
      i = start;
(-)a/src/internet-stack/udp-l4-protocol.cc (-2 / +11 lines)
 Lines 23-28    Link Here 
23
#include "ns3/packet.h"
23
#include "ns3/packet.h"
24
#include "ns3/node.h"
24
#include "ns3/node.h"
25
#include "ns3/boolean.h"
25
#include "ns3/boolean.h"
26
#include "ns3/system-object.h"
26
27
27
#include "udp-l4-protocol.h"
28
#include "udp-l4-protocol.h"
28
#include "udp-header.h"
29
#include "udp-header.h"
 Lines 180-186   UdpL4Protocol::Receive(Ptr<Packet> packe Link Here 
180
{
181
{
181
  NS_LOG_FUNCTION (this << packet << source << destination);
182
  NS_LOG_FUNCTION (this << packet << source << destination);
182
  UdpHeader udpHeader;
183
  UdpHeader udpHeader;
183
  if(m_calcChecksum)
184
185
  BooleanValue b;
186
  System ()->GetAttribute ("CalcChecksum", b);
187
188
  if(m_calcChecksum || b.Get ())
184
  {
189
  {
185
    udpHeader.EnableChecksums();
190
    udpHeader.EnableChecksums();
186
  }
191
  }
 Lines 218-224   UdpL4Protocol::Send (Ptr<Packet> packet, Link Here 
218
  NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport);
223
  NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport);
219
224
220
  UdpHeader udpHeader;
225
  UdpHeader udpHeader;
221
  if(m_calcChecksum)
226
227
  BooleanValue b;
228
  System ()->GetAttribute ("CalcChecksum", b);
229
230
  if(m_calcChecksum || b.Get ())
222
  {
231
  {
223
    udpHeader.EnableChecksums();
232
    udpHeader.EnableChecksums();
224
    udpHeader.InitializeChecksum (saddr,
233
    udpHeader.InitializeChecksum (saddr,
(-)a/src/node/ipv4-header.cc (-1 / +7 lines)
 Lines 21-26    Link Here 
21
#include "ns3/assert.h"
21
#include "ns3/assert.h"
22
#include "ns3/log.h"
22
#include "ns3/log.h"
23
#include "ns3/header.h"
23
#include "ns3/header.h"
24
#include "ns3/system-object.h"
25
#include "ns3/boolean.h"
26
24
#include "ipv4-header.h"
27
#include "ipv4-header.h"
25
28
26
NS_LOG_COMPONENT_DEFINE ("Ipv4Header");
29
NS_LOG_COMPONENT_DEFINE ("Ipv4Header");
 Lines 264-270   Ipv4Header::Serialize (Buffer::Iterator Link Here 
264
  i.WriteHtonU32 (m_source.Get ());
267
  i.WriteHtonU32 (m_source.Get ());
265
  i.WriteHtonU32 (m_destination.Get ());
268
  i.WriteHtonU32 (m_destination.Get ());
266
269
267
  if (m_calcChecksum) 
270
  BooleanValue b;
271
  System ()->GetAttribute ("CalcChecksum", b);
272
273
  if (m_calcChecksum || b.Get ()) 
268
    {
274
    {
269
      i = start;
275
      i = start;
270
      uint16_t checksum = i.CalculateIpChecksum(20);
276
      uint16_t checksum = i.CalculateIpChecksum(20);

Return to bug 491