OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2008 INRIA | 3 * Copyright (c) 2008 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace ns3 { | 29 namespace ns3 { |
30 | 30 |
31 NS_OBJECT_ENSURE_REGISTERED (SimpleChannel); | 31 NS_OBJECT_ENSURE_REGISTERED (SimpleChannel); |
32 | 32 |
33 TypeId· | 33 TypeId· |
34 SimpleChannel::GetTypeId (void) | 34 SimpleChannel::GetTypeId (void) |
35 { | 35 { |
36 static TypeId tid = TypeId ("ns3::SimpleChannel") | 36 static TypeId tid = TypeId ("ns3::SimpleChannel") |
37 .SetParent<Channel> () | 37 .SetParent<Channel> () |
38 .AddConstructor<SimpleChannel> () | 38 .AddConstructor<SimpleChannel> () |
| 39 .AddAttribute ("Delay", "Transmission delay through the channel", |
| 40 TimeValue (Seconds (0)), |
| 41 MakeTimeAccessor (&SimpleChannel::m_delay), |
| 42 MakeTimeChecker ()) |
39 ; | 43 ; |
40 return tid; | 44 return tid; |
41 } | 45 } |
42 | 46 |
43 SimpleChannel::SimpleChannel () | 47 SimpleChannel::SimpleChannel () |
44 { | 48 { |
45 NS_LOG_FUNCTION (this); | 49 NS_LOG_FUNCTION (this); |
46 } | 50 } |
47 | 51 |
48 void | 52 void |
49 SimpleChannel::Send (Ptr<Packet> p, uint16_t protocol, | 53 SimpleChannel::Send (Ptr<Packet> p, uint16_t protocol, |
50 Mac48Address to, Mac48Address from, | 54 Mac48Address to, Mac48Address from, |
51 Ptr<SimpleNetDevice> sender) | 55 Ptr<SimpleNetDevice> sender) |
52 { | 56 { |
53 NS_LOG_FUNCTION (this << p << protocol << to << from << sender); | 57 NS_LOG_FUNCTION (this << p << protocol << to << from << sender); |
54 for (std::vector<Ptr<SimpleNetDevice> >::const_iterator i = m_devices.begin ()
; i != m_devices.end (); ++i) | 58 for (std::vector<Ptr<SimpleNetDevice> >::const_iterator i = m_devices.begin ()
; i != m_devices.end (); ++i) |
55 { | 59 { |
56 Ptr<SimpleNetDevice> tmp = *i; | 60 Ptr<SimpleNetDevice> tmp = *i; |
57 if (tmp == sender) | 61 if (tmp == sender) |
58 { | 62 { |
59 continue; | 63 continue; |
60 } | 64 } |
61 Simulator::ScheduleWithContext (tmp->GetNode ()->GetId (), Seconds (0), | 65 Simulator::ScheduleWithContext (tmp->GetNode ()->GetId (), m_delay, |
62 &SimpleNetDevice::Receive, tmp, p->Copy ()
, protocol, to, from); | 66 &SimpleNetDevice::Receive, tmp, p->Copy ()
, protocol, to, from); |
63 } | 67 } |
64 } | 68 } |
65 | 69 |
66 void | 70 void |
67 SimpleChannel::Add (Ptr<SimpleNetDevice> device) | 71 SimpleChannel::Add (Ptr<SimpleNetDevice> device) |
68 { | 72 { |
69 NS_LOG_FUNCTION (this << device); | 73 NS_LOG_FUNCTION (this << device); |
70 m_devices.push_back (device); | 74 m_devices.push_back (device); |
71 } | 75 } |
72 | 76 |
73 uint32_t | 77 uint32_t |
74 SimpleChannel::GetNDevices (void) const | 78 SimpleChannel::GetNDevices (void) const |
75 { | 79 { |
76 NS_LOG_FUNCTION (this); | 80 NS_LOG_FUNCTION (this); |
77 return m_devices.size (); | 81 return m_devices.size (); |
78 } | 82 } |
79 Ptr<NetDevice> | 83 Ptr<NetDevice> |
80 SimpleChannel::GetDevice (uint32_t i) const | 84 SimpleChannel::GetDevice (uint32_t i) const |
81 { | 85 { |
82 NS_LOG_FUNCTION (this << i); | 86 NS_LOG_FUNCTION (this << i); |
83 return m_devices[i]; | 87 return m_devices[i]; |
84 } | 88 } |
85 | 89 |
86 } // namespace ns3 | 90 } // namespace ns3 |
OLD | NEW |