Feature #3913
closed
Add DummyForwarder to utils
Added by Zhiyi Zhang almost 8 years ago.
Updated almost 7 years ago.
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());
- Status changed from New to Code review
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?
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.
- 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"?
Junxiao Shi wrote:
As indicated in #3940-18, the dummy forwarder does not belong to src/util/
. It should be placed in src/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.
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.
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.
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.
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.
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&);
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.
- 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.
Also available in: Atom
PDF