Feature #3913
closedAdd DummyForwarder to utils
100%
Description
In many test cases, we want to test packet exchange between faces. Though we have DummyClientFace, we do not have a DummyForwarder which can forward packets among faces.
This DummyForwarder was first designed for Name-based Access Control protocol tests: https://gerrit.named-data.net/#/c/2599/12.
We move the DummyForwarder to ndn-cxx.
To add Face to DummyForwarder, the steps is like:
DummyForwarder forwarder(io_service);
auto face = make_shared<DummyClientFace>(io_service, keychain, {true, true});
size_t faceID = forwarder.addFace(face);
forwarder.registerPrefix("/face", faceID);
To pass the packets, the steps is like:
do {
advanceClocks(time::milliseconds(10), 20);
} while (forwarder.passInterest() || forwarder.passData());
Updated by Zhiyi Zhang almost 8 years ago
- Status changed from New to Code review
Updated by Junxiao Shi almost 8 years ago
To pass the packets, the steps is like:
do { advanceClocks(time::milliseconds(10), 20); } while (forwarder.passInterest() || forwarder.passData());
Why not providing a processEvents
or passPackets
function that takes care of this?
Updated by Zhiyi Zhang almost 7 years ago
I suggest we abandon the current complex effort and just make a really dummy forwarder. In the latest commit, I ported the DummyForwarder from ChronoShare to ndn-cxx.
Updated by Junxiao Shi almost 7 years ago
- Target version set to v0.7
As indicated in #3940-18, the dummy forwarder does not belong to src/util/
. It should be placed in src/dummyfw/
folder.
just make a really dummy forwarder
Can you define the goals and non-goals of the "really dummy forwarder"?
Updated by Davide Pesavento almost 7 years ago
Junxiao Shi wrote:
As indicated in #3940-18, the dummy forwarder does not belong to
src/util/
. It should be placed insrc/dummyfw/
folder.
I said that when the dummy forwarder implementation consisted of several translation units. It's just one translation unit now, it makes no sense to put it in its own directory.
Updated by Zhiyi Zhang almost 7 years ago
Junxiao Shi wrote:
just make a really dummy forwarder
Can you define the goals and non-goals of the "really dummy forwarder"?
It means the dummy forwarder simply broadcasts all the Interest packets and Data packets from sender face to all the other faces.
Updated by Junxiao Shi almost 7 years ago
the dummy forwarder simply broadcasts all the Interest packets and Data packets from sender face to all the other faces.
This isn't a forwarder, dummy or not, and shouldn't be labeled as such.
It's simply a "link".
I suggest this API:
void DummyClientFace::linkTo(DummyClientFace&);
Any number of dummy client faces can be linked together.
Updated by Zhiyi Zhang almost 7 years ago
Junxiao Shi wrote:
I suggest this API:
void DummyClientFace::linkTo(DummyClientFace&);
Any number of dummy client faces can be linked together.
I disagree. If we have n faces, we then need to do n(n-1)/2 times linkTo() to build the mesh link.
Updated by Junxiao Shi almost 7 years ago
If we have n faces, we then need to do n(n-1)/2 times linkTo() to build the mesh link.
Actually not. DummyClientFace::linkTo
is the public API. The class has an internal shared_ptr
pointing to an object that remembers all the faces that are linked together. There are only n-1
invocations.
Updated by Zhiyi Zhang almost 7 years ago
Then we need to define that object and we can change the API to:
void DummyClientFace::linkTo(Object&);
Or we have the current implementation to be that object, but call it DummyBroadcastLink or something. Then it would be:
class DummyBroadcastLink
{
public:
std::vector<shared_ptr<DummyClientFace>> faces;
}
void DummyClientFace::linkTo(DummyBroadcastLink&);
Updated by Junxiao Shi almost 7 years ago
No. It's like this:
class DummyClientFace
{
public:
~DummyClientFace();
class AlreadyLinkedException;
void linkTo(DummyClientFace& other);
void unlink();
private:
class BcastLink;
shared_ptr<BcastLink> m_bcastLink;
};
DummyClientFace::~DummyClientFace()
{
this->unlink();
}
void DummyClientFace::linkTo(DummyClientFace& other)
{
if (m_bcastLink != nullptr && other.m_bcastLink != nullptr) {
if (m_bcastLink != other.m_bcastLink) {
// already on different links
throw AlreadyLinkedException();
}
return; // already on same link
}
if (m_bcastLink == nullptr && other.m_bcastLink != nullptr) {
m_bcastLink = other.m_bcastLink;
m_bcastLink->add(*this);
}
else if (m_bcastLink != nullptr && other.m_bcastLink == nullptr) {
other.m_bcastLink = m_bcastLink;
m_bcastLink->add(other);
}
else {
m_bcastLink = other.m_bcastLink = make_shared<BcastLink>();
m_bcastLink->add(*this);
m_bcastLink->add(other);
}
}
void DummyClientFace::unlink()
{
if (m_bcastLink == nullptr) {
return;
}
m_bcastLink->remove(*this);
m_bcastLink = nullptr;
}
DummyClientFace::BcastLink
is a nested class. It appears in .cpp only and is not part of public API.
Updated by Davide Pesavento almost 7 years ago
- Status changed from Code review to Closed
- % Done changed from 0 to 100
Commit 34429cc4f53fef200f63836361468bdc67d788cc added emulation of a broadcast link to DummyClientFace
. It's not a dummy forwarder, but I believe it satisfies current needs, hence I'm closing this issue.