17 #ifndef HH_SENF_Ext_NetEmu_EmulatedWirelessInterface_ 18 #define HH_SENF_Ext_NetEmu_EmulatedWirelessInterface_ 1 21 #include <boost/signals2.hpp> 22 #include <boost/multi_index_container.hpp> 23 #include <boost/multi_index/ordered_index.hpp> 24 #include <boost/multi_index/composite_key.hpp> 78 typedef boost::function<void (UDPClientHandle::Address const & address)>
UserCallback;
94 Entry(
unsigned frequency_,
unsigned bandwidth_);
95 Entry(
unsigned frequency_,
unsigned bandwidth_, UDPClientHandle::Address address_,
96 unsigned nUsers_,
unsigned ownerNodeId_);
102 struct ByFrequency {};
108 :
public boost::multi_index::indexed_by<
109 boost::multi_index::ordered_unique<
110 boost::multi_index::tag<ByFrequency>,
111 boost::multi_index::composite_key<
113 boost::multi_index::member<Entry, unsigned, &Entry::frequency>,
114 boost::multi_index::member<Entry, unsigned, &Entry::bandwidth> > >,
115 boost::multi_index::ordered_non_unique<
116 boost::multi_index::tag<ByAddress>,
117 boost::multi_index::member<Entry, UDPClientHandle::Address, &Entry::address> >
121 typedef boost::multi_index_container<Entry, EntryIndices> Entries;
126 unsigned interfaceId;
127 mutable UserCallback callback;
131 UserCallback callback_);
134 struct ByInterfaceId {};
145 Entry const * b)
const;
146 bool operator()(
Entry const * a,
151 :
public boost::multi_index::indexed_by<
152 boost::multi_index::ordered_unique<
153 boost::multi_index::tag<ByInterfaceId>,
154 boost::multi_index::member<User, unsigned, &User::interfaceId> >,
155 boost::multi_index::ordered_non_unique<
156 boost::multi_index::tag<ByEntry>,
157 boost::multi_index::member<
158 User, Entries::index_iterator<ByFrequency>::type, &User::entry>,
163 typedef boost::multi_index_container<User, UserIndices> Users;
165 typedef boost::multi_index::member<User, unsigned, &User::interfaceId> GetInterfaceId;
166 typedef boost::transform_iterator<
172 typedef boost::iterator_range<InterfaceIdIterator>
UsersRange;
180 void consoleGroup(UDPClientHandle::Address
const & group);
211 void release(
unsigned interfaceId);
231 UsersRange
users(EntriesRange::iterator i)
const;
247 void consoleList(std::ostream & os)
const;
251 UDPClientHandle::Address
address);
259 UDPClientHandle::Address
address);
265 UDPClientHandle::Address getAddress();
266 void updateAddress(
Entry const & entry);
271 UDPClientHandle::Address group_;
272 boost::scoped_ptr<console::UDPServer> server_;
276 unsigned lastAddress_;
304 public detail::InterfaceAccess<WirelessInterface>,
305 public detail::CommfaceAccess<EmulatedWirelessReceiver, EmulatedWirelessTransmitter>
308 using detail::InterfaceAccess<WirelessInterface>::interface;
309 using detail::CommfaceAccess<EmulatedWirelessReceiver, EmulatedWirelessTransmitter>::receiver;
310 using detail::CommfaceAccess<EmulatedWirelessReceiver, EmulatedWirelessTransmitter>::transmitter;
312 typedef std::vector<console::ValueRange<unsigned> >
Ranges;
319 void registerFrequency(
unsigned frequencyLower,
unsigned frequencyUpper,
320 unsigned bandwidthLower,
unsigned bandwidthUpper);
322 void registerFrequency(Ranges
const & frequencies, Ranges
const & bandwidths);
329 void distanceCallback(DistanceCallback cb);
335 unsigned emulatedFrequency()
const;
336 unsigned emulatedBandwidth()
const;
341 void emulatedCoverageRange(
unsigned distance);
349 DistanceCallback distanceCallback_;
359 public detail::InterfaceAccess<WirelessInterface>,
360 public detail::InterfaceAccess<EmulatedWirelessInterface>
363 typedef detail::InterfaceAccess<EmulatedWirelessInterface>
emui;
364 typedef detail::InterfaceAccess<WirelessInterface>
basei;
385 detail::EmulatedWirelessInterfaceReceiveFilter filter_;
387 unsigned rssiRandomnessRange_;
388 unsigned noiseRandomnessRange_;
390 friend class detail::EmulatedWirelessInterfaceReceiveFilter;
399 public detail::InterfaceAccess<WirelessInterface>,
400 public detail::InterfaceAccess<EmulatedWirelessInterface>
403 typedef detail::InterfaceAccess<EmulatedWirelessInterface>
emui;
404 typedef detail::InterfaceAccess<WirelessInterface>
basei;
406 typedef std::vector< console::ValueRange<int> >
Ranges;
408 void registerTxPower(
int power);
409 void registerTxPower(
int powerLow,
int powerHigh);
410 void registerTxPower(Ranges
const & powers);
420 detail::EmulatedWirelessInterfaceTransmitFilter filter_;
void allocate(unsigned interfaceId, unsigned frequency, unsigned bandwidth, UserCallback cb)
Register for a wireless channel.
WirelessInterfaceAPI public header.
std::vector< console::ValueRange< int > > Ranges
Emulated interface base-class for transmit capable interfaces.
detail::InterfaceAccess< EmulatedWirelessInterface > emui
detail::InterfaceAccess< EmulatedWirelessInterface > emui
boost::iterator_range< InterfaceIdIterator > UsersRange
Iterator range of interface id's using a channel.
#define SENF_LOG_CLASS_AREA()
Emulated wireless receiver base-class.
Emulated wireless transmitter base-class.
void nextAddress(unsigned index)
Set next address index to use (if free)
EmulatedInterface public header.
unsigned nUsers
Number of active channel users.
detail::InterfaceAccess< WirelessInterface > basei
Annotations public header.
Emulated interface base-class.
UDPClientHandle::Address consoleGroup() const
Get control channel multicast group/port.
UDPClientHandle::Address address
Assigned multicast address.
Wireless spectrum management.
StatsDataCollectorKernel signal
boost::iterator_range< Entries::index_iterator< ByFrequency >::type > EntriesRange
Iterator range of channel entries.
ppi::connector::ActiveOutputJack receiverJack
EmulatedFrequencyRegistry & emulatedFrequencyRegistry()
Channel allocation entry.
unsigned bandwidth
Channel bandwidth.
std::vector< console::ValueRange< unsigned > > Ranges
Emulated interface base-class for receive capable interfaces.
boost::signals2::signal< void(Entry const &, unsigned nodeId, ChangeType type)> channelPopulationChanged
Channel population changed signal.
unsigned ownerNodeId
Channel master.
unsigned frequency
Channel frequency.
std::pair< INet4Network, unsigned > addressRange() const
Get address/port range of channel multicast addresses.
Emulated wireless interface base-class.
boost::function< void(unsigned frequency, unsigned bandwidth)> CollisionCallback
Callback type called for channel collisions.
void start()
Start multicast address/port allocation.
friend class EmulatedFrequencyRegistry
ppi::connector::PassiveInputJack transmitterJack
void release(unsigned interfaceId)
Release channel registration.
UsersRange users(EntriesRange::iterator i) const
Get interface id's of local users of a given channel.
senf::UDPv4ClientSocketHandle UDPClientHandle
void stop()
Stop multicast address/port allocation.
void collisionCallback(CollisionCallback cb)
Change collision callback.
boost::function< double(unsigned nodeId)> DistanceCallback
boost::function< void(UDPClientHandle::Address const &address)> UserCallback
Callback type called to set channel address.
EntriesRange entries() const
Get all channel entries.
detail::InterfaceAccess< WirelessInterface > basei