Alex Bikfalvi
SimStream Documentation
Router.cpp
00001 #include "Headers.h" 00002 #include "Router.h" 00003 #include "Console.h" 00004 00005 CRouter::CRouter( 00006 __uint32 id, 00007 CSimHandler* sim, 00008 CAddress address, 00009 __uint32 numLinks, 00010 CRoute* route, 00011 CInfo* info, 00012 CAddress* rp 00013 ) : CNode(id, sim, address, numLinks, route, info) 00014 { 00015 // Initialize layers 00016 this->layerIgmp = new CLayerIgmp(this->sim, this->address, this->info->NumGroups(), CLayerIgmp::IGMP_ROUTER); 00017 this->layerIpRoute = new CLayerIpRoute( 00018 this->sim, 00019 this->address, 00020 this->route 00021 ); 00022 this->layerPimSm = new CLayerPimSm( 00023 this->sim, 00024 this->info->NumGroups(), 00025 this->address, 00026 rp, 00027 this->route 00028 ); 00029 00030 // Create layer connections 00031 // IP layer <-> IGMP layer 00032 (*this->layerIp->EventRecv()) += this->layerIgmp->DelegateRecv(); 00033 (*this->layerIgmp->EventSend()) += this->layerIp->DelegateSend(); 00034 // IGMP layer <-> IP multicast layer 00035 (*this->layerIgmp->EventJoin()) += this->layerIpMcast->DelegateJoin(); 00036 (*this->layerIgmp->EventLeave()) += this->layerIpMcast->DelegateLeave(); 00037 (*this->layerIgmp->EventLocalJoin()) += this->layerIpMcast->DelegateLocalJoin(); 00038 (*this->layerIgmp->EventLocalLeave()) += this->layerIpMcast->DelegateLocalLeave(); 00039 // Layer IP <-> Layer IP route 00040 (*this->layerIp->EventRecv()) += this->layerIpRoute->DelegateRecv(); 00041 (*this->layerIpRoute->EventSend()) += this->layerIp->DelegateSend(); 00042 // Layer IGMP <-> Layer PIM-SM 00043 (*this->layerIgmp->EventJoin()) += this->layerPimSm->DelegateJoin(); 00044 (*this->layerIgmp->EventLeave()) += this->layerPimSm->DelegateLeave(); 00045 // Layer IP <-> Layer PIM-SM 00046 (*this->layerIp->EventRecv()) += this->layerPimSm->DelegateRecv(); 00047 (*this->layerPimSm->EventSend()) += this->layerIp->DelegateSend(); 00048 // Layer PIM-SM <-> Layer IP multicast 00049 (*this->layerPimSm->EventJoin()) += this->layerIpMcast->DelegateJoin(); 00050 (*this->layerPimSm->EventLeave()) += this->layerIpMcast->DelegateLeave(); 00051 } 00052 00053 CRouter::~CRouter() 00054 { 00055 // Delete layers 00056 delete this->layerIgmp; 00057 delete this->layerIpRoute; 00058 delete this->layerPimSm; 00059 } 00060 00061 void CRouter::Finalize() 00062 { 00063 // Call base class finalizer 00064 CNode::Finalize(); 00065 00066 // Call the finalizer for each layer 00067 this->layerIgmp->Finalize(); 00068 this->layerIpRoute->Finalize(); 00069 this->layerPimSm->Finalize(); 00070 }
Last updated: February 8, 2011