Skip to content

Commit

Permalink
disable S2S; support minElevationAngle for drones
Browse files Browse the repository at this point in the history
* Add a flag that disables S2S communication
* Add a SatDrone that supports Wlan and satellite communication
* Add a dedicated minElevationAngle filter for drones
  • Loading branch information
m-franke committed Nov 23, 2023
1 parent d78d6fe commit e40f825
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ MediumLimitCache::MediumLimitCache() :
maxTransmissionDuration(NaN),
maxCommunicationRange(m(NaN)),
maxInterferenceRange(m(NaN)),
minElevationAngle(deg(NaN))
minElevationAngleV2S(deg(NaN)),
minElevationAngleD2S(deg(NaN)),
disableS2SCommunication(false)
{
}

Expand All @@ -99,7 +101,9 @@ void MediumLimitCache::initialize(int stage)
WATCH(maxTransmissionDuration);
WATCH(maxCommunicationRange);
WATCH(maxInterferenceRange);
WATCH(minElevationAngle);
WATCH(minElevationAngleV2S);
WATCH(minElevationAngleD2S);
WATCH(disableS2SCommunication);
}
}

Expand All @@ -118,7 +122,9 @@ std::ostream& MediumLimitCache::printToStream(std::ostream &stream, int level) c
<< ", maxTransmissionDuration = " << maxTransmissionDuration
<< ", maxCommunicationRange = " << maxCommunicationRange
<< ", maxInterferenceRange = " << maxInterferenceRange
<< ", minElevationAngle = " << minElevationAngle;
<< ", minElevationAngleV2S = " << minElevationAngleV2S
<< ", minElevationAngleD2S = " << minElevationAngleD2S
<< ", disableS2SCommunication = " << disableS2SCommunication;
return stream;
}

Expand All @@ -135,7 +141,9 @@ void MediumLimitCache::updateLimits()
maxTransmissionDuration = computeMaxTransmissionDuration();
maxCommunicationRange = computeMaxCommunicationRange();
maxInterferenceRange = computeMaxInterferenceRange();
minElevationAngle = computeMinElevationAngle();
minElevationAngleV2S = computeMinElevationAngleV2S();
minElevationAngleD2S = computeMinElevationAngleD2S();
disableS2SCommunication = par("disableS2SCommunication");
}

void MediumLimitCache::addRadio(const IRadio *radio)
Expand Down Expand Up @@ -218,9 +226,14 @@ m MediumLimitCache::computeMaxInterferenceRange() const
return maxIgnoreNaN(m(par("maxInterferenceRange")), computeMaxRange(maxTransmissionPower, minInterferencePower));
}

deg MediumLimitCache::computeMinElevationAngle() const
deg MediumLimitCache::computeMinElevationAngleV2S() const
{
return deg(par("minElevationAngle"));
return deg(par("minElevationAngleV2S"));
}

deg MediumLimitCache::computeMinElevationAngleD2S() const
{
return deg(par("minElevationAngleD2S"));
}

const simtime_t MediumLimitCache::computeMinInterferenceTime() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,17 @@ class INET_API MediumLimitCache : public cModule, public IMediumLimitCache
*/
m maxInterferenceRange;
/**
* The minimum elevation angle between devices using the satNic.
* The minimum elevation angle between SatCars and Satellites using the satNic.
*/
deg minElevationAngle;
deg minElevationAngleV2S;
/**
* The minimum elevation angle between Drones and Satellites using the satNic.
*/
deg minElevationAngleD2S;
/**
* Disable satellite to satellite communication.
*/
bool disableS2SCommunication;
//@}

protected:
Expand All @@ -131,7 +139,8 @@ class INET_API MediumLimitCache : public cModule, public IMediumLimitCache
virtual m computeMaxRange(W maxTransmissionPower, W minReceptionPower) const;
virtual m computeMaxCommunicationRange() const;
virtual m computeMaxInterferenceRange() const;
virtual deg computeMinElevationAngle() const;
virtual deg computeMinElevationAngleV2S() const;
virtual deg computeMinElevationAngleD2S() const;

virtual void updateLimits();
//@}
Expand Down Expand Up @@ -162,7 +171,9 @@ class INET_API MediumLimitCache : public cModule, public IMediumLimitCache

virtual m getMaxCommunicationRange() const override { return maxCommunicationRange; }
virtual m getMaxInterferenceRange() const override { return maxInterferenceRange; }
virtual deg getMinElevationAngle() const override { return minElevationAngle;}
virtual deg getMinElevationAngleV2S() const override { return minElevationAngleV2S;}
virtual deg getMinElevationAngleD2S() const override { return minElevationAngleD2S;}
virtual bool getDisableS2SCommunication() const override { return disableS2SCommunication;}

