csma version of install star and example
This commit is contained in:
@@ -199,6 +199,19 @@ CsmaHelper::Install (const NodeContainer &c, Ptr<CsmaChannel> channel)
|
||||
return container;
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::InstallStar (Ptr<Node> hub, NodeContainer spokes,
|
||||
NetDeviceContainer& hubDevices, NetDeviceContainer& spokeDevices)
|
||||
{
|
||||
for (uint32_t i = 0; i < spokes.GetN (); ++i)
|
||||
{
|
||||
NodeContainer nodes (hub, spokes.Get (i));
|
||||
NetDeviceContainer nd = Install (nodes);
|
||||
hubDevices.Add (nd.Get (0));
|
||||
spokeDevices.Add (nd.Get (1));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::EnqueueEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet)
|
||||
{
|
||||
|
||||
@@ -179,6 +179,39 @@ public:
|
||||
*/
|
||||
NetDeviceContainer Install (const NodeContainer &c, Ptr<CsmaChannel> channel);
|
||||
|
||||
/**
|
||||
* \brief Make a star network topology.
|
||||
*
|
||||
* Given a pointer to a node that will become the hub of the star, and a
|
||||
* NodeContainer containing pointers to the nodes that will become the
|
||||
* spokes; we construct CSMA net devices on the hub (corresponding to the
|
||||
* spokes) and store them in the hubDevices NetDeviceContainer. We add a
|
||||
* net device to each spoke node and store them in the spokeDevices
|
||||
* NetDeviceContainer. A CSMA is created for each spoke.
|
||||
*
|
||||
* Usually when one thinks of a star network, one thinks of point-to-point
|
||||
* links. We're just using a single pair of devices on a multi-point-to-point
|
||||
* network "drops" as the link. You are free to add any number of other
|
||||
* devices on the link if you want.
|
||||
*
|
||||
* The ordering of the devices in the hubDevices container is according to
|
||||
* the order of the spokes container -- that is, hubDevices[0] will be the
|
||||
* net device used on the hub that talks to spokes[0]. the container entry
|
||||
* spokeDevices[0] will have the device that hubDevices[0] talks to -- those
|
||||
* two devices are the ones that connect hub to spokes[0].
|
||||
*
|
||||
* \param hub The central node of the star network
|
||||
* \param spokes A NodeContainer of the nodes that will be the spoke (leaf)
|
||||
* nodes
|
||||
* \param hubDevices A NetDeviceContainer that will be filled with pointers
|
||||
* to the point-to-point net devices created on the hub.
|
||||
* \param spokeDevices A NetDeviceContainer that will be filled with pointers
|
||||
* to the point-to-point net devices created on each of
|
||||
* the spokes.
|
||||
*/
|
||||
void InstallStar (Ptr<Node> hub, NodeContainer spokes,
|
||||
NetDeviceContainer& hubDevices, NetDeviceContainer& spokeDevices);
|
||||
|
||||
private:
|
||||
static void RxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet);
|
||||
static void EnqueueEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet);
|
||||
|
||||
Reference in New Issue
Block a user