bug 491: It is painful to enable all checksums
This commit is contained in:
@@ -26,11 +26,6 @@ Icmpv4L4Protocol::GetTypeId (void)
|
||||
static TypeId tid = TypeId ("ns3::Icmpv4L4Protocol")
|
||||
.SetParent<Ipv4L4Protocol> ()
|
||||
.AddConstructor<Icmpv4L4Protocol> ()
|
||||
.AddAttribute ("CalcChecksum",
|
||||
"Control whether the icmp header checksum is calculated and stored in outgoing icmpv4 headers",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&Icmpv4L4Protocol::m_calcChecksum),
|
||||
MakeBooleanChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -111,7 +106,7 @@ Icmpv4L4Protocol::SendMessage (Ptr<Packet> packet, Ipv4Address source, Ipv4Addre
|
||||
Icmpv4Header icmp;
|
||||
icmp.SetType (type);
|
||||
icmp.SetCode (code);
|
||||
if (m_calcChecksum)
|
||||
if (Node::ChecksumEnabled ())
|
||||
{
|
||||
icmp.EnableChecksum ();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ private:
|
||||
virtual void DoDispose (void);
|
||||
|
||||
Ptr<Node> m_node;
|
||||
bool m_calcChecksum;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -61,11 +61,6 @@ Ipv4L3Protocol::GetTypeId (void)
|
||||
UintegerValue (64),
|
||||
MakeUintegerAccessor (&Ipv4L3Protocol::m_defaultTtl),
|
||||
MakeUintegerChecker<uint8_t> ())
|
||||
.AddAttribute ("CalcChecksum", "If true, we calculate the checksum of outgoing packets"
|
||||
" and verify the checksum of incoming packets.",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&Ipv4L3Protocol::m_calcChecksum),
|
||||
MakeBooleanChecker ())
|
||||
.AddTraceSource ("Tx", "Send ipv4 packet to outgoing interface.",
|
||||
MakeTraceSourceAccessor (&Ipv4L3Protocol::m_txTrace))
|
||||
.AddTraceSource ("Rx", "Receive ipv4 packet from incoming interface.",
|
||||
@@ -422,7 +417,7 @@ Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t pr
|
||||
}
|
||||
|
||||
Ipv4Header ipHeader;
|
||||
if (m_calcChecksum)
|
||||
if (Node::ChecksumEnabled ())
|
||||
{
|
||||
ipHeader.EnableChecksum ();
|
||||
}
|
||||
@@ -609,7 +604,7 @@ Ipv4L3Protocol::BuildHeader (
|
||||
ipHeader.SetIdentification (m_identification);
|
||||
m_identification ++;
|
||||
}
|
||||
if (m_calcChecksum)
|
||||
if (Node::ChecksumEnabled ())
|
||||
{
|
||||
ipHeader.EnableChecksum ();
|
||||
}
|
||||
|
||||
@@ -211,7 +211,6 @@ private:
|
||||
Ipv4InterfaceList m_interfaces;
|
||||
uint32_t m_nInterfaces;
|
||||
uint8_t m_defaultTtl;
|
||||
bool m_calcChecksum;
|
||||
uint16_t m_identification;
|
||||
Ptr<Node> m_node;
|
||||
TracedCallback<Ptr<const Packet>, uint32_t> m_txTrace;
|
||||
|
||||
@@ -332,11 +332,6 @@ TcpL4Protocol::GetTypeId (void)
|
||||
ObjectFactoryValue (GetDefaultRttEstimatorFactory ()),
|
||||
MakeObjectFactoryAccessor (&TcpL4Protocol::m_rttFactory),
|
||||
MakeObjectFactoryChecker ())
|
||||
.AddAttribute ("CalcChecksum", "If true, we calculate the checksum of outgoing packets"
|
||||
" and verify the checksum of incoming packets.",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&TcpL4Protocol::m_calcChecksum),
|
||||
MakeBooleanChecker ())
|
||||
.AddAttribute ("SocketList", "The list of sockets associated to this protocol.",
|
||||
ObjectVectorValue (),
|
||||
MakeObjectVectorAccessor (&TcpL4Protocol::m_sockets),
|
||||
@@ -477,7 +472,7 @@ TcpL4Protocol::Receive (Ptr<Packet> packet,
|
||||
NS_LOG_FUNCTION (this << packet << source << destination << incomingInterface);
|
||||
|
||||
TcpHeader tcpHeader;
|
||||
if(m_calcChecksum)
|
||||
if(Node::ChecksumEnabled ())
|
||||
{
|
||||
tcpHeader.EnableChecksums();
|
||||
tcpHeader.InitializeChecksum (source, destination, PROT_NUMBER);
|
||||
@@ -529,7 +524,7 @@ TcpL4Protocol::Send (Ptr<Packet> packet,
|
||||
TcpHeader tcpHeader;
|
||||
tcpHeader.SetDestinationPort (dport);
|
||||
tcpHeader.SetSourcePort (sport);
|
||||
if(m_calcChecksum)
|
||||
if(Node::ChecksumEnabled ())
|
||||
{
|
||||
tcpHeader.EnableChecksums();
|
||||
}
|
||||
@@ -571,7 +566,7 @@ TcpL4Protocol::SendPacket (Ptr<Packet> packet, TcpHeader outgoingHeader,
|
||||
|
||||
outgoingHeader.SetLength (5); //header length in units of 32bit words
|
||||
/* outgoingHeader.SetUrgentPointer (0); //XXX */
|
||||
if(m_calcChecksum)
|
||||
if(Node::ChecksumEnabled ())
|
||||
{
|
||||
outgoingHeader.EnableChecksums();
|
||||
}
|
||||
|
||||
@@ -124,8 +124,6 @@ private:
|
||||
Ipv4Address, Ipv4Address);
|
||||
static ObjectFactory GetDefaultRttEstimatorFactory (void);
|
||||
|
||||
bool m_goodChecksum;
|
||||
bool m_calcChecksum;
|
||||
std::vector<Ptr<TcpSocketImpl> > m_sockets;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,11 +48,6 @@ UdpL4Protocol::GetTypeId (void)
|
||||
static TypeId tid = TypeId ("ns3::UdpL4Protocol")
|
||||
.SetParent<Ipv4L4Protocol> ()
|
||||
.AddConstructor<UdpL4Protocol> ()
|
||||
.AddAttribute ("CalcChecksum", "If true, we calculate the checksum of outgoing packets"
|
||||
" and verify the checksum of incoming packets.",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&UdpL4Protocol::m_calcChecksum),
|
||||
MakeBooleanChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -204,7 +199,7 @@ UdpL4Protocol::Receive(Ptr<Packet> packet,
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << source << destination);
|
||||
UdpHeader udpHeader;
|
||||
if(m_calcChecksum)
|
||||
if(Node::ChecksumEnabled ())
|
||||
{
|
||||
udpHeader.EnableChecksums();
|
||||
}
|
||||
@@ -243,7 +238,7 @@ UdpL4Protocol::Send (Ptr<Packet> packet,
|
||||
NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport);
|
||||
|
||||
UdpHeader udpHeader;
|
||||
if(m_calcChecksum)
|
||||
if(Node::ChecksumEnabled ())
|
||||
{
|
||||
udpHeader.EnableChecksums();
|
||||
udpHeader.InitializeChecksum (saddr,
|
||||
@@ -272,7 +267,7 @@ UdpL4Protocol::Send (Ptr<Packet> packet,
|
||||
NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport);
|
||||
|
||||
UdpHeader udpHeader;
|
||||
if(m_calcChecksum)
|
||||
if(Node::ChecksumEnabled ())
|
||||
{
|
||||
udpHeader.EnableChecksums();
|
||||
udpHeader.InitializeChecksum (saddr,
|
||||
|
||||
@@ -118,7 +118,6 @@ protected:
|
||||
private:
|
||||
Ptr<Node> m_node;
|
||||
Ipv4EndPointDemux *m_endPoints;
|
||||
bool m_calcChecksum;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/global-value.h"
|
||||
#include "ns3/boolean.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Node");
|
||||
|
||||
@@ -35,6 +37,11 @@ namespace ns3{
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Node);
|
||||
|
||||
GlobalValue g_checksumEnabled = GlobalValue ("ChecksumEnabled",
|
||||
"A global switch to enable all checksums for all protocols",
|
||||
BooleanValue (false),
|
||||
MakeBooleanChecker ());
|
||||
|
||||
TypeId
|
||||
Node::GetTypeId (void)
|
||||
{
|
||||
@@ -222,6 +229,14 @@ Node::UnregisterProtocolHandler (ProtocolHandler handler)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Node::ChecksumEnabled (void)
|
||||
{
|
||||
BooleanValue val;
|
||||
g_checksumEnabled.GetValue (val);
|
||||
return val.Get ();
|
||||
}
|
||||
|
||||
bool
|
||||
Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
|
||||
const Address &from, const Address &to, NetDevice::PacketType packetType)
|
||||
|
||||
@@ -172,6 +172,12 @@ public:
|
||||
*/
|
||||
void UnregisterProtocolHandler (ProtocolHandler handler);
|
||||
|
||||
|
||||
/**
|
||||
* \returns true if checksums are enabled, false otherwise.
|
||||
*/
|
||||
static bool ChecksumEnabled (void);
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user