Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/rhornig/tmp/svn/inet-framework/trunk@779 539eec35-cc16-0410-b457-356aab9780e1
  • Loading branch information
andras committed Aug 4, 2005
1 parent 6d7c75c commit 01b2428
Show file tree
Hide file tree
Showing 302 changed files with 3,793 additions and 3,362 deletions.
16 changes: 8 additions & 8 deletions Applications/Ethernet/EtherAppCli.cc
Expand Up @@ -20,8 +20,8 @@
#include <string.h>
#include <math.h>
#include <omnetpp.h>

#include "EtherCtrl_m.h"
#include "INETDefs.h"
#include "Ieee802Ctrl_m.h"
#include "EtherApp_m.h"
#include "utils.h"

Expand All @@ -30,7 +30,7 @@
/**
* Simple traffic generator for the Ethernet model.
*/
class EtherAppCli : public cSimpleModule
class INET_API EtherAppCli : public cSimpleModule
{
// send parameters
long seqNum;
Expand Down Expand Up @@ -91,7 +91,7 @@ void EtherAppCli::initialize(int stage)
destMACAddress = resolveDestMACAddress();

// if no dest address given, nothing to do
if (destMACAddress.isEmpty())
if (destMACAddress.isUnspecified())
return;

registerDSAP(localSAP);
Expand Down Expand Up @@ -145,9 +145,9 @@ void EtherAppCli::registerDSAP(int dsap)
{
EV << fullPath() << " registering DSAP " << dsap << "\n";

EtherCtrl *etherctrl = new EtherCtrl();
Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
etherctrl->setDsap(dsap);
cMessage *msg = new cMessage("register_DSAP", ETHCTRL_REGISTER_DSAP);
cMessage *msg = new cMessage("register_DSAP", IEEE802CTRL_REGISTER_DSAP);
msg->setControlInfo(etherctrl);

send(msg, "out");
Expand All @@ -161,7 +161,7 @@ void EtherAppCli::sendPacket()
sprintf(msgname, "req-%d-%ld", id(), seqNum);
EV << "Generating packet `" << msgname << "'\n";

EtherAppReq *datapacket = new EtherAppReq(msgname, ETHCTRL_DATA);
EtherAppReq *datapacket = new EtherAppReq(msgname, IEEE802CTRL_DATA);

datapacket->setRequestId(seqNum);

Expand All @@ -171,7 +171,7 @@ void EtherAppCli::sendPacket()
long respLen = respLength->longValue();
datapacket->setResponseBytes(respLen);

EtherCtrl *etherctrl = new EtherCtrl();
Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
etherctrl->setSsap(localSAP);
etherctrl->setDsap(remoteSAP);
etherctrl->setDest(destMACAddress);
Expand Down
14 changes: 7 additions & 7 deletions Applications/Ethernet/EtherAppSrv.cc
Expand Up @@ -20,7 +20,7 @@
#include <string.h>
#include <omnetpp.h>

#include "EtherCtrl_m.h"
#include "Ieee802Ctrl_m.h"
#include "EtherApp_m.h"
#include "utils.h"

Expand All @@ -31,7 +31,7 @@
/**
* Server-side process EtherAppCli.
*/
class EtherAppSrv : public cSimpleModule
class INET_API EtherAppSrv : public cSimpleModule
{
protected:
int localSAP;
Expand Down Expand Up @@ -80,7 +80,7 @@ void EtherAppSrv::handleMessage(cMessage *msg)
eedStats.collect(lastEED);

EtherAppReq *req = check_and_cast<EtherAppReq *>(msg);
EtherCtrl *ctrl = check_and_cast<EtherCtrl *>(req->removeControlInfo());
Ieee802Ctrl *ctrl = check_and_cast<Ieee802Ctrl *>(req->removeControlInfo());
MACAddress srcAddr = ctrl->getSrc();
long requestId = req->getRequestId();
long replyBytes = req->getResponseBytes();
Expand All @@ -103,7 +103,7 @@ void EtherAppSrv::handleMessage(cMessage *msg)

EV << "Generating packet `" << msgname << "'\n";

EtherAppResp *datapacket = new EtherAppResp(msgname, ETHCTRL_DATA);
EtherAppResp *datapacket = new EtherAppResp(msgname, IEEE802CTRL_DATA);
datapacket->setRequestId(requestId);
datapacket->setLength(8*l);
sendPacket(datapacket, srcAddr);
Expand All @@ -116,7 +116,7 @@ void EtherAppSrv::handleMessage(cMessage *msg)

void EtherAppSrv::sendPacket(cMessage *datapacket, const MACAddress& destAddr)
{
EtherCtrl *etherctrl = new EtherCtrl();
Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
etherctrl->setSsap(localSAP);
etherctrl->setDsap(remoteSAP);
etherctrl->setDest(destAddr);
Expand All @@ -128,9 +128,9 @@ void EtherAppSrv::registerDSAP(int dsap)
{
EV << fullPath() << " registering DSAP " << dsap << "\n";

EtherCtrl *etherctrl = new EtherCtrl();
Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
etherctrl->setDsap(dsap);
cMessage *msg = new cMessage("register_DSAP", ETHCTRL_REGISTER_DSAP);
cMessage *msg = new cMessage("register_DSAP", IEEE802CTRL_REGISTER_DSAP);
msg->setControlInfo(etherctrl);

send(msg, "out");
Expand Down
64 changes: 47 additions & 17 deletions Applications/Generic/IPTrafGen.cc
@@ -1,5 +1,6 @@
//
// Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
// Copyright (C) 2004-2005 Andras Varga
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
Expand All @@ -20,7 +21,7 @@
#include <omnetpp.h>
#include "IPTrafGen.h"
#include "IPControlInfo_m.h"
#include "StringTokenizer.h"
#include "IPv6ControlInfo_m.h"
#include "IPAddressResolver.h"


Expand Down Expand Up @@ -48,15 +49,27 @@ void IPTrafSink::handleMessage(cMessage *msg)

void IPTrafSink::printPacket(cMessage *msg)
{
IPControlInfo *controlInfo = check_and_cast<IPControlInfo *>(msg->controlInfo());

IPAddress src = controlInfo->srcAddr();
IPAddress dest = controlInfo->destAddr();
int protocol = controlInfo->protocol();
IPvXAddress src, dest;
int protocol = -1;
if (dynamic_cast<IPControlInfo *>(msg->controlInfo())!=NULL)
{
IPControlInfo *ctrl = (IPControlInfo *)msg->controlInfo();
src = ctrl->srcAddr();
dest = ctrl->destAddr();
protocol = ctrl->protocol();
}
else if (dynamic_cast<IPv6ControlInfo *>(msg->controlInfo())!=NULL)
{
IPv6ControlInfo *ctrl = (IPv6ControlInfo *)msg->controlInfo();
src = ctrl->srcAddr();
dest = ctrl->destAddr();
protocol = ctrl->protocol();
}

ev << msg << endl;
ev << "Payload length: " << (msg->length()/8) << " bytes" << endl;
ev << "src: " << src << " dest: " << dest << " protocol=" << protocol << "\n";
if (protocol!=-1)
ev << "src: " << src << " dest: " << dest << " protocol=" << protocol << "\n";
}

void IPTrafSink::processPacket(cMessage *msg)
Expand Down Expand Up @@ -92,7 +105,7 @@ void IPTrafGen::initialize(int stage)
simtime_t startTime = par("startTime");

const char *destAddrs = par("destAddresses");
StringTokenizer tokenizer(destAddrs);
cStringTokenizer tokenizer(destAddrs);
const char *token;
while ((token = tokenizer.nextToken())!=NULL)
destAddresses.push_back(IPAddressResolver().resolve(token));
Expand All @@ -109,7 +122,7 @@ void IPTrafGen::initialize(int stage)
scheduleAt(startTime, timer);
}

IPAddress IPTrafGen::chooseDestAddr()
IPvXAddress IPTrafGen::chooseDestAddr()
{
int k = intrand(destAddresses.size());
return destAddresses[k];
Expand All @@ -123,16 +136,33 @@ void IPTrafGen::sendPacket()
cMessage *payload = new cMessage(msgName);
payload->setLength(msgLength);

IPControlInfo *controlInfo = new IPControlInfo();
IPAddress destAddr = chooseDestAddr();
controlInfo->setDestAddr(destAddr);
controlInfo->setProtocol(protocol);
payload->setControlInfo(controlInfo);
IPvXAddress destAddr = chooseDestAddr();
if (!destAddr.isIPv6())
{
// send to IPv4
IPControlInfo *controlInfo = new IPControlInfo();
controlInfo->setDestAddr(destAddr.get4());
controlInfo->setProtocol(protocol);
payload->setControlInfo(controlInfo);

ev << "Sending packet: ";
printPacket(payload);

send(payload, "to_ip");
}
else
{
// send to IPv6
IPv6ControlInfo *controlInfo = new IPv6ControlInfo();
controlInfo->setDestAddr(destAddr.get6());
controlInfo->setProtocol(protocol);
payload->setControlInfo(controlInfo);

ev << "Sending packet: ";
printPacket(payload);
ev << "Sending packet: ";
printPacket(payload);

send(payload, "to_ip");
send(payload, "to_ipv6");
}
numSent++;
}

Expand Down
18 changes: 9 additions & 9 deletions Applications/Generic/IPTrafGen.h
Expand Up @@ -18,19 +18,19 @@
//


#ifndef __CBRAPP_H__
#define __CBRAPP_H__
#ifndef __IPTRAFGEN_H__
#define __IPTRAFGEN_H__

#include <vector>
#include <omnetpp.h>

#include "IPControlInfo_m.h"
#include "IPvXAddress.h"


/**
* Consumes and prints packets received from the UDP module. See NED for more info.
* Consumes and prints packets received from the IP module. See NED for more info.
*/
class IPTrafSink : public cSimpleModule
class INET_API IPTrafSink : public cSimpleModule
{
protected:
int numReceived;
Expand All @@ -46,23 +46,23 @@ class IPTrafSink : public cSimpleModule


/**
* UDP application. See NED for more info.
* IP traffic generator application. See NED for more info.
*/
class IPTrafGen : public IPTrafSink
class INET_API IPTrafGen : public IPTrafSink
{
protected:
std::string nodeName;
int protocol;
int msgLength;
int numPackets;
std::vector<IPAddress> destAddresses;
std::vector<IPvXAddress> destAddresses;

static int counter; // counter for generating a global number for each packet

int numSent;

// chooses random destination address
virtual IPAddress chooseDestAddr();
virtual IPvXAddress chooseDestAddr();
virtual void sendPacket();

public:
Expand Down
17 changes: 9 additions & 8 deletions Applications/Generic/IPTrafGen.ned
Expand Up @@ -20,22 +20,23 @@

//
// Consumes and prints packets received from the IP module.
// Compatible with both IPv4 and IPv6.
//
simple IPTrafSink
gates:
in: from_ip;
out: to_ip;
in: from_ip, from_ipv6;
out: to_ip, to_ipv6;
endsimple


//
// Sends IP datagrams to the given \IP address at the given interval.
// Sends IP or IPv6 datagrams to the given address at the given interval.
// The interval can be a constant or a random value (e.g. exponential(1)).
// If the destAddresses parameter contains more than one address, one
// of them is randomly for each packet. An address may be given in the
// dotted decimal notation, or with the module name. (The IPAddressResolver
// class is used to resolve the address.) To disable the model, set
// destAddresses to "".
// dotted decimal notation (or, for IPv6, in the usual notation with colons),
// or with the module name. (The IPAddressResolver class is used to resolve
// the address.) To disable the model, set destAddresses to "".
//
// The peer can be IPTrafSink or another IPTrafGen (it handles received packets
// exactly like IPTrafSink).
Expand All @@ -49,8 +50,8 @@ simple IPTrafGen
packetLength : numeric, // (bits)
destAddresses: string; // list of \IP addresses, separated by spaces
gates:
in: from_ip;
out: to_ip;
in: from_ip, from_ipv6;
out: to_ip, to_ipv6;
endsimple


Expand Down
5 changes: 3 additions & 2 deletions Applications/Generic/IPTrafficGenerator.ned
@@ -1,5 +1,6 @@
//
// Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
// Copyright (C) 2004-2005 Andras Varga
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
Expand All @@ -24,7 +25,7 @@
//
simple IPTrafficGenerator
gates:
in: from_ip;
out: to_ip;
in: from_ip, from_ipv6;
out: to_ip, to_ipv6;
endsimple

0 comments on commit 01b2428

Please sign in to comment.