virtual m getMaxCommunicationRange(const IRadio *radio) const override;
virtual m getMaxInterferenceRange(const IRadio *radio) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ module MediumLimitCache like IMediumLimitCache
double maxTransmissionDuration @unit(s) = default(10ms); // maximum duration of a transmission on the medium
double maxCommunicationRange @unit(m) = default(nan m); // maximum communication range on the medium, NaN means medium computes using transmitter and receiver models
double maxInterferenceRange @unit(m) = default(nan m); // maximum interference range on the medium, NaN means medium computes using transmitter and receiver models
double minElevationAngle @unit(deg) = default(nan deg);// minimum elevation angle between to vehicles transmitting via the satNic, NaN completly ignores the minElevationAngle.
double minElevationAngleV2S @unit(deg) = default(nan deg); // minimum elevation angle between a vehicle and a satelite such that communication is possible, NaN completly ignores the minElevationAngle.
double minElevationAngleD2S @unit(deg) = default(nan deg); // minimum elevation angle between a drone and a satelite such that communication is possible, NaN completly ignores the minElevationAngle.
bool disableS2SCommunication = default(false); // disables communication between satelites
@display("i=block/table2");
@class(MediumLimitCache);
}
Expand Down
60 changes: 50 additions & 10 deletions lib/inet/src/inet/physicallayer/common/packetlevel/RadioMedium.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,28 +204,64 @@ bool RadioMedium::matchesMacAddressFilter(const IRadio *radio, const Packet *pac
return false;
}

bool RadioMedium::isElevationAngleLargeEnough(const ITransmission *transmission, const IArrival *arrival) const
bool RadioMedium::areReceiverAndTransmitterSatellites(const Radio* receiverRadio, const ITransmission *transmission) const
{
deg minElevationAngle = mediumLimitCache->getMinElevationAngle();
if (std::isnan(minElevationAngle.get())) return true;
// Determine whether the transmitter is a satellite
const Radio* transmitter = dynamic_cast<const Radio*>(transmission->getTransmitter());
if (transmitter == nullptr) {
throw cRuntimeError("No radio found with id %d", transmission->getTransmitter()->getId());
}
std::string transmitterModuleType(transmitter->getParentModule()->getParentModule()->getNedTypeName());
if (transmitterModuleType != "space_veins.nodes.Satellite") {
return false;
}
// Determine whether the receiver is a satellite
if (receiverRadio == nullptr) {
throw cRuntimeError("receiverRadio is nullptr.");
}
std::string receiverModuleType(receiverRadio->getParentModule()->getParentModule()->getNedTypeName());
if (receiverModuleType != "space_veins.nodes.Satellite") {
return false;
}
return true;
}

