From ef9dc2aadcfaffbf9456965da39df3f133c76c09 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Wed, 11 Dec 2013 10:00:06 +0100 Subject: [PATCH] Bug 1812 - example/stats wifi program manual is erroneous --- src/flow-monitor/model/ipv4-flow-probe.cc | 5 ++++- src/flow-monitor/model/ipv4-flow-probe.h | 1 + src/internet/model/ipv4-l3-protocol.cc | 9 +++++++++ src/internet/model/ipv4-l3-protocol.h | 5 +++-- src/internet/model/ipv6-l3-protocol.cc | 5 +++++ src/internet/model/ipv6-l3-protocol.h | 1 + src/stats/doc/statistics.rst | 2 +- 7 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/flow-monitor/model/ipv4-flow-probe.cc b/src/flow-monitor/model/ipv4-flow-probe.cc index b36745cae..3e556eb34 100644 --- a/src/flow-monitor/model/ipv4-flow-probe.cc +++ b/src/flow-monitor/model/ipv4-flow-probe.cc @@ -359,7 +359,10 @@ Ipv4FlowProbe::DropLogger (const Ipv4Header &ipHeader, Ptr ipPaylo myReason = DROP_FRAGMENT_TIMEOUT; NS_LOG_DEBUG ("DROP_FRAGMENT_TIMEOUT"); break; - + case Ipv4L3Protocol::DROP_MTU_TOO_LITTLE: + myReason = DROP_MTU_TOO_LITTLE; + NS_LOG_DEBUG ("DROP_MTU_TOO_LITTLE"); + break; default: myReason = DROP_INVALID_REASON; NS_FATAL_ERROR ("Unexpected drop reason code " << reason); diff --git a/src/flow-monitor/model/ipv4-flow-probe.h b/src/flow-monitor/model/ipv4-flow-probe.h index 46e39f1fe..54755115f 100644 --- a/src/flow-monitor/model/ipv4-flow-probe.h +++ b/src/flow-monitor/model/ipv4-flow-probe.h @@ -69,6 +69,7 @@ public: DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */ DROP_ROUTE_ERROR, /**< Route error */ DROP_FRAGMENT_TIMEOUT, /**< Fragment timeout exceeded */ + DROP_MTU_TOO_LITTLE, /**< MTU (or PMTU) lower than minimum */ DROP_INVALID_REASON, /**< Fallback reason (no known reason) */ }; diff --git a/src/internet/model/ipv4-l3-protocol.cc b/src/internet/model/ipv4-l3-protocol.cc index 2f9338332..9c9bc45e6 100644 --- a/src/internet/model/ipv4-l3-protocol.cc +++ b/src/internet/model/ipv4-l3-protocol.cc @@ -748,6 +748,15 @@ Ipv4L3Protocol::SendRealOut (Ptr route, Ptr outInterface = GetInterface (interface); NS_LOG_LOGIC ("Send via NetDevice ifIndex " << outDev->GetIfIndex () << " ipv4InterfaceIndex " << interface); + // RFC 791, pg.25: + // Every internet module must be able to forward a datagram of 68 + // octets without further fragmentation. This is because an internet + // header may be up to 60 octets, and the minimum fragment is 8 octets. + if (outInterface->GetDevice ()->GetMtu () < 68) + { + m_dropTrace (ipHeader, packet, DROP_MTU_TOO_LITTLE, m_node->GetObject (), interface); + } + if (!route->GetGateway ().IsEqual (Ipv4Address ("0.0.0.0"))) { if (outInterface->IsUp ()) diff --git a/src/internet/model/ipv4-l3-protocol.h b/src/internet/model/ipv4-l3-protocol.h index e2c4cc4a8..1d91ecc58 100755 --- a/src/internet/model/ipv4-l3-protocol.h +++ b/src/internet/model/ipv4-l3-protocol.h @@ -98,8 +98,9 @@ public: DROP_BAD_CHECKSUM, /**< Bad checksum */ DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */ DROP_ROUTE_ERROR, /**< Route error */ - DROP_FRAGMENT_TIMEOUT /**< Fragment timeout exceeded */ - }; + DROP_FRAGMENT_TIMEOUT, /**< Fragment timeout exceeded */ + DROP_MTU_TOO_LITTLE, /**< MTU (or PMTU) lower than minimum */ + }; /** * \brief Set node associated with this stack. diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 5cd573cd4..262829381 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -888,6 +888,11 @@ void Ipv6L3Protocol::SendRealOut (Ptr route, Ptr packet, Ipv6 targetMtu = dev->GetMtu (); } + if (targetMtu<1280) + { + m_dropTrace (ipHeader, packet, DROP_MTU_TOO_LITTLE, m_node->GetObject (), interface); + } + if (packet->GetSize () > targetMtu + 40) /* 40 => size of IPv6 header */ { // Router => drop diff --git a/src/internet/model/ipv6-l3-protocol.h b/src/internet/model/ipv6-l3-protocol.h index d4508d8d3..76eff8d4e 100644 --- a/src/internet/model/ipv6-l3-protocol.h +++ b/src/internet/model/ipv6-l3-protocol.h @@ -81,6 +81,7 @@ public: DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */ DROP_ROUTE_ERROR, /**< Route error */ DROP_UNKNOWN_PROTOCOL, /**< Unknown L4 protocol */ + DROP_MTU_TOO_LITTLE, /**< MTU (or PMTU) lower than minimum */ }; /** diff --git a/src/stats/doc/statistics.rst b/src/stats/doc/statistics.rst index 173ca79ad..c542dc4a5 100644 --- a/src/stats/doc/statistics.rst +++ b/src/stats/doc/statistics.rst @@ -242,7 +242,7 @@ To see what the example program, applications, and stat framework are doing in d .. sourcecode:: bash - $ export NS_LOG=StatFramework:WiFiDistanceExperiment:WiFiDistanceApps + $ export NS_LOG=WiFiDistanceExperiment:WiFiDistanceApps Note that this slows down the simulation extraordinarily.