I am looking for the initial implementation of the TCP / IP protocol in OMNeT++ software. The problem I encountered is that when the connection between computer1 and computer2 is established, and computer1 acts as a client and wants to send a packet named volt, OMNeT++ displays the message
"No more events — simulation ended at event # 52, t = 0.5.".
Thanks for guiding me to solving this problem. It is noteworthy that the code is attached at the end of this text. We also used OMNeT++ version 4.4.1 with INET 2.5.0.
computer1 (client) code:
#include <string.h>
#include <omnetpp.h>
#include "TCPSocket.h"
#include "IPvXAddressResolver.h"
#include "UDPControlInfo_m.h"
#include "Alireza_m.h"
using namespace std;
class COMP1: public cSimpleModule
{
public:
const char * connectAddress;
int connectPort;
TCPSocket tcpsocket;
protected:
int localPort, destPort;
std::vector<IPvXAddress> destAddresses;
virtual ~COMP1();
virtual int numInitStages() const
{
return 4;
}
virtual void initialize(int stage);
virtual void handleMessage(cMessage *msg);
};
Define_Module(COMP1);
void COMP1::initialize(int stage)
{
if (stage != 3)
{
return;
}
Alireza * pk=new Alireza("volt");
pk -> setVoltX(5);
tcpsocket.setOutputGate(gate("tcpOut"));
tcpsocket.readDataTransferModePar(*this);
tcpsocket.setDataTransferMode(TCP_TRANSFER_OBJECT);
tcpsocket.bind(IPvXAddressResolver().resolve("Computer1"), 1001);
IPvXAddress destination=IPvXAddressResolver().resolve("Computer2");
connectPort=1002;
tcpsocket.connect(destination, connectPort);
scheduleAt(simTime() +0.5, pk);
}
void COMP1::handleMessage(cMessage *msg)
{
ev << " I got a message Name=" << msg -> getName() << endl;
EV << " clienttttttttttt como111111111 received message \n " ;
IPvXAddress destAddr = IPvXAddressResolver().resolve(par("destAddresses"));
Alireza * pk=new Alireza("volt");
pk -> setVoltX(1);
tcpsocket.send(pk);
}
COMP1::~COMP1()
{
}
---------------------------------------------------------------------------------------------------------------------------------------------
computer2 (Server) code:
#include <string.h>
#include <omnetpp.h>
#include "TCPSocket.h"
#include "UDPSocket.h"
#include "IPvXAddressResolver.h"
#include "UDPControlInfo_m.h"
#include "Alireza_m.h"
using namespace std;
class COMP2: public cSimpleModule
{
public:
const char * connectAddress;
int connectPort;
TCPSocket tcpsocket;
protected:
int localPort, destPort;
std::vector<IPvXAddress> destAddresses;
virtual ~COMP2();
virtual int numInitStages() const
{
return 4;
}
virtual void initialize(int stage);
virtual void handleMessage(cMessage *msg);
};
Define_Module(COMP2);
void COMP2::initialize(int stage)
{
if (stage != 3)
{
return;
}
destPort = par("destPort");
localPort = par("localPort");
tcpsocket.setOutputGate(gate("tcpOut"));
tcpsocket.setDataTransferMode(TCP_TRANSFER_OBJECT);
tcpsocket.bind(IPvXAddressResolver().resolve("Computer2"), 1002);
tcpsocket.listen();
}
void COMP2::handleMessage(cMessage *msg)
{
ev << " I got a message Name=" << msg -> getName() << endl;
EV << " serverrrrrrrr comp22222222 received message \n" ;\
}
COMP2::~COMP2()
{
}
scheduleAt(simTime() +0.5, timer);
It must be the timer that is scheduled
Enviado desde Correo para Windows 10
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/f16034d1-36d9-482d-8b5f-0fa91d31c15an%40googlegroups.com.
thank you Dear Alfonso.
I implemented scheduleAt() for timer in handleMessage() but it gave the same error message as before,i.e " "Error in module (COMP1) NET2.Computer1.comp1 (id=12) at event #49, t=0.5: scheduleAt(): cannot schedule message (cMessage)Timer, it is currently in scheduled-events, being underway between two modules."
What solution do you suggest to enable scheduleAt() for packets such as timer and alireza, so that after communication stablishment, it can be sent to Computer2 via tcp gate?