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 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
ssize_t computeMtu(const Endpoint &localEndpoint)
computes maximum payload size in a UDP packet
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
boost::asio::ip::udp::endpoint Endpoint