|
INET Framework for OMNeT++/OMNEST
|
UDP application.
More...
#include <UdpBasicApp.h>
UDP application.
See NED for more info.
◆ SelfMsgKinds
| Enumerator |
|---|
| START | |
| SEND | |
| STOP | |
◆ UdpBasicApp()
| inet::UdpBasicApp::UdpBasicApp |
( |
| ) |
|
|
inline |
◆ ~UdpBasicApp()
| inet::UdpBasicApp::~UdpBasicApp |
( |
| ) |
|
◆ chooseDestAddr()
| L3Address inet::UdpBasicApp::chooseDestAddr |
( |
| ) |
|
|
protectedvirtual |
◆ finish()
| void inet::UdpBasicApp::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
54 recordScalar(
"packets sent",
numSent);
56 ApplicationBase::finish();
◆ handleCrashOperation()
◆ handleMessageWhenUp()
| void inet::UdpBasicApp::handleMessageWhenUp |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
◆ handleStartOperation()
◆ handleStopOperation()
◆ initialize()
| void inet::UdpBasicApp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
◆ numInitStages()
| virtual int inet::UdpBasicApp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ processPacket()
| void inet::UdpBasicApp::processPacket |
( |
Packet * |
msg | ) |
|
|
protectedvirtual |
◆ processSend()
| void inet::UdpBasicApp::processSend |
( |
| ) |
|
|
protectedvirtual |
◆ processStart()
| void inet::UdpBasicApp::processStart |
( |
| ) |
|
|
protectedvirtual |
124 const char *localAddress = par(
"localAddress");
125 socket.
bind(*localAddress ? L3AddressResolver().resolve(localAddress) : L3Address(),
localPort);
128 const char *destAddrs = par(
"destAddresses");
129 cStringTokenizer tokenizer(destAddrs);
132 while ((token = tokenizer.nextToken()) !=
nullptr) {
135 L3AddressResolver().tryResolve(token, result);
136 if (result.isUnspecified())
137 EV_ERROR <<
"cannot resolve destination address: " << token << endl;
Referenced by handleMessageWhenUp().
◆ processStop()
| void inet::UdpBasicApp::processStop |
( |
| ) |
|
|
protectedvirtual |
◆ refreshDisplay()
| void inet::UdpBasicApp::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
221 getDisplayString().setTagArg(
"t", 0, buf);
◆ sendPacket()
| void inet::UdpBasicApp::sendPacket |
( |
| ) |
|
|
protectedvirtual |
105 std::ostringstream str;
107 Packet *packet =
new Packet(str.str().c_str());
109 packet->addTag<FragmentationReq>()->setDontFragment(
true);
110 const auto& payload = makeShared<ApplicationPacket>();
111 payload->setChunkLength(
B(par(
"messageLength")));
112 payload->setSequenceNumber(
numSent);
113 payload->addTag<CreationTimeTag>()->setCreationTime(simTime());
114 packet->insertAtBack(payload);
Referenced by processSend().
◆ setSocketOptions()
| void inet::UdpBasicApp::setSocketOptions |
( |
| ) |
|
|
protectedvirtual |
61 int timeToLive = par(
"timeToLive");
65 int dscp = par(
"dscp");
73 const char *multicastInterface = par(
"multicastInterface");
74 if (multicastInterface[0]) {
75 IInterfaceTable *ift = getModuleFromPar<IInterfaceTable>(par(
"interfaceTableModule"),
this);
76 NetworkInterface *ie = ift->findInterfaceByName(multicastInterface);
78 throw cRuntimeError(
"Wrong multicastInterface setting: no interface named \"%s\"", multicastInterface);
82 bool receiveBroadcast = par(
"receiveBroadcast");
86 bool joinLocalMulticastGroups = par(
"joinLocalMulticastGroups");
87 if (joinLocalMulticastGroups) {
88 MulticastGroupList mgl = getModuleFromPar<IInterfaceTable>(par(
"interfaceTableModule"),
this)->collectMulticastGroups();
Referenced by processStart().
◆ socketClosed()
| void inet::UdpBasicApp::socketClosed |
( |
UdpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived()
| void inet::UdpBasicApp::socketDataArrived |
( |
UdpSocket * |
socket, |
|
|
Packet * |
packet |
|
) |
| |
|
overrideprotectedvirtual |
◆ socketErrorArrived()
Notifies about error indication arrival, indication ownership is transferred to the callee.
Implements inet::UdpSocket::ICallback.
205 EV_WARN <<
"Ignoring UDP error report " << indication->getName() << endl;
◆ destAddresses
| std::vector<L3Address> inet::UdpBasicApp::destAddresses |
|
protected |
◆ destAddressStr
| std::vector<std::string> inet::UdpBasicApp::destAddressStr |
|
protected |
◆ destPort
| int inet::UdpBasicApp::destPort = -1 |
|
protected |
◆ dontFragment
| bool inet::UdpBasicApp::dontFragment = false |
|
protected |
◆ localPort
| int inet::UdpBasicApp::localPort = -1 |
|
protected |
◆ numReceived
| int inet::UdpBasicApp::numReceived = 0 |
|
protected |
◆ numSent
| int inet::UdpBasicApp::numSent = 0 |
|
protected |
◆ packetName
| const char* inet::UdpBasicApp::packetName = nullptr |
|
protected |
◆ selfMsg
◆ socket
◆ startTime
◆ stopTime
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
std::vector< L3Address > destAddresses
Definition: UdpBasicApp.h:29
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
@ STOP
Definition: UdpBasicApp.h:26
State operationalState
Definition: OperationalMixin.h:23
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
int numReceived
Definition: UdpBasicApp.h:43
void bind(int localPort)
Bind the socket to a local port number.
Definition: UdpSocket.cc:34
void sendTo(Packet *msg, L3Address destAddr, int destPort)
Sends a data packet to the given address and port.
Definition: UdpSocket.cc:69
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 scheduleClockEventAfter(clocktime_t delay, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:65
virtual void destroy() override
Notify the protocol that the owner of ISocket has destroyed the socket.
Definition: UdpSocket.cc:98
virtual void scheduleClockEventAt(clocktime_t time, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:64
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
std::vector< std::string > destAddressStr
Definition: UdpBasicApp.h:30
UdpSocket socket
Definition: UdpBasicApp.h:38
void setCallback(ICallback *cb)
Sets a callback object, to be used with processMessage().
Definition: UdpSocket.cc:338
#define CLOCKTIME_ZERO
Constant for zero simulation time.
Definition: contract/ClockTime.h:36
virtual void setSocketOptions()
Definition: UdpBasicApp.cc:59
virtual clocktime_t getClockTime() const
Definition: ClockUserModuleMixin.h:72
@ SEND
Definition: UdpBasicApp.h:26
void setMulticastOutputInterface(int interfaceId)
Set the output interface for sending multicast packets (like the Unix IP_MULTICAST_IF socket option).
Definition: UdpSocket.cc:148
cMessage ClockEvent
Definition: contract/ClockEvent.h:18
ClockEvent * selfMsg
Definition: UdpBasicApp.h:39
intscale< b, 1, 8 > B
Definition: Units.h:1168
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
int destPort
Definition: UdpBasicApp.h:31
clocktime_t stopTime
Definition: UdpBasicApp.h:33
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
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
virtual void processSend()
Definition: UdpBasicApp.cc:153
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
int localPort
Definition: UdpBasicApp.h:31
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
const char * packetName
Definition: UdpBasicApp.h:35
const double k
Definition: Qam1024Modulation.cc:14
@ START
Definition: UdpBasicApp.h:26
void setBroadcast(bool broadcast)
Set the Broadcast option on the UDP socket.
Definition: UdpSocket.cc:139
virtual L3Address chooseDestAddr()
Definition: UdpBasicApp.cc:94
int numSent
Definition: UdpBasicApp.h:42
virtual void delayActiveOperationFinish(simtime_t timeout)
Definition: OperationalMixinImpl.h:161
virtual void processStop()
Definition: UdpBasicApp.cc:167
virtual void startActiveOperationExtraTimeOrFinish(simtime_t extraTime)
Definition: OperationalMixinImpl.h:179
bool dontFragment
Definition: UdpBasicApp.h:34
virtual void processStart()
Definition: UdpBasicApp.cc:121
clocktime_t startTime
Definition: UdpBasicApp.h:32
virtual void sendPacket()
Definition: UdpBasicApp.cc:103
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 cMessage * cancelClockEvent(ClockEvent *msg)
Definition: ClockUserModuleMixin.h:66
virtual void refreshDisplay() const override
Definition: OperationalMixinImpl.h:200
virtual void processPacket(Packet *msg)
Definition: UdpBasicApp.cc:224