Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #ifndef __INET_MACRELAYUNITBASE_H
00020 #define __INET_MACRELAYUNITBASE_H
00021 
00022 #include <omnetpp.h>
00023 #include <map>
00024 #include <string>
00025 #include "MACAddress.h"
00026 
00027 class EtherFrame;
00028 
00029 
00036 class INET_API MACRelayUnitBase : public cSimpleModule
00037 {
00038   public:
00039     
00040     struct AddressEntry
00041     {
00042         int portno;              
00043         simtime_t insertionTime; 
00044     };
00045 
00046   protected:
00047     struct MAC_compare
00048     {
00049         bool operator()(const MACAddress& u1, const MACAddress& u2) const
00050             {return u1.compareTo(u2) < 0;}
00051     };
00052 
00053     typedef std::map<MACAddress, AddressEntry, MAC_compare> AddressTable;
00054 
00055     
00056     int numPorts;               
00057     int addressTableSize;       
00058     simtime_t agingTime;        
00059 
00060     AddressTable addresstable;  
00061 
00062     int seqNum;                 
00063 
00064   protected:
00068     virtual void initialize();
00069 
00077     virtual void handleAndDispatchFrame(EtherFrame *frame, int inputport);
00078 
00083     virtual void broadcastFrame(EtherFrame *frame, int inputport);
00084 
00088     virtual void readAddressTable(const char* fileName);
00089 
00093     virtual void updateTableWithAddress(MACAddress& address, int portno);
00094 
00098     virtual int getPortForAddress(MACAddress& address);
00099 
00103     virtual void printAddressTable();
00104 
00108     virtual void removeAgedEntriesFromTable();
00109 
00113     virtual void removeOldestTableEntry();
00114 
00119     virtual void sendPauseFrame(int portno, int pauseUnits);
00120 
00121 };
00122 
00123 #endif
00124 
00125