To implement the Content-Centric Network (CCN) in OMNeT++ has encompasses to building a recreation situation that contains enabling announcement founded on content names slightly than host addresses, consumers, producers and content routers. It is encompass possibly and we used by INET framework. The following procedure are to support to become ongoing by the basic CCN simulation in OMNeT++ by using the INET framework.
Step-by-Step Implementation:
Step 1: Install OMNeT++ and INET Framework
Step 3: Define CCN Models Using NED
package ccn;
import inet.node.inet.StandardHost;
import inet.node.inet.Router;
import inet.node.ethernet.EtherSwitch;
import inet.physicallayer.common.packetlevel.RadioMedium;
network CCNNetwork
{
parameters:
int numConsumers = default(4);
int numProducers = default(2);
int numRouters = default(3);
submodules:
radioMedium: RadioMedium {
@display(“p=100,100”);
}
consumer[numConsumers]: StandardHost {
@display(“p=200+100*i,200”);
}
producer[numProducers]: StandardHost {
@display(“p=300+100*i,300”);
}
router[numRouters]: Router {
@display(“p=400+100*i,400”);
}
switch: EtherSwitch {
@display(“p=300,500”);
}
connections allowunconnected:
for i=0..numConsumers-1 {
consumer[i].ethg++ <–> switch.ethg++;
}
for i=0..numProducers-1 {
producer[i].ethg++ <–> switch.ethg++;
}
for i=0..numRouters-1 {
router[i].ethg++ <–> switch.ethg++;
}
}
Step 4: Implement CCN Communication Logic
#include <omnetpp.h>
#include “inet/applications/base/ApplicationBase.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class ContentRouter : public ApplicationBase
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
void handleInterest(Packet *pkt);
void handleData(Packet *pkt);
};
Define_Module(ContentRouter);
void ContentRouter::initialize(int stage)
{
ApplicationBase::initialize(stage);
}
void ContentRouter::handleMessageWhenUp(cMessage *msg)
{
Packet *pkt = check_and_cast<Packet *>(msg);
if (strcmp(pkt->getName(), “Interest”) == 0) {
handleInterest(pkt);
} else if (strcmp(pkt->getName(), “Data”) == 0) {
handleData(pkt);
} else {
delete msg;
}
}
void ContentRouter::handleInterest(Packet *pkt)
{
// Handle Interest packet
EV << “Received Interest packet: ” << pkt->getName() << endl;
// Implement Interest forwarding logic
delete pkt;
}
void ContentRouter::handleData(Packet *pkt)
{
// Handle Data packet
EV << “Received Data packet: ” << pkt->getName() << endl;
// Implement Data forwarding logic
delete pkt;
}
#include <omnetpp.h>
#include “inet/applications/base/ApplicationBase.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class ContentConsumer : public ApplicationBase
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
void sendInterest();
void handleData(Packet *pkt);
cMessage *sendEvent = nullptr;
};
Define_Module(ContentConsumer);
void ContentConsumer::initialize(int stage)
{
ApplicationBase::initialize(stage);
if (stage == INITSTAGE_LOCAL) {
sendEvent = new cMessage(“sendInterest”);
scheduleAt(simTime() + par(“startTime”), sendEvent);
}
}
void ContentConsumer::handleMessageWhenUp(cMessage *msg)
{
if (msg == sendEvent) {
sendInterest();
scheduleAt(simTime() + par(“sendInterval”), sendEvent);
} else {
Packet *pkt = check_and_cast<Packet *>(msg);
handleData(pkt);
}
}
void ContentConsumer::sendInterest()
{
// Create and send an Interest packet
EV << “Sending Interest packet” << endl;
Packet *pkt = new Packet(“Interest”);
pkt->setByteLength(par(“messageSize”));
send(pkt, “lowerLayerOut”);
}
void ContentConsumer::handleData(Packet *pkt)
{
// Handle received Data packet
EV << “Received Data packet: ” << pkt->getName() << endl;
delete pkt;
}
#include <omnetpp.h>
#include “inet/applications/base/ApplicationBase.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class ContentProducer : public ApplicationBase
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
void handleInterest(Packet *pkt);
};
Define_Module(ContentProducer);
void ContentProducer::initialize(int stage)
{
ApplicationBase::initialize(stage);
}
void ContentProducer::handleMessageWhenUp(cMessage *msg)
{
Packet *pkt = check_and_cast<Packet *>(msg);
if (strcmp(pkt->getName(), “Interest”) == 0) {
handleInterest(pkt);
}else {
delete msg;
}
}
void ContentProducer::handleInterest(Packet *pkt)
{
// Handle Interest packet
EV << “Received Interest packet: ” << pkt->getName() << endl;
// Create and send a Data packet in response to the Interest
Packet *dataPkt = new Packet(“Data”);
dataPkt->setByteLength(par(“dataSize”));
send(dataPkt, “lowerLayerOut”);
delete pkt;
}
Step 5: Integrate CCN Modules into Network Model
package ccn;
import inet.node.inet.StandardHost;
import inet.node.inet.Router;
import inet.node.ethernet.EtherSwitch;
import inet.physicallayer.contract.packetlevel.IRadioMedium;
import inet.physicallayer.common.packetlevel.RadioMedium;
network CCNNetwork
{
parameters:
int numConsumers = default(4);
int numProducers = default(2);
int numRouters = default(3);
submodules:
radioMedium: RadioMedium {
@display(“p=100,100”);
}
consumer[numConsumers]: StandardHost {
@display(“p=200+100*i,200”);
@children:
wlan[0].radio.transmitter.typename = “ContentConsumer”;
wlan[0].radio.receiver.typename = “ContentConsumer”;
}
producer[numProducers]: StandardHost {
@display(“p=300+100*i,300”);
@children:
wlan[0].radio.transmitter.typename = “ContentProducer”;
wlan[0].radio.receiver.typename = “ContentProducer”;
}
router[numRouters]: Router {
@display(“p=400+100*i,400”);
@children:
wlan[0].radio.transmitter.typename = “ContentRouter”;
wlan[0].radio.receiver.typename = “ContentRouter”;
}
switch: EtherSwitch {
@display(“p=300,500”);
}
connections allowunconnected:
for i=0..numConsumers-1 {
consumer[i].ethg++ <–> switch.ethg++;
}
for i=0..numProducers-1 {
producer[i].ethg++ <–> switch.ethg++;
}
for i=0..numRouters-1 {
router[i].ethg++ <–> switch.ethg++;
}
}
Step 6: Configure Simulation Parameters
[General]
network = CCNNetwork
sim-time-limit = 100s
# Mobility
**.consumer[*].mobility.bounds = “0,0,1000,1000”
# Content consumer application parameters
**.consumer[*].udpApp.startTime = uniform(0s, 10s)
**.consumer[*].udpApp.sendInterval = exponential(1s)
**.consumer[*].udpApp.messageSize = 256B
**.consumer[*].udpApp.localPort = 1000
**.consumer[*].udpApp.destPort = 2000
# Content producer application parameters
**.producer[*].udpApp.startTime = uniform(0s, 10s)
**.producer[*].udpApp.sendInterval = exponential(1s)
**.producer[*].udpApp.messageSize = 256B
**.producer[*].udpApp.localPort = 3000
**.producer[*].udpApp.destPort = 4000
# Content router application parameters
**.router[*].udpApp.startTime = uniform(0s, 10s)
**.router[*].udpApp.sendInterval = exponential(1s)
**.router[*].udpApp.messageSize = 256B
**.router[*].udpApp.localPort = 5000
**.router[*].udpApp.destPort = 6000
Step 7: Build and Run the Simulation
Step 8: Analyze Results
From the following scripts are label in technique to execute the Content Centric Network in ns3. We learn how to succeed in the Content centric network and their development. We are motivated to put forward the expressive script and views describe the Content centric network in ns3. Reach out to us for exceptional simulation and project performance on content-centric networks in OMNeT++, crafted by leading developers for your projects. We utilize the INET framework to deliver the best ideas tailored to your needs.