src/devices/p2p/p2p-channel.cc
changeset 568 e1660959ecbb
parent 378 32bd402ea5ea
child 767 c36570ed4f5e
equal deleted inserted replaced
567:6fb98941c36f 568:e1660959ecbb
    68   NS_DEBUG("PointToPointChannel::PointToPointChannel (" << name << ", " << 
    68   NS_DEBUG("PointToPointChannel::PointToPointChannel (" << name << ", " << 
    69     bps.GetBitRate() << ", " << delay << ")");
    69     bps.GetBitRate() << ", " << delay << ")");
    70 }
    70 }
    71 
    71 
    72   void
    72   void
    73 PointToPointChannel::Attach(PointToPointNetDevice *device)
    73 PointToPointChannel::Attach(Ptr<PointToPointNetDevice> device)
    74 {
    74 {
    75   NS_DEBUG("PointToPointChannel::Attach (" << device << ")");
    75   NS_DEBUG("PointToPointChannel::Attach (" << device << ")");
    76   NS_ASSERT(m_nDevices < N_DEVICES && "Only two devices permitted");
    76   NS_ASSERT(m_nDevices < N_DEVICES && "Only two devices permitted");
    77   NS_ASSERT(device);
    77   NS_ASSERT(device != 0);
    78 
    78 
    79   m_link[m_nDevices].m_src = device;
    79   m_link[m_nDevices].m_src = device;
    80   ++m_nDevices;
    80   ++m_nDevices;
    81 //
    81 //
    82 // If we have both devices connected to the channel, then finish introducing
    82 // If we have both devices connected to the channel, then finish introducing
    90       m_link[1].m_state = IDLE;
    90       m_link[1].m_state = IDLE;
    91     }
    91     }
    92 }
    92 }
    93 
    93 
    94 bool
    94 bool
    95 PointToPointChannel::TransmitStart(Packet& p, PointToPointNetDevice* src)
    95 PointToPointChannel::TransmitStart(Packet& p, Ptr<PointToPointNetDevice> src)
    96 {
    96 {
    97   NS_DEBUG ("PointToPointChannel::TransmitStart (" << &p << ", " << src << 
    97   NS_DEBUG ("PointToPointChannel::TransmitStart (" << &p << ", " << src << 
    98             ")");
    98             ")");
    99   NS_DEBUG ("PointToPointChannel::TransmitStart (): UID is " << 
    99   NS_DEBUG ("PointToPointChannel::TransmitStart (): UID is " << 
   100             p.GetUid () << ")");
   100             p.GetUid () << ")");
   115   m_link[wire].m_state = TRANSMITTING;
   115   m_link[wire].m_state = TRANSMITTING;
   116   return true;
   116   return true;
   117 }
   117 }
   118 
   118 
   119 bool
   119 bool
   120 PointToPointChannel::TransmitEnd(Packet& p, PointToPointNetDevice* src)
   120 PointToPointChannel::TransmitEnd(Packet& p, Ptr<PointToPointNetDevice> src)
   121 {
   121 {
   122   NS_DEBUG("PointToPointChannel::TransmitEnd (" << &p << ", " << src << ")");
   122   NS_DEBUG("PointToPointChannel::TransmitEnd (" << &p << ", " << src << ")");
   123   NS_DEBUG ("PointToPointChannel::TransmitEnd (): UID is " << 
   123   NS_DEBUG ("PointToPointChannel::TransmitEnd (): UID is " << 
   124             p.GetUid () << ")");
   124             p.GetUid () << ")");
   125 
   125 
   145 }
   145 }
   146 
   146 
   147 void
   147 void
   148 PointToPointChannel::PropagationCompleteEvent(
   148 PointToPointChannel::PropagationCompleteEvent(
   149   Packet p, 
   149   Packet p, 
   150   PointToPointNetDevice *src)
   150   Ptr<PointToPointNetDevice> src)
   151 {
   151 {
   152   NS_DEBUG("PointToPointChannel::PropagationCompleteEvent (" << &p << ", " << 
   152   NS_DEBUG("PointToPointChannel::PropagationCompleteEvent (" << &p << ", " << 
   153     src << ")");
   153     src << ")");
   154   NS_DEBUG ("PointToPointChannel::PropagationCompleteEvent (): UID is " << 
   154   NS_DEBUG ("PointToPointChannel::PropagationCompleteEvent (): UID is " << 
   155     p.GetUid () << ")");
   155     p.GetUid () << ")");
   167 PointToPointChannel::GetNDevices (void) const
   167 PointToPointChannel::GetNDevices (void) const
   168 {
   168 {
   169   return m_nDevices;
   169   return m_nDevices;
   170 }
   170 }
   171 
   171 
   172 NetDevice *
   172 Ptr<NetDevice>
   173 PointToPointChannel::GetDevice (uint32_t i) const
   173 PointToPointChannel::GetDevice (uint32_t i) const
   174 {
   174 {
   175   NS_ASSERT(i < 2);
   175   NS_ASSERT(i < 2);
   176   return m_link[i].m_src;
   176   return m_link[i].m_src;
   177 }
   177 }