|
INET Framework for OMNeT++/OMNEST
|
#include <UdpSocketIo.h>
◆ finish()
| void inet::UdpSocketIo::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
47 recordScalar(
"packets sent",
numSent);
49 ApplicationBase::finish();
◆ handleCrashOperation()
◆ handleMessageWhenUp()
| void inet::UdpSocketIo::handleMessageWhenUp |
( |
cMessage * |
message | ) |
|
|
overrideprotectedvirtual |
◆ handleStartOperation()
Implements inet::OperationalMixin< cSimpleModule >.
125 const char *localAddress = par(
"localAddress");
126 socket.
bind(*localAddress ? L3AddressResolver().resolve(localAddress) : L3Address(), par(
"localPort"));
127 const char *destAddrs = par(
"destAddress");
129 socket.
connect(L3AddressResolver().resolve(destAddrs), par(
"destPort"));
◆ handleStopOperation()
◆ initialize()
| void inet::UdpSocketIo::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
◆ numInitStages()
| virtual int inet::UdpSocketIo::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ refreshDisplay()
| void inet::UdpSocketIo::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
57 getDisplayString().setTagArg(
"t", 0, buf);
◆ setSocketOptions()
| void inet::UdpSocketIo::setSocketOptions |
( |
| ) |
|
|
protectedvirtual |
62 int timeToLive = par(
"timeToLive");
66 int dscp = par(
"dscp");
74 NetworkInterface *multicastInterface =
nullptr;
75 const char *multicastInterfaceName = par(
"multicastInterface");
76 if (multicastInterfaceName[0]) {
77 IInterfaceTable *ift = getModuleFromPar<IInterfaceTable>(par(
"interfaceTableModule"),
this);
78 multicastInterface = ift->findInterfaceByName(multicastInterfaceName);
79 if (!multicastInterface)
80 throw cRuntimeError(
"Wrong multicastInterface setting: no interface named \"%s\"", multicastInterfaceName);
84 auto multicastAddresses = check_and_cast<cValueArray *>(par(
"multicastAddresses").objectValue());
85 for (
int i = 0; i < multicastAddresses->size(); i++)
86 socket.
joinMulticastGroup(Ipv4Address(multicastAddresses->get(0).stringValue()), multicastInterface !=
nullptr ? multicastInterface->getInterfaceId() : -1);
88 bool receiveBroadcast = par(
"receiveBroadcast");
92 bool joinLocalMulticastGroups = par(
"joinLocalMulticastGroups");
93 if (joinLocalMulticastGroups) {
94 MulticastGroupList mgl = getModuleFromPar<IInterfaceTable>(par(
"interfaceTableModule"),
this)->collectMulticastGroups();
Referenced by handleStartOperation().
◆ socketClosed()
| void inet::UdpSocketIo::socketClosed |
( |
UdpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived()
| void inet::UdpSocketIo::socketDataArrived |
( |
UdpSocket * |
socket, |
|
|
Packet * |
packet |
|
) |
| |
|
overrideprotectedvirtual |
Notifies about data arrival, packet ownership is transferred to the callee.
Implements inet::UdpSocket::ICallback.
105 packet->removeTag<SocketInd>();
106 send(packet,
"trafficOut");
◆ socketErrorArrived()
Notifies about error indication arrival, indication ownership is transferred to the callee.
Implements inet::UdpSocket::ICallback.
111 EV_WARN <<
"Ignoring UDP error report " << indication->getName() << endl;
◆ dontFragment
| bool inet::UdpSocketIo::dontFragment = false |
|
protected |
◆ numReceived
| int inet::UdpSocketIo::numReceived = 0 |
|
protected |
◆ numSent
| int inet::UdpSocketIo::numSent = 0 |
|
protected |
◆ socket
The documentation for this class was generated from the following files:
void setOutputGate(cGate *toUdp)
Sets the gate on which to send to UDP.
Definition: UdpSocket.h:117
void setDscp(short dscp)
Sets the Ipv4 / Ipv6 dscp fields of packets sent from the UDP socket.
Definition: UdpSocket.cc:121
void setTimeToLive(int ttl)
Set the TTL (Ipv6: Hop Limit) field on sent packets.
Definition: UdpSocket.cc:112
State operationalState
Definition: OperationalMixin.h:23
void bind(int localPort)
Bind the socket to a local port number.
Definition: UdpSocket.cc:34
static std::string getReceivedPacketInfo(Packet *pk)
Utility function: returns a line of information about a packet received via UDP.
Definition: UdpSocket.cc:315
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
virtual void destroy() override
Notify the protocol that the owner of ISocket has destroyed the socket.
Definition: UdpSocket.cc:98
int numReceived
Definition: UdpSocketIo.h:22
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
void setCallback(ICallback *cb)
Sets a callback object, to be used with processMessage().
Definition: UdpSocket.cc:338
void setMulticastOutputInterface(int interfaceId)
Set the output interface for sending multicast packets (like the Unix IP_MULTICAST_IF socket option).
Definition: UdpSocket.cc:148
virtual void send(Packet *msg) override
Sends a data packet to the address and port specified previously in a connect() call.
Definition: UdpSocket.cc:80
void connect(L3Address remoteAddr, int remotePort)
Connects to a remote UDP socket.
Definition: UdpSocket.cc:53
virtual void setSocketOptions()
Definition: UdpSocketIo.cc:60
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
void joinLocalMulticastGroups(MulticastGroupList mgl)
Joins the socket to each multicast group that are registered with any of the interfaces.
Definition: UdpSocket.cc:265
virtual void processMessage(cMessage *msg) override
Examines the message, takes ownership, and updates socket state.
Definition: UdpSocket.cc:343
int numSent
Definition: UdpSocketIo.h:21
void joinMulticastGroup(const L3Address &multicastAddr, int interfaceId=-1)
Adds the socket to the given multicast group, that is, UDP packets arriving to the given multicast ad...
Definition: UdpSocket.cc:175
std::vector< MulticastGroup > MulticastGroupList
Definition: IInterfaceTable.h:26
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
virtual void close() override
Unbinds the socket.
Definition: UdpSocket.cc:87
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
virtual bool belongsToSocket(cMessage *msg) const override
Returns true if the message belongs to this socket instance (message has a UdpControlInfo as getContr...
Definition: UdpSocket.cc:373
void setBroadcast(bool broadcast)
Set the Broadcast option on the UDP socket.
Definition: UdpSocket.cc:139
virtual void delayActiveOperationFinish(simtime_t timeout)
Definition: OperationalMixinImpl.h:161
virtual void startActiveOperationExtraTimeOrFinish(simtime_t extraTime)
Definition: OperationalMixinImpl.h:179
UdpSocket socket
Definition: UdpSocketIo.h:20
void setTos(short tos)
Sets the Ipv4 Type of Service / Ipv6 Traffic Class fields of packets sent from the UDP socket.
Definition: UdpSocket.cc:130
virtual void refreshDisplay() const override
Definition: OperationalMixinImpl.h:200
bool dontFragment
Definition: UdpSocketIo.h:19