Loading...
Searching...
No Matches
satellite-simple-channel.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014 Magister Solutions Ltd.
4 *
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
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Sami Rantanen <sami.rantanen@magister.fi>
19 */
20
22
24
25#include "ns3/log.h"
26#include "ns3/node.h"
27#include "ns3/packet.h"
28#include "ns3/simulator.h"
29
30#include <cstddef>
31#include <vector>
32
33NS_LOG_COMPONENT_DEFINE("SatSimpleChannel");
34
35namespace ns3
36{
37
38NS_OBJECT_ENSURE_REGISTERED(SatSimpleChannel);
39
40TypeId
42{
43 static TypeId tid =
44 TypeId("ns3::SatSimpleChannel").SetParent<Channel>().AddConstructor<SatSimpleChannel>();
45 return tid;
46}
47
49{
50 NS_LOG_FUNCTION(this);
51}
52
53void
55 uint16_t protocol,
56 Mac48Address to,
57 Mac48Address from,
58 Ptr<SatSimpleNetDevice> sender)
59{
60 NS_LOG_FUNCTION(this << p << protocol << to << from << sender);
61 for (std::vector<Ptr<SatSimpleNetDevice>>::const_iterator i = m_devices.begin();
62 i != m_devices.end();
63 ++i)
64 {
65 Ptr<SatSimpleNetDevice> device = *i;
66
67 if (device != sender)
68 {
69 Simulator::ScheduleWithContext(device->GetNode()->GetId(),
70 Seconds(0),
72 device,
73 p->Copy(),
74 protocol,
75 to,
76 from);
77 }
78 }
79}
80
81void
82SatSimpleChannel::Add(Ptr<SatSimpleNetDevice> device)
83{
84 NS_LOG_FUNCTION(this << device);
85 m_devices.push_back(device);
86}
87
88std::size_t
90{
91 NS_LOG_FUNCTION(this);
92 return m_devices.size();
93}
94
95Ptr<NetDevice>
96SatSimpleChannel::GetDevice(std::size_t i) const
97{
98 NS_LOG_FUNCTION(this << i);
99 return m_devices[i];
100}
101
102} // namespace ns3
The satellite simple channel, for satellite public and backbone networks.
SatSimpleChannel()
Default constructor.
virtual void Send(Ptr< Packet > p, uint16_t protocol, Mac48Address to, Mac48Address from, Ptr< SatSimpleNetDevice > sender)
A packet is sent by a net device.
virtual std::size_t GetNDevices(void) const
std::vector< Ptr< SatSimpleNetDevice > > m_devices
static TypeId GetTypeId(void)
Get the type ID.
virtual void Add(Ptr< SatSimpleNetDevice > device)
Attached a net device to the channel.
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
void Receive(Ptr< Packet > packet, uint16_t protocol, Mac48Address to, Mac48Address from)
Receive a packet from a connected SatSimpleChannel.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.