NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
multicast-udp-face.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "multicast-udp-face.hpp"
27 
28 namespace nfd {
29 
30 NFD_LOG_INCLASS_2TEMPLATE_SPECIALIZATION_DEFINE(DatagramFace,
32  "MulticastUdpFace");
33 
34 MulticastUdpFace::MulticastUdpFace(const protocol::endpoint& multicastGroup,
35  const FaceUri& localUri,
36  protocol::socket recvSocket, protocol::socket sendSocket)
37  : DatagramFace(FaceUri(multicastGroup), localUri, std::move(recvSocket))
38  , m_multicastGroup(multicastGroup)
39  , m_sendSocket(std::move(sendSocket))
40 {
41 }
42 
43 const MulticastUdpFace::protocol::endpoint&
45 {
46  return m_multicastGroup;
47 }
48 
49 void
51 {
52  NFD_LOG_FACE_TRACE(__func__);
53  this->emitSignal(onSendInterest, interest);
54  sendBlock(interest.wireEncode());
55 }
56 
57 void
59 {
60  NFD_LOG_FACE_TRACE(__func__);
63  this->emitSignal(onSendData, data);
64  sendBlock(data.wireEncode());
65 }
66 
67 void
68 MulticastUdpFace::sendBlock(const Block& block)
69 {
70  m_sendSocket.async_send_to(boost::asio::buffer(block.wire(), block.size()), m_multicastGroup,
71  bind(&MulticastUdpFace::handleSend, this,
72  boost::asio::placeholders::error,
73  boost::asio::placeholders::bytes_transferred,
74  block));
75 }
76 
77 } // namespace nfd
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
Definition: face.hpp:321
signal::Signal< Face, Interest > onSendInterest
fires when an Interest is sent out
Definition: face.hpp:86
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
MulticastUdpFace(const protocol::endpoint &multicastGroup, const FaceUri &localUri, protocol::socket recvSocket, protocol::socket sendSocket)
Creates a UDP-based face for multicast communication.
STL namespace.
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
represents an Interest packet
Definition: interest.hpp:45
void sendData(const Data &data) 1
send a Data
signal::Signal< Face, Data > onSendData
fires when a Data is sent out
Definition: face.hpp:89
size_t size() const
Definition: block.cpp:504
#define emitSignal(...)
(implementation detail)
Definition: signal-emit.hpp:76
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
Definition: data.cpp:52
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
void sendInterest(const Interest &interest) 1
send an Interest
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Definition: interest.cpp:217
void handleSend(const boost::system::error_code &error, size_t nBytesSent, const Block &payload)
const protocol::endpoint & getMulticastGroup() const
const uint8_t * wire() const
Definition: block.cpp:495
represents a Data packet
Definition: data.hpp:39