|
INET Framework for OMNeT++/OMNEST
|
Implements the Udp protocol: encapsulates/decapsulates user data into/from Udp.
More...
#include <Udp.h>
|
| static void | insertCrc (const Protocol *networkProtocol, const L3Address &srcAddress, const L3Address &destAddress, const Ptr< UdpHeader > &udpHeader, Packet *udpPayload) |
| |
| static bool | verifyCrc (const Protocol *networkProtocol, const Ptr< const UdpHeader > &udpHeader, Packet *packet) |
| |
| static uint16_t | computeCrc (const Protocol *networkProtocol, const L3Address &srcAddress, const L3Address &destAddress, const Ptr< const UdpHeader > &udpHeader, const Ptr< const Chunk > &udpData) |
| |
| static bool | isCorrectPacket (Packet *packet, const Ptr< const UdpHeader > &udpHeader) |
| |
|
| virtual void | refreshDisplay () const override |
| |
| virtual SockDesc * | getSocketById (int sockId) |
| |
| virtual SockDesc * | getOrCreateSocket (int sockId) |
| |
| virtual SockDesc * | createSocket (int sockId, const L3Address &localAddr, int localPort) |
| |
| virtual void | bind (int sockId, const L3Address &localAddr, int localPort) |
| |
| virtual void | connect (int sockId, const L3Address &remoteAddr, int remotePort) |
| |
| virtual void | close (int sockId) |
| |
| virtual void | destroySocket (int sockId) |
| |
| void | destroySocket (SocketsByIdMap::iterator it) |
| |
| virtual void | clearAllSockets () |
| |
| virtual void | setTimeToLive (SockDesc *sd, int ttl) |
| |
| virtual void | setDscp (SockDesc *sd, short dscp) |
| |
| virtual void | setTos (SockDesc *sd, short tos) |
| |
| virtual void | setBroadcast (SockDesc *sd, bool broadcast) |
| |
| virtual void | setMulticastOutputInterface (SockDesc *sd, int interfaceId) |
| |
| virtual void | setMulticastLoop (SockDesc *sd, bool loop) |
| |
| virtual void | setReuseAddress (SockDesc *sd, bool reuseAddr) |
| |
| virtual void | joinMulticastGroups (SockDesc *sd, const std::vector< L3Address > &multicastAddresses, const std::vector< int > interfaceIds) |
| |
| virtual void | leaveMulticastGroups (SockDesc *sd, const std::vector< L3Address > &multicastAddresses) |
| |
| virtual void | blockMulticastSources (SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList) |
| |
| virtual void | unblockMulticastSources (SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList) |
| |
| virtual void | joinMulticastSources (SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList) |
| |
| virtual void | leaveMulticastSources (SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList) |
| |
| virtual void | setMulticastSourceFilter (SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, UdpSourceFilterMode filterMode, const std::vector< L3Address > &sourceList) |
| |
| virtual void | addMulticastAddressToInterface (NetworkInterface *ie, const L3Address &multicastAddr) |
| |
| virtual ushort | getEphemeralPort () |
| |
| virtual SockDesc * | findSocketForUnicastPacket (const L3Address &localAddr, ushort localPort, const L3Address &remoteAddr, ushort remotePort) |
| |
| virtual std::vector< SockDesc * > | findSocketsForMcastBcastPacket (const L3Address &localAddr, ushort localPort, const L3Address &remoteAddr, ushort remotePort, bool isMulticast, bool isBroadcast) |
| |
| virtual SockDesc * | findFirstSocketByLocalAddress (const L3Address &localAddr, ushort localPort) |
| |
| virtual void | sendUp (Ptr< const UdpHeader > &header, Packet *payload, SockDesc *sd, ushort srcPort, ushort destPort) |
| |
| virtual void | processUndeliverablePacket (Packet *udpPacket) |
| |
| virtual void | sendUpErrorIndication (SockDesc *sd, const L3Address &localAddr, ushort localPort, const L3Address &remoteAddr, ushort remotePort) |
| |
| virtual void | processICMPv4Error (Packet *icmpPacket) |
| |
| virtual void | processICMPv6Error (Packet *icmpPacket) |
| |
| virtual void | processUDPPacket (Packet *udpPacket) |
| |
| virtual void | handleUpperPacket (Packet *appData) override |
| |
| virtual void | handleLowerPacket (Packet *appData) override |
| |
| virtual void | handleUpperCommand (cMessage *msg) override |
| |
| virtual UdpHeader * | createUDPPacket () |
| |
| virtual void | handleStartOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleStopOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleCrashOperation (LifecycleOperation *operation) override |
| |
| virtual void | initialize (int stage) override |
| |
| virtual int | numInitStages () const override |
| |
| virtual bool | isUpperMessage (cMessage *message) const override |
| |
| virtual bool | isLowerMessage (cMessage *message) const override |
| |
| virtual bool | isInitializeStage (int stage) const override |
| |
| virtual bool | isModuleStartStage (int stage) const override |
| |
| virtual bool | isModuleStopStage (int stage) const override |
| |
| virtual void | handleMessageWhenUp (cMessage *message) override |
| |
| virtual void | handleSelfMessage (cMessage *message) |
| |
| virtual void | handleUpperMessage (cMessage *message) |
| |
| virtual void | handleLowerMessage (cMessage *message) |
| |
| virtual void | handleLowerCommand (cMessage *message) |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | refreshDisplay () const override |
| |
| virtual void | handleMessage (cMessage *msg) override |
| |
| virtual void | handleMessageWhenDown (cMessage *msg) |
| |
| virtual bool | handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override |
| | Perform one stage of a lifecycle operation. More...
|
| |
| virtual State | getInitialOperationalState () const |
| | Returns initial operational state: OPERATING or NOT_OPERATING. More...
|
| |
| virtual void | handleActiveOperationTimeout (cMessage *message) |
| |
| virtual bool | isUp () const |
| | utility functions More...
|
| |
| virtual bool | isDown () const |
| |
| virtual void | setOperationalState (State newState) |
| |
| virtual void | scheduleOperationTimeout (simtime_t timeout) |
| |
| virtual void | setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State) |
| |
| virtual void | delayActiveOperationFinish (simtime_t timeout) |
| |
| virtual void | startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO) |
| |
| virtual void | startActiveOperationExtraTimeOrFinish (simtime_t extraTime) |
| |
| virtual void | finishActiveOperation () |
| |
Implements the Udp protocol: encapsulates/decapsulates user data into/from Udp.
More info in the NED file.
◆ MulticastMembershipTable
◆ SockDescList
◆ SocketsByIdMap
◆ SocketsByPortMap
◆ PortRange
| Enumerator |
|---|
| EPHEMERAL_PORTRANGE_START | |
| EPHEMERAL_PORTRANGE_END | |
◆ Udp()
◆ ~Udp()
◆ addMulticastAddressToInterface()
489 ASSERT(ie && ie->isMulticast());
490 ASSERT(multicastAddr.isMulticast());
493 #ifdef INET_WITH_IPv4
494 ie->getProtocolDataForUpdate<Ipv4InterfaceData>()->joinMulticastGroup(multicastAddr.toIpv4());
495 #endif // ifdef INET_WITH_IPv4
498 #ifdef INET_WITH_IPv6
499 ie->getProtocolDataForUpdate<Ipv6InterfaceData>()->assignAddress(multicastAddr.toIpv6(),
false, SimTime::getMaxTime(), SimTime::getMaxTime());
500 #endif // ifdef INET_WITH_IPv6
503 ie->joinMulticastGroup(multicastAddr);
Referenced by joinMulticastGroups().
◆ bind()
| void inet::Udp::bind |
( |
int |
sockId, |
|
|
const L3Address & |
localAddr, |
|
|
int |
localPort |
|
) |
| |
|
protectedvirtual |
297 throw cRuntimeError(
"sockId in BIND message not filled in");
299 if (localPort < -1 || localPort > 65535)
300 throw cRuntimeError(
"bind: invalid local port number %d", localPort);
308 if (existing !=
nullptr && (!sd || !sd->reuseAddr || !existing->reuseAddr))
309 throw cRuntimeError(
"bind: local address/port %s:%u already taken", localAddr.str().c_str(), localPort);
313 throw cRuntimeError(
"bind: socket is already bound (sockId=%d)", sockId);
316 sd->localAddr = localAddr;
317 if (localPort != -1 && sd->localPort != localPort) {
319 sd->localPort = localPort;
Referenced by handleUpperCommand().
◆ blockMulticastSources()
542 ASSERT(ie && ie->isMulticast());
543 ASSERT(multicastAddress.isMulticast());
545 MulticastMembership *membership = sd->findMulticastMembership(multicastAddress, ie->getInterfaceId());
547 throw cRuntimeError(
"Udp::blockMulticastSources(): not a member of %s group on interface '%s'",
548 multicastAddress.str().c_str(), ie->getFullName());
551 throw cRuntimeError(
"Udp::blockMulticastSources(): socket was not joined to all sources of %s group on interface '%s'",
552 multicastAddress.str().c_str(), ie->getFullName());
554 std::vector<L3Address> oldSources(membership->sourceList);
555 std::vector<L3Address>& excludedSources = membership->sourceList;
556 bool changed =
false;
557 for (
auto& elem : sourceList) {
558 const L3Address& sourceAddress = elem;
559 if (!
contains(excludedSources, sourceAddress)) {
560 excludedSources.push_back(sourceAddress);
Referenced by handleUpperCommand().
◆ clearAllSockets()
| void inet::Udp::clearAllSockets |
( |
| ) |
|
|
protectedvirtual |
◆ close()
| void inet::Udp::close |
( |
int |
sockId | ) |
|
|
protectedvirtual |
876 EV_ERROR <<
"socket id=" << sockId <<
" doesn't exist (already closed?)\n";
880 EV_INFO <<
"Closing socket: " << *(it->second) <<
"\n";
Referenced by handleUpperCommand().
◆ computeCrc()
| uint16_t inet::Udp::computeCrc |
( |
const Protocol * |
networkProtocol, |
|
|
const L3Address & |
srcAddress, |
|
|
const L3Address & |
destAddress, |
|
|
const Ptr< const UdpHeader > & |
udpHeader, |
|
|
const Ptr< const Chunk > & |
udpData |
|
) |
| |
|
static |
843 auto pseudoHeader = makeShared<TransportPseudoHeader>();
844 pseudoHeader->setSrcAddress(srcAddress);
845 pseudoHeader->setDestAddress(destAddress);
846 pseudoHeader->setNetworkProtocolId(networkProtocol->getId());
848 pseudoHeader->setPacketLength(udpHeader->getChunkLength() + udpData->getChunkLength());
851 pseudoHeader->setChunkLength(
B(12));
853 pseudoHeader->setChunkLength(
B(40));
855 throw cRuntimeError(
"Unknown network protocol: %s", networkProtocol->getName());
857 MemoryOutputStream stream;
868 return crc == 0x0000 ? 0xFFFF : crc;
Referenced by insertCrc(), and verifyCrc().
◆ connect()
| void inet::Udp::connect |
( |
int |
sockId, |
|
|
const L3Address & |
remoteAddr, |
|
|
int |
remotePort |
|
) |
| |
|
protectedvirtual |
385 if (remoteAddr.isUnspecified())
386 throw cRuntimeError(
"connect: unspecified remote address");
387 if (remotePort <= 0 || remotePort > 65535)
388 throw cRuntimeError(
"connect: invalid remote port number %d", remotePort);
391 sd->remoteAddr = remoteAddr;
392 sd->remotePort = remotePort;
393 sd->onlyLocalPortIsSet =
false;
395 EV_INFO <<
"Socket connected: " << *sd <<
"\n";
Referenced by handleUpperCommand().
◆ createSocket()
346 SockDesc *sd =
new SockDesc(sockId);
347 sd->multicastLoop = par(
"defaultMulticastLoop");
349 sd->localAddr = localAddr;
351 sd->onlyLocalPortIsSet = sd->localAddr.isUnspecified();
360 EV_INFO <<
"Socket created: " << *sd <<
"\n";
Referenced by bind(), and getOrCreateSocket().
◆ createUDPPacket()
1503 return new UdpHeader();
◆ destroySocket() [1/2]
| void inet::Udp::destroySocket |
( |
int |
sockId | ) |
|
|
protectedvirtual |
909 EV_WARN <<
"socket id=" << sockId <<
" doesn't exist\n";
912 EV_INFO <<
"Destroy socket: " << *(it->second) <<
"\n";
Referenced by close(), and handleUpperCommand().
◆ destroySocket() [2/2]
| void inet::Udp::destroySocket |
( |
SocketsByIdMap::iterator |
it | ) |
|
|
protected |
887 SockDesc *sd = it->second;
892 for (
auto it = list.begin(); it != list.end(); ++it)
◆ findFirstSocketByLocalAddress()
336 for (
auto sd : list) {
337 if (sd->localAddr.isUnspecified() || sd->localAddr == localAddr)
Referenced by bind().
◆ findSocketForUnicastPacket()
1031 SockDesc *socketBoundToAnyAddress =
nullptr;
1032 for (SockDescList::reverse_iterator it = list.rbegin(); it != list.rend(); ++it) {
1034 if (sd->onlyLocalPortIsSet || (
1035 (sd->remotePort == -1 || sd->remotePort == remotePort) &&
1036 (sd->localAddr.isUnspecified() || sd->localAddr == localAddr) &&
1037 (sd->remoteAddr.isUnspecified() || sd->remoteAddr == remoteAddr)))
1039 if (sd->localAddr.isUnspecified())
1040 socketBoundToAnyAddress = sd;
1046 return socketBoundToAnyAddress;
Referenced by processICMPv4Error(), processICMPv6Error(), and processUDPPacket().
◆ findSocketsForMcastBcastPacket()
1051 ASSERT(isMulticast || isBroadcast);
1052 std::vector<SockDesc *> result;
1058 for (
auto sd : list) {
1060 if (sd->isBroadcast) {
1061 if ((sd->remotePort == -1 || sd->remotePort == remotePort) &&
1062 (sd->remoteAddr.isUnspecified() || sd->remoteAddr == remoteAddr))
1063 result.push_back(sd);
1066 else if (isMulticast) {
1067 auto membership = sd->findFirstMulticastMembership(localAddr);
1068 if (membership != sd->multicastMembershipTable.end()) {
1069 if ((sd->remotePort == -1 || sd->remotePort == remotePort) &&
1070 (sd->remoteAddr.isUnspecified() || sd->remoteAddr == remoteAddr) &&
1071 (*membership)->isSourceAllowed(remoteAddr))
1072 result.push_back(sd);
Referenced by processUDPPacket().
◆ getEphemeralPort()
| ushort inet::Udp::getEphemeralPort |
( |
| ) |
|
|
protectedvirtual |
◆ getOrCreateSocket()
◆ getSocketById()
1510 throw cRuntimeError(
"socket id=%d doesn't exist (already closed?)", sockId);
◆ handleCrashOperation()
◆ handleLowerPacket()
| void inet::Udp::handleLowerPacket |
( |
Packet * |
appData | ) |
|
|
overrideprotectedvirtual |
◆ handleStartOperation()
◆ handleStopOperation()
◆ handleUpperCommand()
| void inet::Udp::handleUpperCommand |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::LayeredProtocolBase.
143 switch (msg->getKind()) {
145 int socketId = check_and_cast<Request *>(msg)->getTag<SocketReq>()->getSocketId();
146 UdpBindCommand *
ctrl = check_and_cast<UdpBindCommand *>(msg->getControlInfo());
147 bind(socketId,
ctrl->getLocalAddr(),
ctrl->getLocalPort());
152 int socketId = check_and_cast<Request *>(msg)->getTag<SocketReq>()->getSocketId();
153 UdpConnectCommand *
ctrl = check_and_cast<UdpConnectCommand *>(msg->getControlInfo());
159 int socketId = check_and_cast<Request *>(msg)->getTag<SocketReq>()->getSocketId();
160 UdpSetOptionCommand *
ctrl = check_and_cast<UdpSetOptionCommand *>(msg->getControlInfo());
163 switch (
ctrl->getOptionCode()) {
165 auto cmd = check_and_cast<UdpSetTimeToLiveCommand *>(
ctrl);
170 auto cmd = check_and_cast<UdpSetDscpCommand *>(
ctrl);
175 auto cmd = check_and_cast<UdpSetTosCommand *>(
ctrl);
176 setTos(sd, cmd->getTos());
180 auto cmd = check_and_cast<UdpSetBroadcastCommand *>(
ctrl);
185 auto cmd = check_and_cast<UdpSetMulticastInterfaceCommand *>(
ctrl);
190 auto cmd = check_and_cast<UdpSetMulticastLoopCommand *>(
ctrl);
195 auto cmd = check_and_cast<UdpSetReuseAddressCommand *>(
ctrl);
200 auto cmd = check_and_cast<UdpJoinMulticastGroupsCommand *>(
ctrl);
201 std::vector<L3Address> addresses;
202 std::vector<int> interfaceIds;
203 for (
size_t i = 0; i < cmd->getMulticastAddrArraySize(); i++)
204 addresses.push_back(cmd->getMulticastAddr(i));
205 for (
size_t i = 0; i < cmd->getInterfaceIdArraySize(); i++)
206 interfaceIds.push_back(cmd->getInterfaceId(i));
211 auto cmd = check_and_cast<UdpLeaveMulticastGroupsCommand *>(
ctrl);
212 std::vector<L3Address> addresses;
213 for (
size_t i = 0; i < cmd->getMulticastAddrArraySize(); i++)
214 addresses.push_back(cmd->getMulticastAddr(i));
219 auto cmd = check_and_cast<UdpBlockMulticastSourcesCommand *>(
ctrl);
220 NetworkInterface *ie =
ift->getInterfaceById(cmd->getInterfaceId());
221 std::vector<L3Address> sourceList;
222 for (
size_t i = 0; i < cmd->getSourceListArraySize(); i++)
223 sourceList.push_back(cmd->getSourceList(i));
228 auto cmd = check_and_cast<UdpUnblockMulticastSourcesCommand *>(
ctrl);
229 NetworkInterface *ie =
ift->getInterfaceById(cmd->getInterfaceId());
230 std::vector<L3Address> sourceList;
231 for (
size_t i = 0; i < cmd->getSourceListArraySize(); i++)
232 sourceList.push_back(cmd->getSourceList(i));
237 auto cmd = check_and_cast<UdpLeaveMulticastSourcesCommand *>(
ctrl);
238 NetworkInterface *ie =
ift->getInterfaceById(cmd->getInterfaceId());
239 std::vector<L3Address> sourceList;
240 for (
size_t i = 0; i < cmd->getSourceListArraySize(); i++)
241 sourceList.push_back(cmd->getSourceList(i));
246 auto cmd = check_and_cast<UdpJoinMulticastSourcesCommand *>(
ctrl);
247 NetworkInterface *ie =
ift->getInterfaceById(cmd->getInterfaceId());
248 std::vector<L3Address> sourceList;
249 for (
size_t i = 0; i < cmd->getSourceListArraySize(); i++)
250 sourceList.push_back(cmd->getSourceList(i));
255 auto cmd = check_and_cast<UdpSetMulticastSourceFilterCommand *>(
ctrl);
256 NetworkInterface *ie =
ift->getInterfaceById(cmd->getInterfaceId());
257 std::vector<L3Address> sourceList;
258 for (
unsigned int i = 0; i < cmd->getSourceListArraySize(); i++)
259 sourceList.push_back(cmd->getSourceList(i));
263 throw cRuntimeError(
"Unknown subclass of UdpSetOptionCommand received from app: code=%d, name=%s",
ctrl->getOptionCode(),
ctrl->getClassName());
269 int socketId = check_and_cast<Request *>(msg)->getTag<SocketReq>()->getSocketId();
272 auto udpCtrl =
new UdpSocketClosedIndication();
273 indication->setControlInfo(udpCtrl);
274 indication->addTag<SocketInd>()->setSocketId(socketId);
275 send(indication,
"appOut");
281 int socketId = check_and_cast<Request *>(msg)->getTag<SocketReq>()->getSocketId();
287 throw cRuntimeError(
"Unknown command code (message kind) %d received from app", msg->getKind());
◆ handleUpperPacket()
| void inet::Udp::handleUpperPacket |
( |
Packet * |
appData | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::LayeredProtocolBase.
707 throw cRuntimeError(
"Unknown packet command code (message kind) %d received from app", packet->getKind());
710 L3Address srcAddr, destAddr;
711 int srcPort = -1, destPort = -1;
713 auto& socketReq = packet->removeTag<SocketReq>();
714 int socketId = socketReq->getSocketId();
718 auto addressReq = packet->addTagIfAbsent<L3AddressReq>();
719 srcAddr = addressReq->getSrcAddress();
720 destAddr = addressReq->getDestAddress();
722 if (srcAddr.isUnspecified())
723 addressReq->setSrcAddress(srcAddr = sd->localAddr);
725 if (destAddr.isUnspecified())
726 addressReq->setDestAddress(destAddr = sd->remoteAddr);
728 if (
auto& portsReq = packet->removeTagIfPresent<
L4PortReq>()) {
729 srcPort = portsReq->getSrcPort();
730 destPort = portsReq->getDestPort();
734 srcPort = sd->localPort;
737 destPort = sd->remotePort;
739 const auto& interfaceReq = packet->findTag<
InterfaceReq>();
740 ASSERT(interfaceReq ==
nullptr || interfaceReq->getInterfaceId() != -1);
742 if (interfaceReq ==
nullptr && destAddr.isMulticast()) {
743 auto membership = sd->findFirstMulticastMembership(destAddr);
744 int interfaceId = (membership != sd->multicastMembershipTable.end() && (*membership)->interfaceId != -1) ? (*membership)->interfaceId : sd->multicastOutputInterfaceId;
745 if (interfaceId != -1)
746 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(interfaceId);
749 if (addressReq->getDestAddress().isUnspecified())
750 throw cRuntimeError(
"send: unspecified destination address");
752 if (destPort <= 0 || destPort > 65535)
753 throw cRuntimeError(
"send: invalid remote port number %d", destPort);
758 if (sd->ttl != -1 && packet->findTag<
HopLimitReq>() ==
nullptr)
759 packet->addTag<
HopLimitReq>()->setHopLimit(sd->ttl);
761 if (sd->dscp != -1 && packet->findTag<
DscpReq>() ==
nullptr)
762 packet->addTag<
DscpReq>()->setDifferentiatedServicesCodePoint(sd->dscp);
764 if (sd->tos != -1 && packet->findTag<TosReq>() ==
nullptr) {
765 packet->addTag<TosReq>()->
setTos(sd->tos);
766 if (packet->findTag<
DscpReq>())
767 throw cRuntimeError(
"setting error: TOS and DSCP found together");
770 const Protocol *l3Protocol =
nullptr;
779 auto udpHeader = makeShared<UdpHeader>();
781 udpHeader->setSourcePort(srcPort);
782 udpHeader->setDestinationPort(destPort);
784 B totalLength = udpHeader->getChunkLength() + packet->getTotalLength();
788 udpHeader->setTotalLengthField(totalLength);
791 udpHeader->setCrc(0x0000);
794 udpHeader->setCrcMode(
crcMode);
795 insertCrc(l3Protocol, srcAddr, destAddr, udpHeader, packet);
802 EV_INFO <<
"Sending app packet " << packet->getName() <<
" over " << l3Protocol->getName() <<
".\n";
805 send(packet,
"ipOut");
◆ initialize()
| void inet::Udp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::OperationalMixin< cSimpleModule >.
66 const char *crcModeString = par(
"crcMode");
70 ift.reference(
this,
"interfaceTableModule",
true);
93 cModuleType *moduleType = cModuleType::get(
"inet.transportlayer.udp.UdpCrcInsertionHook");
94 auto crcInsertion = check_and_cast<UdpCrcInsertionHook *>(moduleType->create(
"crcInsertion",
this));
95 crcInsertion->finalizeParameters();
96 crcInsertion->callInitialize();
107 #ifdef INET_WITH_IPv4
108 auto ipv4 =
dynamic_cast<INetfilter *
>(findModuleByPath(
"^.ipv4.ip"));
110 ipv4->registerHook(0, crcInsertion);
112 #ifdef INET_WITH_IPv6
113 auto ipv6 =
dynamic_cast<INetfilter *
>(findModuleByPath(
"^.ipv6.ipv6"));
115 ipv6->registerHook(0, crcInsertion);
◆ insertCrc()
◆ isCorrectPacket()
| bool inet::Udp::isCorrectPacket |
( |
Packet * |
packet, |
|
|
const Ptr< const UdpHeader > & |
udpHeader |
|
) |
| |
|
static |
1354 auto trailerPopOffset = packet->getBackOffset();
1355 auto udpHeaderOffset = packet->getFrontOffset() - udpHeader->getChunkLength();
1358 else if (
B(udpHeader->getTotalLengthField()) > trailerPopOffset - udpHeaderOffset)
1361 const auto& l3AddressInd = packet->findTag<
L3AddressInd>();
1362 const auto& networkProtocolInd = packet->findTag<NetworkProtocolInd>();
1363 if (l3AddressInd !=
nullptr && networkProtocolInd !=
nullptr)
1364 return verifyCrc(networkProtocolInd->getProtocol(), udpHeader, packet);
Referenced by inet::UdpProtocolDissector::dissect().
◆ joinMulticastGroups()
| void inet::Udp::joinMulticastGroups |
( |
SockDesc * |
sd, |
|
|
const std::vector< L3Address > & |
multicastAddresses, |
|
|
const std::vector< int > |
interfaceIds |
|
) |
| |
|
protectedvirtual |
452 for (uint32_t
k = 0;
k < multicastAddresses.size();
k++) {
453 const L3Address& multicastAddr = multicastAddresses[
k];
454 int interfaceId =
k < interfaceIds.size() ? interfaceIds[
k] : -1;
455 ASSERT(multicastAddr.isMulticast());
457 MulticastMembership *membership = sd->findMulticastMembership(multicastAddr, interfaceId);
459 throw cRuntimeError(
"UPD::joinMulticastGroups(): %s group on interface %s is already joined.",
460 multicastAddr.str().c_str(),
ift->getInterfaceById(interfaceId)->getFullName());
462 membership =
new MulticastMembership();
463 membership->interfaceId = interfaceId;
464 membership->multicastAddress = multicastAddr;
467 sd->addMulticastMembership(membership);
470 if (interfaceId != -1) {
471 NetworkInterface *ie =
ift->getInterfaceById(interfaceId);
473 throw cRuntimeError(
"Interface id=%d does not exist", interfaceId);
474 ASSERT(ie->isMulticast());
478 for (
int i = 0; i <
ift->getNumInterfaces(); i++) {
479 NetworkInterface *ie =
ift->getInterface(i);
480 if (ie->isMulticast())
Referenced by handleUpperCommand().
◆ joinMulticastSources()
637 ASSERT(ie && ie->isMulticast());
638 ASSERT(multicastAddress.isMulticast());
640 MulticastMembership *membership = sd->findMulticastMembership(multicastAddress, ie->getInterfaceId());
642 membership =
new MulticastMembership();
643 membership->interfaceId = ie->getInterfaceId();
644 membership->multicastAddress = multicastAddress;
646 sd->addMulticastMembership(membership);
650 throw cRuntimeError(
"Udp::joinMulticastSources(): socket was joined to all sources of %s group on interface '%s'",
651 multicastAddress.str().c_str(), ie->getFullName());
653 std::vector<L3Address> oldSources(membership->sourceList);
654 std::vector<L3Address>& includedSources = membership->sourceList;
655 bool changed =
false;
656 for (
auto& elem : sourceList) {
657 const L3Address& sourceAddress = elem;
658 if (!
contains(includedSources, sourceAddress)) {
659 includedSources.push_back(sourceAddress);
Referenced by handleUpperCommand().
◆ leaveMulticastGroups()
| void inet::Udp::leaveMulticastGroups |
( |
SockDesc * |
sd, |
|
|
const std::vector< L3Address > & |
multicastAddresses |
|
) |
| |
|
protectedvirtual |
508 std::vector<L3Address>
empty;
510 for (
auto& multicastAddresse : multicastAddresses) {
511 auto it = sd->findFirstMulticastMembership(multicastAddresse);
512 while (it != sd->multicastMembershipTable.end()) {
513 MulticastMembership *membership = *it;
514 if (membership->multicastAddress != multicastAddresse)
516 it = sd->multicastMembershipTable.erase(it);
521 if (membership->interfaceId != -1) {
522 NetworkInterface *ie =
ift->getInterfaceById(membership->interfaceId);
523 ie->changeMulticastGroupMembership(membership->multicastAddress,
527 for (
int j = 0; j <
ift->getNumInterfaces(); ++j) {
528 NetworkInterface *ie =
ift->getInterface(j);
529 if (ie->isMulticast())
530 ie->changeMulticastGroupMembership(membership->multicastAddress,
Referenced by handleUpperCommand().
◆ leaveMulticastSources()
603 ASSERT(ie && ie->isMulticast());
604 ASSERT(multicastAddress.isMulticast());
606 MulticastMembership *membership = sd->findMulticastMembership(multicastAddress, ie->getInterfaceId());
608 throw cRuntimeError(
"Udp::leaveMulticastSources(): not a member of %s group in interface '%s'",
609 multicastAddress.str().c_str(), ie->getFullName());
612 throw cRuntimeError(
"Udp::leaveMulticastSources(): socket was joined to all sources of %s group on interface '%s'",
613 multicastAddress.str().c_str(), ie->getFullName());
615 std::vector<L3Address> oldSources(membership->sourceList);
616 std::vector<L3Address>& includedSources = membership->sourceList;
617 bool changed =
false;
618 for (
auto& elem : sourceList) {
619 const L3Address& sourceAddress = elem;
620 auto it =
find(includedSources, sourceAddress);
621 if (it != includedSources.end()) {
622 includedSources.erase(it);
631 if (includedSources.empty())
632 sd->deleteMulticastMembership(membership);
Referenced by handleUpperCommand().
◆ numInitStages()
| virtual int inet::Udp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ processICMPv4Error()
| void inet::Udp::processICMPv4Error |
( |
Packet * |
icmpPacket | ) |
|
|
protectedvirtual |
1153 #ifdef INET_WITH_IPv4
1158 icmp = getModuleFromPar<Icmp>(par(
"icmpModule"),
this);
1159 if (!icmp->verifyCrc(packet)) {
1160 EV_WARN <<
"incoming ICMP packet has wrong CRC, dropped\n";
1161 PacketDropDetails details;
1168 L3Address localAddr, remoteAddr;
1169 int localPort = -1, remotePort = -1;
1170 bool udpHeaderAvailable =
false;
1172 const auto& icmpHeader = packet->popAtFront<IcmpHeader>();
1174 type = icmpHeader->getType();
1175 code = icmpHeader->getCode();
1176 const auto& ipv4Header = packet->popAtFront<Ipv4Header>();
1177 if (ipv4Header->getDontFragment() || ipv4Header->getFragmentOffset() == 0) {
1179 localAddr = ipv4Header->getSrcAddress();
1180 remoteAddr = ipv4Header->getDestAddress();
1181 localPort = udpHeader->getSourcePort();
1182 remotePort = udpHeader->getDestinationPort();
1183 udpHeaderAvailable =
true;
1185 EV_WARN <<
"ICMP error received: type=" <<
type <<
" code=" << code
1186 <<
" about packet " << localAddr <<
":" << localPort <<
" > "
1187 << remoteAddr <<
":" << remotePort <<
"\n";
1190 if (udpHeaderAvailable) {
1194 EV_DETAIL <<
"Source socket is sockId=" << sd->sockId <<
", notifying.\n";
1198 EV_WARN <<
"No socket on that local port, ignoring ICMP error\n";
1202 EV_WARN <<
"Udp header not available, ignoring ICMP error\n";
1203 #endif // ifdef INET_WITH_IPv4
Referenced by handleLowerPacket().
◆ processICMPv6Error()
| void inet::Udp::processICMPv6Error |
( |
Packet * |
icmpPacket | ) |
|
|
protectedvirtual |
1210 #ifdef INET_WITH_IPv6
1213 icmpv6 = getModuleFromPar<Icmpv6>(par(
"icmpv6Module"),
this);
1214 if (!icmpv6->verifyCrc(packet)) {
1215 EV_WARN <<
"incoming ICMPv6 packet has wrong CRC, dropped\n";
1216 PacketDropDetails details;
1225 L3Address localAddr, remoteAddr;
1226 ushort localPort, remotePort;
1227 bool udpHeaderAvailable =
false;
1229 const auto& icmpHeader = packet->popAtFront<Icmpv6Header>();
1232 type = icmpHeader->getType();
1235 const auto& ipv6Header = packet->popAtFront<Ipv6Header>();
1236 const Ipv6FragmentHeader *fh =
dynamic_cast<const Ipv6FragmentHeader *
>(ipv6Header->findExtensionHeaderByType(
IP_PROT_IPv6EXT_FRAGMENT));
1237 if (!fh || fh->getFragmentOffset() == 0) {
1239 localAddr = ipv6Header->getSrcAddress();
1240 remoteAddr = ipv6Header->getDestAddress();
1241 localPort = udpHeader->getSourcePort();
1242 remotePort = udpHeader->getDestinationPort();
1243 udpHeaderAvailable =
true;
1247 if (udpHeaderAvailable) {
1248 EV_WARN <<
"ICMP error received: type=" <<
type <<
" code=" << code
1249 <<
" about packet " << localAddr <<
":" << localPort <<
" > "
1250 << remoteAddr <<
":" << remotePort <<
"\n";
1255 EV_DETAIL <<
"Source socket is sockId=" << sd->sockId <<
", notifying.\n";
1259 EV_WARN <<
"No socket on that local port, ignoring ICMPv6 error\n";
1263 EV_WARN <<
"Udp header not available, ignoring ICMPv6 error\n";
1265 #endif // ifdef INET_WITH_IPv6
Referenced by handleLowerPacket().
◆ processUDPPacket()
| void inet::Udp::processUDPPacket |
( |
Packet * |
udpPacket | ) |
|
|
protectedvirtual |
919 ASSERT(udpPacket->getControlInfo() ==
nullptr);
924 b udpHeaderPopPosition = udpPacket->getFrontOffset();
928 EV_INFO <<
"Packet " << udpPacket->getName() <<
" received from network, dest port " << udpHeader->getDestinationPort() <<
"\n";
930 auto srcPort = udpHeader->getSourcePort();
931 auto destPort = udpHeader->getDestinationPort();
933 auto srcAddr = l3AddressInd->getSrcAddress();
934 auto destAddr = l3AddressInd->getDestAddress();
935 auto totalLength =
B(udpHeader->getTotalLengthField());
936 auto hasIncorrectLength = totalLength<udpHeader->getChunkLength() || totalLength> udpHeader->getChunkLength() + udpPacket->getDataLength();
937 auto networkProtocol = udpPacket->getTag<NetworkProtocolInd>()->getProtocol();
939 if (hasIncorrectLength || !
verifyCrc(networkProtocol, udpHeader, udpPacket)) {
940 EV_WARN <<
"Packet has bit error, discarding\n";
941 PacketDropDetails details;
950 if (totalLength < udpPacket->getDataLength()) {
951 udpPacket->setBackOffset(udpHeaderPopPosition + totalLength);
954 bool isMulticast = destAddr.isMulticast();
955 bool isBroadcast = destAddr.isBroadcast();
956 if (!isMulticast && !isBroadcast) {
960 EV_WARN <<
"No socket registered on port " << destPort <<
"\n";
961 udpPacket->setFrontOffset(udpHeaderPopPosition);
966 sendUp(udpHeader, udpPacket, sd, srcPort, destPort);
973 EV_WARN <<
"No socket registered on port " << destPort <<
"\n";
974 udpPacket->setFrontOffset(udpHeaderPopPosition);
980 for (i = 0; i < sds.size() - 1; i++)
981 sendUp(udpHeader, udpPacket->dup(), sds[i], srcPort, destPort);
982 sendUp(udpHeader, udpPacket, sds[i], srcPort, destPort);
Referenced by handleLowerPacket().
◆ processUndeliverablePacket()
| void inet::Udp::processUndeliverablePacket |
( |
Packet * |
udpPacket | ) |
|
|
protectedvirtual |
1082 const auto& udpHeader = udpPacket->peekAtFront<UdpHeader>();
1083 PacketDropDetails details;
1090 snprintf(buff,
sizeof(buff),
"Port %d unreachable", udpHeader->getDestinationPort());
1091 udpPacket->setName(buff);
1092 const Protocol *
protocol = udpPacket->getTag<NetworkProtocolInd>()->getProtocol();
1095 throw cRuntimeError(
"(%s)%s arrived from lower layer without NetworkProtocolInd",
1096 udpPacket->getClassName(), udpPacket->getName());
1101 udpPacket->insertAtFront(udpPacket->getTag<NetworkProtocolInd>()->getNetworkProtocolHeader());
1102 auto inIe = udpPacket->getTag<InterfaceInd>()->getInterfaceId();
1105 #ifdef INET_WITH_IPv4
1108 icmp = getModuleFromPar<Icmp>(par(
"icmpModule"),
this);
1110 #endif // ifdef INET_WITH_IPv4
1114 #ifdef INET_WITH_IPv6
1117 icmpv6 = getModuleFromPar<Icmpv6>(par(
"icmpv6Module"),
this);
1119 #endif // ifdef INET_WITH_IPv6
1126 throw cRuntimeError(
"(%s)%s arrived from lower layer with unrecognized NetworkProtocolInd %s",
1127 udpPacket->getClassName(), udpPacket->getName(),
protocol->getName());
Referenced by processUDPPacket().
◆ refreshDisplay()
| void inet::Udp::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
1346 getDisplayString().setTagArg(
"i", 1,
"red");
1348 getDisplayString().setTagArg(
"t", 0, buf);
◆ sendUp()
1134 EV_INFO <<
"Sending payload up to socket sockId=" << sd->sockId <<
"\n";
1140 payload->addTagIfAbsent<SocketInd>()->setSocketId(sd->sockId);
1143 payload->addTagIfAbsent<
L4PortInd>()->setSrcPort(srcPort);
1144 payload->addTagIfAbsent<
L4PortInd>()->setDestPort(destPort);
1147 send(payload,
"appOut");
Referenced by processUDPPacket().
◆ sendUpErrorIndication()
1272 auto indication =
new Indication(
"ERROR",
UDP_I_ERROR);
1273 UdpErrorIndication *udpCtrl =
new UdpErrorIndication();
1274 indication->setControlInfo(udpCtrl);
1276 indication->addTag<SocketInd>()->setSocketId(sd->sockId);
1278 addresses->setSrcAddress(localAddr);
1279 addresses->setDestAddress(remoteAddr);
1280 auto ports = indication->addTag<
L4PortInd>();
1281 ports->setSrcPort(sd->localPort);
1282 ports->setDestPort(remotePort);
1284 send(indication,
"appOut");
Referenced by processICMPv4Error(), and processICMPv6Error().
◆ setBroadcast()
| void inet::Udp::setBroadcast |
( |
SockDesc * |
sd, |
|
|
bool |
broadcast |
|
) |
| |
|
protectedvirtual |
◆ setDscp()
| void inet::Udp::setDscp |
( |
SockDesc * |
sd, |
|
|
short |
dscp |
|
) |
| |
|
protectedvirtual |
◆ setMulticastLoop()
| void inet::Udp::setMulticastLoop |
( |
SockDesc * |
sd, |
|
|
bool |
loop |
|
) |
| |
|
protectedvirtual |
◆ setMulticastOutputInterface()
| void inet::Udp::setMulticastOutputInterface |
( |
SockDesc * |
sd, |
|
|
int |
interfaceId |
|
) |
| |
|
protectedvirtual |
◆ setMulticastSourceFilter()
671 ASSERT(ie && ie->isMulticast());
672 ASSERT(multicastAddress.isMulticast());
674 MulticastMembership *membership = sd->findMulticastMembership(multicastAddress, ie->getInterfaceId());
676 membership =
new MulticastMembership();
677 membership->interfaceId = ie->getInterfaceId();
678 membership->multicastAddress = multicastAddress;
680 sd->addMulticastMembership(membership);
683 bool changed = membership->filterMode != filterMode ||
684 membership->sourceList.size() != sourceList.size() ||
685 !equal(sourceList.begin(), sourceList.end(), membership->sourceList.begin());
687 std::vector<L3Address> oldSources(membership->sourceList);
693 membership->filterMode = filterMode;
694 membership->sourceList = sourceList;
696 ie->changeMulticastGroupMembership(multicastAddress, oldFilterMode, oldSources, newFilterMode, sourceList);
Referenced by handleUpperCommand().
◆ setReuseAddress()
| void inet::Udp::setReuseAddress |
( |
SockDesc * |
sd, |
|
|
bool |
reuseAddr |
|
) |
| |
|
protectedvirtual |
◆ setTimeToLive()
| void inet::Udp::setTimeToLive |
( |
SockDesc * |
sd, |
|
|
int |
ttl |
|
) |
| |
|
protectedvirtual |
◆ setTos()
| void inet::Udp::setTos |
( |
SockDesc * |
sd, |
|
|
short |
tos |
|
) |
| |
|
protectedvirtual |
◆ unblockMulticastSources()
572 ASSERT(ie && ie->isMulticast());
573 ASSERT(multicastAddress.isMulticast());
575 MulticastMembership *membership = sd->findMulticastMembership(multicastAddress, ie->getInterfaceId());
577 throw cRuntimeError(
"Udp::unblockMulticastSources(): not a member of %s group in interface '%s'",
578 multicastAddress.str().c_str(), ie->getFullName());
581 throw cRuntimeError(
"Udp::unblockMulticastSources(): socket was not joined to all sources of %s group on interface '%s'",
582 multicastAddress.str().c_str(), ie->getFullName());
584 std::vector<L3Address> oldSources(membership->sourceList);
585 std::vector<L3Address>& excludedSources = membership->sourceList;
586 bool changed =
false;
587 for (
auto& elem : sourceList) {
588 const L3Address& sourceAddress = elem;
589 auto it =
find(excludedSources, sourceAddress);
590 if (it != excludedSources.end()) {
591 excludedSources.erase(it);
Referenced by handleUpperCommand().
◆ verifyCrc()
| bool inet::Udp::verifyCrc |
( |
const Protocol * |
networkProtocol, |
|
|
const Ptr< const UdpHeader > & |
udpHeader, |
|
|
Packet * |
packet |
|
) |
| |
|
static |
989 switch (udpHeader->getCrcMode()) {
992 return udpHeader->getCrc() == 0x0000;
995 auto totalLength = udpHeader->getTotalLengthField();
997 return udpHeader->isCorrect() && udpDataBytes->isCorrect();
1003 if (udpHeader->getCrc() == 0x0000)
1009 auto srcAddress = l3AddressInd->getSrcAddress();
1010 auto destAddress = l3AddressInd->getDestAddress();
1011 auto totalLength = udpHeader->getTotalLengthField();
1013 auto computedCrc =
computeCrc(networkProtocol, srcAddress, destAddress, udpHeader, udpData);
1015 return computedCrc == 0xFFFF && udpHeader->isCorrect() && udpData->isCorrect();
1019 throw cRuntimeError(
"Unknown CRC mode");
Referenced by isCorrectPacket(), and processUDPPacket().
◆ operator<<
| std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const Udp::SockDesc & |
sd |
|
) |
| |
|
friend |
1441 os <<
"sockId=" << sd.sockId;
1442 os <<
" localPort=" << sd.localPort;
1443 if (sd.remotePort != -1)
1444 os <<
" remotePort=" << sd.remotePort;
1445 if (!sd.localAddr.isUnspecified())
1446 os <<
" localAddr=" << sd.localAddr;
1447 if (!sd.remoteAddr.isUnspecified())
1448 os <<
" remoteAddr=" << sd.remoteAddr;
1449 if (sd.multicastOutputInterfaceId != -1)
1450 os <<
" interfaceId=" << sd.multicastOutputInterfaceId;
1451 if (!sd.multicastLoop)
1452 os <<
" multicastLoop=" << sd.multicastLoop;
◆ crcMode
◆ ift
◆ lastEphemeralPort
◆ numDroppedBadChecksum
| int inet::Udp::numDroppedBadChecksum = 0 |
|
protected |
◆ numDroppedWrongPort
| int inet::Udp::numDroppedWrongPort = 0 |
|
protected |
◆ numPassedUp
| int inet::Udp::numPassedUp = 0 |
|
protected |
◆ numSent
| int inet::Udp::numSent = 0 |
|
protected |
◆ socketsByIdMap
◆ socketsByPortMap
The documentation for this class was generated from the following files:
virtual SockDesc * findSocketForUnicastPacket(const L3Address &localAddr, ushort localPort, const L3Address &remoteAddr, ushort remotePort)
Definition: Udp.cc:1023
virtual void processUDPPacket(Packet *udpPacket)
Definition: Udp.cc:917
virtual void destroySocket(int sockId)
Definition: Udp.cc:904
@ EPHEMERAL_PORTRANGE_END
Definition: Udp.h:61
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd TransportProtocolInd
Definition: IUdp-gates.txt:20
const uint16_t UDP_MAX_MESSAGE_SIZE
Definition: Udp.h:38
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
int numPassedUp
Definition: Udp.h:127
@ ICMP_DESTINATION_UNREACHABLE
Definition: IcmpHeader_m.h:77
const char empty[]
Definition: ConstType.h:29
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DscpReq
Definition: IUdp-gates.txt:25
@ UDP_C_CONNECT
Definition: UdpControlInfo_m.h:88
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
static const Protocol ipv4
Definition: Protocol.h:93
virtual void setTimeToLive(SockDesc *sd, int ttl)
Definition: Udp.cc:415
removed L4PortReq
Definition: IUdp-gates.txt:11
static const Protocol ipv6
Definition: Protocol.h:94
simsignal_t packetReceivedFromUpperSignal
Definition: Simsignals.cc:88
ushort lastEphemeralPort
Definition: Udp.h:116
@ PORT_UNREACHABLE
Definition: Icmpv6Header_m.h:126
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
static const Protocol icmpv4
Definition: Protocol.h:71
@ CRC_COMPUTED
Definition: CrcMode_m.h:59
int numSent
Definition: Udp.h:126
removed InterfaceReq
Definition: IUdp-gates.txt:11
static void serialize(MemoryOutputStream &stream, const Ptr< const Chunk > &chunk, b offset=b(0), b length=b(-1))
Serializes a chunk into the given stream.
Definition: Chunk.cc:175
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd L3AddressInd
Definition: IUdp-gates.txt:20
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
virtual void sendUp(Ptr< const UdpHeader > &header, Packet *payload, SockDesc *sd, ushort srcPort, ushort destPort)
Definition: Udp.cc:1132
virtual void setBroadcast(SockDesc *sd, bool broadcast)
Definition: Udp.cc:430
virtual void processICMPv6Error(Packet *icmpPacket)
Definition: Udp.cc:1208
static bool verifyCrc(const Protocol *networkProtocol, const Ptr< const UdpHeader > &udpHeader, Packet *packet)
Definition: Udp.cc:987
int numDroppedWrongPort
Definition: Udp.h:128
@ UDP_C_SETOPTION_SET_MCAST_SRC_FILTER
Definition: UdpControlInfo_m.h:133
CrcMode parseCrcMode(const char *crcModeString, bool allowDisable)
Definition: CrcMode.cc:14
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
@ CRC_DISABLED
Definition: CrcMode_m.h:56
virtual void blockMulticastSources(SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList)
Definition: Udp.cc:540
SocketsByIdMap socketsByIdMap
Definition: Udp.h:112
static const Protocol nextHopForwarding
Definition: Protocol.h:128
@ UDP_C_SETOPTION_LEAVE_MCAST_SRC
Definition: UdpControlInfo_m.h:132
@ IPv4
Definition: L3Address.h:35
void registerService(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a service primitive (SDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:14
virtual void leaveMulticastGroups(SockDesc *sd, const std::vector< L3Address > &multicastAddresses)
Definition: Udp.cc:506
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
@ UDP_C_SETOPTION_REUSEADDR
Definition: UdpControlInfo_m.h:126
virtual void clearAllSockets()
Definition: Udp.cc:1323
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
virtual void setDscp(SockDesc *sd, short dscp)
Definition: Udp.cc:420
@ IP_PROT_IPv6EXT_FRAGMENT
Definition: IpProtocolId_m.h:114
virtual SockDesc * createSocket(int sockId, const L3Address &localAddr, int localPort)
Definition: Udp.cc:343
removed ctrl
Definition: IUdp-gates.txt:7
virtual void setMulticastLoop(SockDesc *sd, bool loop)
Definition: Udp.cc:440
@ IP_PROT_UDP
Definition: IpProtocolId_m.h:97
McastSourceFilterMode
Definition: NetworkInterface.h:33
@ UDP_C_SETOPTION_BROADCAST
Definition: UdpControlInfo_m.h:123
removed MulticastReq
Definition: IUdp-gates.txt:11
virtual void leaveMulticastSources(SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList)
Definition: Udp.cc:601
virtual void setMulticastSourceFilter(SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, UdpSourceFilterMode filterMode, const std::vector< L3Address > &sourceList)
Definition: Udp.cc:669
intscale< b, 1, 8 > B
Definition: Units.h:1168
static void insertCrc(const Protocol *networkProtocol, const L3Address &srcAddress, const L3Address &destAddress, const Ptr< UdpHeader > &udpHeader, Packet *udpPayload)
Definition: Udp.cc:809
@ PF_ALLOW_INCOMPLETE
Definition: Chunk.h:280
@ UDP_C_SETOPTION_JOIN_MCAST_GRP
Definition: UdpControlInfo_m.h:127
@ UDP_I_SOCKET_CLOSED
Definition: UdpControlInfo_m.h:159
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
static const Protocol udp
Definition: Protocol.h:117
@ UDP_INCLUDE_MCAST_SOURCES
Definition: UdpControlInfo_m.h:1205
if(cwndVector) cwndVector -> record(state->snd_cwnd)
virtual void joinMulticastSources(SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList)
Definition: Udp.cc:635
virtual void setTos(SockDesc *sd, short tos)
Definition: Udp.cc:425
bool contains(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:65
@ PF_ALLOW_EMPTY
Definition: Chunk.h:279
void insertTransportProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< TransportHeaderBase > &header)
Definition: L4Tools.cc:77
virtual void addMulticastAddressToInterface(NetworkInterface *ie, const L3Address &multicastAddr)
Definition: Udp.cc:487
removed HopLimitReq
Definition: IUdp-gates.txt:11
INET_API InitStage INITSTAGE_TRANSPORT_LAYER
Initialization of transport-layer protocols.
@ UDP_C_DESTROY
Definition: UdpControlInfo_m.h:91
removed type
Definition: IUdp-gates.txt:7
ModuleRefByPar< IInterfaceTable > ift
Definition: Udp.h:117
virtual SockDesc * findFirstSocketByLocalAddress(const L3Address &localAddr, ushort localPort)
Definition: Udp.cc:329
@ EPHEMERAL_PORTRANGE_START
Definition: Udp.h:60
CrcMode crcMode
Definition: Udp.h:109
virtual void sendUpErrorIndication(SockDesc *sd, const L3Address &localAddr, ushort localPort, const L3Address &remoteAddr, ushort remotePort)
Definition: Udp.cc:1270
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
@ UDP_C_SETOPTION_JOIN_MCAST_SRC
Definition: UdpControlInfo_m.h:129
@ UDP_C_SETOPTION_UNBLOCK_MCAST_SRC
Definition: UdpControlInfo_m.h:131
virtual void processICMPv4Error(Packet *icmpPacket)
Definition: Udp.cc:1151
virtual void setReuseAddress(SockDesc *sd, bool reuseAddr)
Definition: Udp.cc:445
value< int64_t, units::b > b
Definition: Units.h:1241
CrcMode
Enum generated from inet/transportlayer/common/CrcMode.msg:12 by opp_msgtool.
Definition: CrcMode_m.h:54
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
const B UDP_HEADER_LENGTH
Definition: UdpHeader_m.h:51
simsignal_t packetReceivedFromLowerSignal
Definition: Simsignals.cc:91
@ PF_ALLOW_INCORRECT
Definition: Chunk.h:281
@ UDP_C_BIND
Definition: UdpControlInfo_m.h:87
static uint16_t checksum(const void *addr, unsigned int count)
Definition: TcpIpChecksum.h:33
const double k
Definition: Qam1024Modulation.cc:14
virtual void joinMulticastGroups(SockDesc *sd, const std::vector< L3Address > &multicastAddresses, const std::vector< int > interfaceIds)
Definition: Udp.cc:450
@ CRC_DECLARED_CORRECT
Definition: CrcMode_m.h:57
@ NO_PORT_FOUND
Definition: Simsignals_m.h:82
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd L4PortInd
Definition: IUdp-gates.txt:20
@ UDP_C_SETOPTION_TTL
Definition: UdpControlInfo_m.h:120
virtual void unblockMulticastSources(SockDesc *sd, NetworkInterface *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList)
Definition: Udp.cc:570
@ IPv6
Definition: L3Address.h:36
static const Protocol icmpv6
Definition: Protocol.h:72
@ UDP_I_DATA
Definition: UdpControlInfo_m.h:157
static uint16_t computeCrc(const Protocol *networkProtocol, const L3Address &srcAddress, const L3Address &destAddress, const Ptr< const UdpHeader > &udpHeader, const Ptr< const Chunk > &udpData)
Definition: Udp.cc:841
std::list< SockDesc * > SockDescList
Definition: Udp.h:104
@ CRC_DECLARED_INCORRECT
Definition: CrcMode_m.h:58
virtual void bind(int sockId, const L3Address &localAddr, int localPort)
Definition: Udp.cc:294
int numDroppedBadChecksum
Definition: Udp.h:129
@ UDP_C_DATA
Definition: UdpControlInfo_m.h:86
@ ICMP_DU_PORT_UNREACHABLE
Definition: IcmpHeader_m.h:189
unsigned short ushort
Definition: INETDefs.h:54
virtual void close(int sockId)
Definition: Udp.cc:871
int getId() const
Definition: Protocol.h:37
@ UDP_C_SETOPTION_MCAST_LOOP
Definition: UdpControlInfo_m.h:125
@ UDP_C_SETOPTION_TOS
Definition: UdpControlInfo_m.h:122
@ UDP_C_SETOPTION
Definition: UdpControlInfo_m.h:89
@ UDP_C_SETOPTION_MCAST_IFACE
Definition: UdpControlInfo_m.h:124
virtual void setMulticastOutputInterface(SockDesc *sd, int interfaceId)
Definition: Udp.cc:435
@ MCAST_EXCLUDE_SOURCES
Definition: NetworkInterface.h:33
virtual ushort getEphemeralPort()
Definition: Udp.cc:364
simsignal_t packetSentToUpperSignal
Definition: Simsignals.cc:87
virtual void connect(int sockId, const L3Address &remoteAddr, int remotePort)
Definition: Udp.cc:383
@ MCAST_INCLUDE_SOURCES
Definition: NetworkInterface.h:33
SocketsByPortMap socketsByPortMap
Definition: Udp.h:113
virtual void refreshDisplay() const override
Definition: OperationalMixinImpl.h:200
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
virtual void processUndeliverablePacket(Packet *udpPacket)
Definition: Udp.cc:1080
@ UDP_I_ERROR
Definition: UdpControlInfo_m.h:158
@ UDP_C_CLOSE
Definition: UdpControlInfo_m.h:90
@ ICMPv6_DESTINATION_UNREACHABLE
Definition: Icmpv6Header_m.h:85
@ UDP_C_SETOPTION_DSCP
Definition: UdpControlInfo_m.h:121
@ UDP_EXCLUDE_MCAST_SOURCES
Definition: UdpControlInfo_m.h:1206
virtual SockDesc * getOrCreateSocket(int sockId)
Definition: Udp.cc:398
@ UDP_C_SETOPTION_LEAVE_MCAST_GRP
Definition: UdpControlInfo_m.h:128
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80
@ UDP_C_SETOPTION_BLOCK_MCAST_SRC
Definition: UdpControlInfo_m.h:130
virtual std::vector< SockDesc * > findSocketsForMcastBcastPacket(const L3Address &localAddr, ushort localPort, const L3Address &remoteAddr, ushort remotePort, bool isMulticast, bool isBroadcast)
Definition: Udp.cc:1049
simsignal_t packetSentToLowerSignal
Definition: Simsignals.cc:90