32 const std::string HelloProtocol::INFO_COMPONENT =
"INFO";
33 const std::string HelloProtocol::NLSR_COMPONENT =
"NLSR";
37 , m_scheduler(scheduler)
45 ndn::Interest i(interestName);
46 i.setInterestLifetime(ndn::time::seconds(seconds));
47 i.setMustBeFresh(
true);
49 std::bind(&HelloProtocol::onContent,
52 std::bind(&HelloProtocol::processInterestTimedOut,
54 std::bind(&HelloProtocol::processInterestTimedOut,
65 for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
68 if((*it).getFaceId() != 0) {
70 ndn::Name interestName = (*it).getName() ;
71 interestName.append(NLSR_COMPONENT);
72 interestName.append(INFO_COMPONENT);
85 NLSR_LOG_DEBUG(
"Scheduling HELLO Interests in " << ndn::time::seconds(seconds));
87 m_scheduler.scheduleEvent(ndn::time::seconds(seconds),
93 const ndn::Interest& interest)
96 const ndn::Name interestName = interest.getName();
102 if (interestName.get(-2).toUri() != INFO_COMPONENT) {
103 NLSR_LOG_DEBUG(
"INFO_COMPONENT not found or interestName: " << interestName
104 <<
" does not match expression");
109 neighbor.wireDecode(interestName.get(-1).blockFromValue());
112 std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
113 data->setName(ndn::Name(interest.getName()).appendVersion());
114 data->setFreshnessPeriod(ndn::time::seconds(10));
115 data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
116 INFO_COMPONENT.size());
120 NLSR_LOG_DEBUG(
"Sending out data for name: " << interest.getName());
130 if(adjacent->getFaceId() != 0){
132 ndn::Name interestName(neighbor);
133 interestName.append(NLSR_COMPONENT);
134 interestName.append(INFO_COMPONENT);
144 HelloProtocol::processInterestTimedOut(
const ndn::Interest& interest)
147 const ndn::Name interestName(interest.getName());
149 if (interestName.get(-2).toUri() != INFO_COMPONENT) {
152 ndn::Name neighbor = interestName.getPrefix(-3);
158 uint32_t infoIntTimedOutCount =
161 NLSR_LOG_DEBUG(
"Info Interest Timed out: " << infoIntTimedOutCount);
164 ndn::Name interestName(neighbor);
165 interestName.append(NLSR_COMPONENT);
166 interestName.append(INFO_COMPONENT);
176 NLSR_LOG_DEBUG(
"Neighbor: " << neighbor <<
" status changed to INACTIVE");
186 HelloProtocol::onContent(
const ndn::Interest& interest,
const ndn::Data& data)
188 NLSR_LOG_DEBUG(
"Received data for INFO(name): " << data.getName());
189 if (data.getSignature().hasKeyLocator()) {
190 if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
191 NLSR_LOG_DEBUG(
"Data signed with: " << data.getSignature().getKeyLocator().getName());
195 std::bind(&HelloProtocol::onContentValidated,
this, _1),
196 std::bind(&HelloProtocol::onContentValidationFailed,
201 HelloProtocol::onContentValidated(
const ndn::Data& data)
204 ndn::Name dataName = data.getName();
205 NLSR_LOG_DEBUG(
"Data validation successful for INFO(name): " << dataName);
207 if (dataName.get(-3).toUri() == INFO_COMPONENT) {
208 ndn::Name neighbor = dataName.getPrefix(-4);
216 NLSR_LOG_DEBUG(
"Old Status: " << oldStatus <<
" New Status: " << newStatus);
218 if ((oldStatus - newStatus) != 0) {
232 HelloProtocol::onContentValidationFailed(
const ndn::Data& data,
233 const ndn::security::v2::ValidationError& ve)
uint32_t getInterestResendTime() const
void setTimedOutInterestCount(const ndn::Name &neighbor, uint32_t count)
void scheduleAdjLsaBuild()
Schedules a build of this router's LSA.
ConfParameter & getConfParameter()
ndn::util::signal::Signal< HelloProtocol, Statistics::PacketType > hpIncrementSignal
bool isNeighbor(const ndn::Name &adjName) const
#define NLSR_LOG_DEBUG(x)
uint32_t getInfoInterestInterval() const
const ndn::Name & getRouterPrefix() const
Adjacent::Status getStatusOfNeighbor(const ndn::Name &neighbor) const
RoutingTable & getRoutingTable()
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
void expressInterest(const ndn::Name &interestNamePrefix, uint32_t seconds)
Sends a Hello Interest packet.
void scheduleInterest(uint32_t seconds)
Schedules a Hello Interest event.
#define INIT_LOGGER(name)
uint32_t getInterestRetryNumber() const
AdjacencyList & getAdjacencyList()
void scheduleRoutingTableCalculation(Nlsr &pnlsr)
Schedules a calculation event in the event scheduler only if one isn't already scheduled.
ndn::security::v2::KeyChain & getKeyChain()
void processInterest(const ndn::Name &name, const ndn::Interest &interest)
Processes a Hello Interest from a neighbor.
int32_t getTimedOutInterestCount(const ndn::Name &neighbor) const
void sendScheduledInterest(uint32_t seconds)
Sends Hello Interests to all neighbors.
HelloProtocol(Nlsr &nlsr, ndn::Scheduler &scheduler)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
AdjacencyList::iterator findAdjacent(const ndn::Name &adjName)
ndn::Face & getNlsrFace()
int32_t getHyperbolicState() const
const ndn::security::SigningInfo & getSigningInfo()
ndn::security::ValidatorConfig & getValidator()
void incrementTimedOutInterestCount(const ndn::Name &neighbor)
std::list< Adjacent > & getAdjList()
void setStatusOfNeighbor(const ndn::Name &neighbor, Adjacent::Status status)