Skip to content
This repository has been archived by the owner on Oct 20, 2018. It is now read-only.

Commit

Permalink
Implement transmit and receive unicast
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiroKyl committed May 10, 2017
1 parent e3ca065 commit 8eae760
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
29 changes: 24 additions & 5 deletions inet/src/inet/applications/lltrapp/LLTRApp.cc
Expand Up @@ -8,6 +8,10 @@ namespace inet {

class INET_API LLTRApp: public cSimpleModule
{
UDPSocket socket;

/*=================================================================================*/

int numInitStages() const
{
return NUM_INIT_STAGES;
Expand All @@ -17,19 +21,34 @@ class INET_API LLTRApp: public cSimpleModule
{
cSimpleModule::initialize(stage);

//TODO: write here
switch(stage){
case INITSTAGE_APPLICATION_LAYER:
socket.bind(1100);

break;
}
}

void handleMessage(cMessage *msg)
{
//TODO: write here

delete msg;
switch(msg->getKind()){
case UDP_I_DATA:{
EV << "Arrived: " << msg->getName() << endl;
delete msg;

}break;
case UDP_I_ERROR:{
EV_WARN << "Ignoring UDP error report" << endl;
delete msg;

}break;
default: throw cRuntimeError("Unrecognized message (%s)%s", msg->getClassName(), msg->getName());
}
}

void finish()
{
//TODO: write here
socket.close();

cSimpleModule::finish();
}
Expand Down
5 changes: 5 additions & 0 deletions inet/src/inet/applications/lltrapp/LLTRApp.ned
Expand Up @@ -3,4 +3,9 @@ package inet.applications.lltrapp;

simple LLTRApp
{
parameters:
@display("i=block/app");
gates:
input udpIn @labels(UDPControlInfo/up);
output udpOut @labels(UDPControlInfo/down);
}
18 changes: 16 additions & 2 deletions inet/src/inet/applications/lltrapp/LLTRSuperApp.cc
Expand Up @@ -8,6 +8,10 @@ namespace inet {

class INET_API LLTRSuperApp: public cSimpleModule
{
UDPSocket socket;

/*=================================================================================*/

int numInitStages() const
{
return NUM_INIT_STAGES;
Expand All @@ -17,7 +21,17 @@ class INET_API LLTRSuperApp: public cSimpleModule
{
cSimpleModule::initialize(stage);

//TODO: write here
switch(stage){
case INITSTAGE_APPLICATION_LAYER:
socket.setOutputGate(gate("udpOut"));
socket.setTimeToLive(1);

break;
case INITSTAGE_LAST:
socket.sendTo(new cPacket("=Packet name="), IPv4Address(10,0,1,4), 1100);

break;
}
}

void handleMessage(cMessage *msg)
Expand All @@ -29,7 +43,7 @@ class INET_API LLTRSuperApp: public cSimpleModule

void finish()
{
//TODO: write here
socket.close();

cSimpleModule::finish();
}
Expand Down
5 changes: 5 additions & 0 deletions inet/src/inet/applications/lltrapp/LLTRSuperApp.ned
Expand Up @@ -3,4 +3,9 @@ package inet.applications.lltrapp;

simple LLTRSuperApp
{
parameters:
@display("i=block/app");
gates:
input udpIn @labels(UDPControlInfo/up);
output udpOut @labels(UDPControlInfo/down);
}

0 comments on commit 8eae760

Please sign in to comment.