#include <UDPAppBase.h>
Protected Member Functions | |
virtual void | bindToPort (int port) |
virtual void | sendToUDP (cPacket *msg, int srcPort, const IPvXAddress &destAddr, int destPort) |
virtual void | printPacket (cPacket *msg) |
void UDPAppBase::bindToPort | ( | int | port | ) | [protected, virtual] |
Tells UDP we want to get all packets arriving on the given port
Referenced by UDPVideoStreamSvr::initialize(), UDPSink::initialize(), UDPBasicApp::initialize(), and UDPVideoStreamCli::requestStream().
00025 { 00026 EV << "Binding to UDP port " << port << endl; 00027 00028 // TODO UDPAppBase should be ported to use UDPSocket sometime, but for now 00029 // we just manage the UDP socket by hand... 00030 cMessage *msg = new cMessage("UDP_C_BIND", UDP_C_BIND); 00031 UDPControlInfo *ctrl = new UDPControlInfo(); 00032 ctrl->setSrcPort(port); 00033 ctrl->setSockId(UDPSocket::generateSocketId()); 00034 msg->setControlInfo(ctrl); 00035 send(msg, "udpOut"); 00036 }
void UDPAppBase::sendToUDP | ( | cPacket * | msg, | |
int | srcPort, | |||
const IPvXAddress & | destAddr, | |||
int | destPort | |||
) | [protected, virtual] |
Sends a packet over UDP
Referenced by UDPVideoStreamCli::requestStream(), UDPBasicApp::sendPacket(), and UDPVideoStreamSvr::sendStreamData().
00039 { 00040 // send message to UDP, with the appropriate control info attached 00041 msg->setKind(UDP_C_DATA); 00042 00043 UDPControlInfo *ctrl = new UDPControlInfo(); 00044 ctrl->setSrcPort(srcPort); 00045 ctrl->setDestAddr(destAddr); 00046 ctrl->setDestPort(destPort); 00047 msg->setControlInfo(ctrl); 00048 00049 EV << "Sending packet: "; 00050 printPacket(msg); 00051 00052 send(msg, "udpOut"); 00053 }
void UDPAppBase::printPacket | ( | cPacket * | msg | ) | [protected, virtual] |
Prints a brief about packets having an attached UDPControlInfo (i.e. those which just arrived from UDP, or about to be send to UDP).
Referenced by UDPSink::processPacket(), UDPBasicApp::processPacket(), UDPVideoStreamCli::receiveStream(), and sendToUDP().
00056 { 00057 UDPControlInfo *ctrl = check_and_cast<UDPControlInfo *>(msg->getControlInfo()); 00058 00059 IPvXAddress srcAddr = ctrl->getSrcAddr(); 00060 IPvXAddress destAddr = ctrl->getDestAddr(); 00061 int srcPort = ctrl->getSrcPort(); 00062 int destPort = ctrl->getDestPort(); 00063 00064 ev << msg << " (" << msg->getByteLength() << " bytes)" << endl; 00065 ev << srcAddr << " :" << srcPort << " --> " << destAddr << ":" << destPort << endl; 00066 }