NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
udp-protocol.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "udp-protocol.hpp"
27 
28 namespace nfd {
29 namespace udp {
30 
31 ssize_t
32 computeMtu(const boost::asio::ip::udp::endpoint& localEndpoint)
33 {
34  size_t mtu = 0;
35  if (localEndpoint.address().is_v4()) { // IPv4
36  mtu = std::numeric_limits<uint16_t>::max(); // maximum Total Length
37  mtu -= sizeof(uint32_t) * ((1 << 4) - 1); // maximum Internet Header Length
38  }
39  else { // IPv6
40  mtu = std::numeric_limits<uint16_t>::max(); // maximum Payload Length
41  }
42  mtu -= sizeof(uint16_t) * 4; // size of UDP header
43  return mtu;
44 }
45 
46 } // namespace udp
47 } // namespace nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
ssize_t computeMtu(const boost::asio::ip::udp::endpoint &localEndpoint)
computes maximum payload size in a UDP packet