OverSim
RealworldDevice Class Reference

RealworldDevice is a pseudo interface that allows communcation with the real world through the TunOutScheduler. More...

#include <RealworldDevice.h>

Inheritance diagram for RealworldDevice:
RealworldConnector TunOutDevice UdpOutDevice

Public Member Functions

virtual int numInitStages () const
virtual void initialize (int stage)
 Initialization of the module.
- Public Member Functions inherited from RealworldConnector
 RealworldConnector ()
virtual ~RealworldConnector ()
virtual void handleMessage (cMessage *msg)
 The "main loop".

Protected Member Functions

InterfaceEntry * registerInterface ()
 Register the interface in the interface table of the parent.
- Protected Member Functions inherited from RealworldConnector
virtual void transmitToNetwork (cPacket *msg)
 Send a message to the (realworld) network.
virtual void updateDisplayString ()
virtual char * encapsulate (cPacket *msg, unsigned int *length, sockaddr **addr, socklen_t *addrlen)=0
 Converts an IP datagram to a data block for sending it to the (realworld) network.
virtual cPacket * decapsulate (char *buf, uint32_t length, sockaddr *addr, socklen_t addrlen)=0
 Parses data received from the (realworld) network and converts it into a cMessage.
virtual bool isApp ()
 If the Connector connects to an application, this method has to be overwritten to return "true".

Protected Attributes

InterfaceEntry * interfaceEntry
- Protected Attributes inherited from RealworldConnector
int gateIndexNetwOut
unsigned int mtu
long numSent
long numSendError
long numRcvdOK
long numRcvError
cMessage * packetNotification
PacketBuffer packetBuffer
RealtimeSchedulerscheduler
PacketParserparser

Detailed Description

RealworldDevice is a pseudo interface that allows communcation with the real world through the TunOutScheduler.

WARNING: This does ONLY work with the combination IPv4|UDP|OverlayMessage

Definition at line 38 of file RealworldDevice.h.

Member Function Documentation

void RealworldDevice::initialize ( int  stage)
virtual

Initialization of the module.

Registers the device at the scheduler and searches for the appropriate payload-parser Will be called automatically at startup

Reimplemented from RealworldConnector.

Definition at line 27 of file RealworldDevice.cc.

{
// register our interface entry in IRoutingTable
if (stage == 0) {
}
}
virtual int RealworldDevice::numInitStages ( void  ) const
inlinevirtual

Reimplemented from RealworldConnector.

Definition at line 51 of file RealworldDevice.h.

{
return 4;
}
InterfaceEntry * RealworldDevice::registerInterface ( )
protected

Register the interface in the interface table of the parent.

Returns
A pointer to the Interface entry

Definition at line 39 of file RealworldDevice.cc.

Referenced by initialize().

{
InterfaceEntry *e = new InterfaceEntry();
// interface name: our module name without special characters ([])
char *interfaceName = new char[strlen(getFullName())+1];
char *d=interfaceName;
for (const char *s=getFullName(); *s; s++)
if (isalnum(*s))
*d++ = *s;
*d = '\0';
e->setName(interfaceName);
delete [] interfaceName;
// port: index of gate where our "netwIn" is connected (in IP)
int outputPort = /*getParentModule()->*/gate("netwIn")->getPreviousGate()->getIndex();
e->setNodeOutputGateId(outputPort);
// generate a link-layer address to be used as interface token for IPv6
InterfaceToken token(0, simulation.getUniqueNumber(), 64);
e->setInterfaceToken(token);
// MTU: typical values are 576 (Internet de facto), 1500 (Ethernet-friendly),
// 4000 (on some point-to-point links), 4470 (Cisco routers default, FDDI compatible)
e->setMtu(mtu);
// capabilities
e->setMulticast(true);
e->setPointToPoint(true);
// add
IInterfaceTable *ift = InterfaceTableAccess().get();
ift->addInterface(e, this);
return e;
}

Member Data Documentation

InterfaceEntry* RealworldDevice::interfaceEntry
protected

Definition at line 42 of file RealworldDevice.h.

Referenced by initialize().


The documentation for this class was generated from the following files: