14.4 MacClassifier Class

The MacClassifier class extends the Classifier class to implement a simple broadcasting mechanism. It modifies the recv() method in the following way: since the replication of a packet is expensive, normally a unicast packet will be classified by the MAC destination address macDA_ and delivered directly to the MAC object with such an address. However, if the destination object cannot be found or if the MAC destination address is explicitly set to the broadcast address BCAST_ADDR, the packet will be replicated and sent to all MACs on the lan excluding the one that is the source of the packet. Finally, by setting the bound variable MacClassifier::bcast_ to a non-zero value, will cause MacClassifier always to replicate packets.

    class MacClassifier : public Classifier {
        void recv(Packet*, Handler*);

    void MacClassifier::recv(Packet* p, Handler*)
        Mac* mac;
        hdr_mac* mh = hdr_mac::access(p);

        if (bcast_ || mh-\>macDA() == BCAST_ADDR || (mac = (Mac *)find(p)) == 0) {
                // Replicate packets to all slots (broadcast)
                . . .

Tom Henderson 2011-11-05