bool RadioMedium::isElevationAngleLargeEnough(const Radio *receiverRadio, const ITransmission *transmission, const IArrival *arrival) const
{
// Get receiver and transmitter type
const Radio* transmitter = dynamic_cast<const Radio*>(transmission->getTransmitter());
if (transmitter == nullptr) {
throw cRuntimeError("No radio found with id %d", transmission->getTransmitter()->getId());
}
// Determine whether the transmitter is a vehicle or a satellite
std::string moduleType(transmitter->getParentModule()->getParentModule()->getNedTypeName());
std::string transmitterModuleType(transmitter->getParentModule()->getParentModule()->getNedTypeName());
if (receiverRadio == nullptr) {
throw cRuntimeError("receiverRadio is nullptr.");
}
std::string receiverModuleType(receiverRadio->getParentModule()->getParentModule()->getNedTypeName());
// Set minElvationAngle according to the communication type
deg minElevationAngle;
if (receiverModuleType == "space_veins.nodes.SatDrone" || transmitterModuleType == "space_veins.nodes.SatDrone") {
minElevationAngle = mediumLimitCache->getMinElevationAngleD2S();
} else if (receiverModuleType == "space_veins.nodes.SatCar" || transmitterModuleType == "space_veins.nodes.SatCar") {
minElevationAngle = mediumLimitCache->getMinElevationAngleV2S();
} else {
throw cRuntimeError("Neither V2S nor D2S communication: transmitter module: %s, receiver module: %s", transmitterModuleType.c_str(), receiverModuleType.c_str());
}
// Check whether the minElevationAngle is NaN
if (std::isnan(minElevationAngle.get())) return true;
// Check whether the transmitter or receiver is the satellite
Coord direction; // transmission direction vector always has to point towards the satellite such that we can properly calculate the elevation angle between vehicle and satellite.
if (moduleType == "space_veins.nodes.Satellite") {
if (transmitterModuleType == "space_veins.nodes.Satellite") {
// satellite is transmitter
direction = transmission->getStartPosition() - arrival->getEndPosition();
}
else if (moduleType == "space_veins.nodes.SatCar") {
// vehicle is transmitter
else if (receiverModuleType == "space_veins.nodes.Satellite") {
// satellite is receiver
direction = arrival->getEndPosition() - transmission->getStartPosition();
}
direction.normalize();
deg elevationAngle = inet::deg(inet::rad(asin(direction.z)));
if (elevationAngle.get() > minElevationAngle.get()) return true;
if (elevationAngle.get() >= minElevationAngle.get()) return true;
return false;
}

Expand Down Expand Up @@ -678,7 +714,11 @@ bool RadioMedium::isPotentialReceiver(const IRadio *radio, const ITransmission *
const IArrival *arrival = getArrival(radio, transmission);
return isInCommunicationRange(transmission, arrival->getStartPosition(), arrival->getEndPosition());
}
else if (!isElevationAngleLargeEnough(transmission, getArrival(radio, transmission))) {
else if (mediumLimitCache->getDisableS2SCommunication() && areReceiverAndTransmitterSatellites(receiverRadio, transmission)) {
EV_DEBUG << "Satellite to satellite communication is disabled." << std::endl;
return false;
}
else if (!isElevationAngleLargeEnough(receiverRadio, transmission, getArrival(radio, transmission))) {
EV_DEBUG << "ElevationAngle is not large enough -> is not a potential receiver." << std::endl;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ class INET_API RadioMedium : public cSimpleModule, public cListener, public IRad
*/
virtual bool isPotentialReceiver(const IRadio *receiver, const ITransmission *transmission) const;

virtual bool isElevationAngleLargeEnough(const ITransmission *transmission, const IArrival *arrival) const;
virtual bool areReceiverAndTransmitterSatellites(const Radio* receiverRadio, const ITransmission *transmission) const;
virtual bool isElevationAngleLargeEnough(const Radio *receiverRadio, const ITransmission *transmission, const IArrival *arrival) const;
virtual bool isInCommunicationRange(const ITransmission *transmission, const Coord startPosition, const Coord endPosition) const;
virtual bool isInInterferenceRange(const ITransmission *transmission, const Coord startPosition, const Coord endPosition) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,19 @@ class INET_API IMediumLimitCache : public IPrintableObject
virtual m getMaxInterferenceRange(const IRadio *radio) const = 0;

/**
* Returns the minimum required elevation angle such that two satNics can
* communicate, NaN if unspecified.
* Returns the minimum required elevation angle such that a vehicle and
* a satellite can communicate, NaN if unspecified.
*/
virtual deg getMinElevationAngle() const = 0;
virtual deg getMinElevationAngleV2S() const = 0;
/**
* Returns the minimum required elevation angle such that a drone and
* a satellite can communicate, NaN if unspecified.
*/
virtual deg getMinElevationAngleD2S() const = 0;
/**
* Returns whether satellite to satellite communication is disabled.
*/
virtual bool getDisableS2SCommunication() const = 0;
};

} // namespace physicallayer
Expand Down
56 changes: 56 additions & 0 deletions src/space_veins/nodes/SatDrone.ned
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Copyright (C) 2008 Christoph Sommer <[email protected]>
// Copyright (C) 2021 Mario Franke <[email protected]>
//
// Documentation for these modules is at http://sat.car2x.org/
//
// SPDX-License-Identifier: GPL-2.0-or-later
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//

package space_veins.nodes;

import inet.node.base.ApplicationLayerNodeBase;
import inet.linklayer.contract.IWirelessInterface;

import space_veins.modules.statistics.VehicleStatistics.VehicleStatistics;

module SatDrone extends ApplicationLayerNodeBase
{
parameters:
int numSatelliteNics = default(1);

gates:
input satelliteRadioIn[numSatelliteNics]; // gate for satellite communication

submodules:
satNic[numSatelliteNics]: <default("SatelliteInterface")> like IWirelessInterface {
parameters:
@display("p=825,616,row,150;q=queue");
}

vehicleStatistics: VehicleStatistics;

connections allowunconnected:
for i=0..sizeof(satelliteRadioIn)-1 {
satelliteRadioIn[i] --> { @display("m=s"); } --> satNic[i].radioIn;
}
for i=0..sizeof(satelliteRadioIn)-1 {
satNic[i].upperLayerOut --> nl.in++;
satNic[i].upperLayerIn <-- nl.out++;
}

}

0 comments on commit e40f825

Please sign in to comment.