CoRE Simulation Models for Real-time Networks

Changeset b506070 in oppResultManagers


Ignore:
Timestamp:
04/14/16 14:24:05 (3 years ago)
Author:
Till Steinbach <till.steinbach@…>
Branches:
master
Children:
e45f6e1
Parents:
e301721
Message:

fileutils

Location:
src/oppresultmanagers
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/oppresultmanagers/SQLite/cSQLiteOutputManager.cc

    re301721 rb506070  
    7373    if (!connection)
    7474    {
    75         omnetpp::common::mkPath(
    76                 omnetpp::common::directoryOf(
    77                         omnetpp::getEnvir()->getConfig()->getAsFilename(CFGID_SQLITEOUTMGR_FILE).c_str()).c_str());
     75        mkPath(directoryOf(omnetpp::getEnvir()->getConfig()->getAsFilename(CFGID_SQLITEOUTMGR_FILE).c_str()).c_str());
    7876
    7977        std::string cfgobj = omnetpp::getEnvir()->getConfig()->getAsFilename(CFGID_SQLITEOUTMGR_FILE);
  • src/oppresultmanagers/check/cCheckOutputVectorManager.cc

    re301721 rb506070  
    3030
    3131#include "oppresultmanagers/utilities/HelperFunctions.h"
     32#include "oppresultmanagers/utilities/fileutil.h"
    3233
    3334#include <regex>
     
    369370    if (fileType == ".csv")
    370371    {
    371         //omnetpp::common::removeFile(reportFilename.c_str(), "old eventlog file");
    372         //omnetpp::common::mkPath(omnetpp::common::directoryOf(reportFilename.c_str()).c_str());
     372        removeFile(reportFilename.c_str(), "old eventlog file");
     373        mkPath(directoryOf(reportFilename.c_str()).c_str());
    373374
    374375        std::fstream file;
  • src/oppresultmanagers/eventlog/gcta/GCTAEventlogManager.cc

    re301721 rb506070  
    2020    filename = omnetpp::getEnvir()->getConfig()->getAsFilename(CFGID_EVENTLOG_TLOG_FILE).c_str();
    2121
    22     omnetpp::common::removeFile(filename.c_str(), "old eventlog file");
    23     omnetpp::common::mkPath(omnetpp::common::directoryOf(filename.c_str()).c_str());
     22    removeFile(filename.c_str(), "old pcapng file");
     23    mkPath(directoryOf(filename.c_str()).c_str());
     24
    2425    FILE *out = fopen(filename.c_str(), "w");
    2526    if (!out)
  • src/oppresultmanagers/eventlog/pcapng/PCAPNGEventlogManager.cc

    re301721 rb506070  
    3030
    3131#include "oppresultmanagers/eventlog/pcapng/pcapng.h"
     32#include "oppresultmanagers/utilities/fileutil.h"
    3233
    3334#include "inet/common/serializer/SerializerBase.h"
     
    5455            omnetpp::getEnvir()->getConfig()->getConfigEntry("record-eventlog").getValue(), "false");
    5556    filename = omnetpp::getEnvir()->getConfig()->getAsFilename(CFGID_EVENTLOG_PCAPNG_FILE).c_str();
     57
     58    removeFile(filename.c_str(), "old pcapng file");
     59    mkPath(directoryOf(filename.c_str()).c_str());
     60
    5661    pcapwriter->openFile(filename.c_str());
    5762
     
    114119        //TODO: allow kind of autodetection (e.g. find mac modules in nodes, have to find a clever way to do that)
    115120        omnetpp::cModule *module = omnetpp::getSimulation()->getModuleByPath(modulePath.c_str());
     121        if (!module)
     122        {
     123            throw omnetpp::cRuntimeError(
     124                    "PCAPEventlogManager: error in ini file (pcapng-interfaces option): Module \"%s\" cannot be found",
     125                    modulePath.c_str());
     126        }
     127        if (!module->isSimple())
     128        {
     129            throw omnetpp::cRuntimeError(
     130                    "PCAPEventlogManager: Sorry, module \"%s\" is no simple module. We can only capture packets at simple modules",
     131                    modulePath.c_str());
     132        }
    116133        omnetpp::cGate *gate = module->gate(gateName.c_str());
    117         if (!module)
     134        if (!gate)
    118135        {
    119136            throw omnetpp::cRuntimeError(
    120137                    "PCAPEventlogManager: error in ini file (pcapng-interfaces option): Gate \"%s\" of module \"%s\" cannot be found",
    121138                    gateName.c_str(), modulePath.c_str());
    122         }
    123         if (!module->isSimple())
    124         {
    125             throw omnetpp::cRuntimeError(
    126                     "PCAPEventlogManager: Sorry, module \"%s\" is no simple module. We can only capture packets at simple modules",
    127                     modulePath.c_str());
    128139        }
    129140        uint64_t speed = 0;
     
    218229                    inet::serializer::Context c;
    219230                    c.throwOnSerializerNotFound = false;
    220 //                    c.throwOnSerializedSizeMissmatch = false;
     231                    c.throwOnSerializedSizeMissmatch = false;
    221232                    inet::serializer::SerializerBase::lookupAndSerialize(pkt, wb, c, inet::serializer::LINKTYPE,
    222233                            inet::serializer::LINKTYPE_ETHERNET, static_cast<unsigned int>(capture_length));
     
    228239                        pcapwriter->addEnhancedPacket(static_cast<uint32_t>(senderGate->second->id), true,
    229240                                static_cast<uint64_t>(pkt->getSendingTime().raw()),
    230                                 static_cast<uint32_t>(ethPkt->getFrameByteLength()), wb.getPos(), serializeBuffer);
     241                                static_cast<uint32_t>(ethPkt->getFrameByteLength()), wb.getPos(), serializeBuffer, ethPkt->hasBitError());
    231242                    }
    232243                    //write out if receiver is in interfaces
     
    235246                        pcapwriter->addEnhancedPacket(static_cast<uint32_t>(arrivalGate->second->id), false,
    236247                                static_cast<uint64_t>(pkt->getArrivalTime().raw()),
    237                                 static_cast<uint32_t>(ethPkt->getFrameByteLength()), wb.getPos(), serializeBuffer);
     248                                static_cast<uint32_t>(ethPkt->getFrameByteLength()), wb.getPos(), serializeBuffer, ethPkt->hasBitError());
    238249                    }
    239250                }
  • src/oppresultmanagers/eventlog/pcapng/PCAPNGWriter.cc

    re301721 rb506070  
    218218
    219219void PCAPNGWriter::addEnhancedPacket(uint32_t interfaceId, bool sender, uint64_t timestamp, uint32_t len,
    220         uint32_t caplen, void* data)
     220        uint32_t caplen, void* data, bool bitError)
    221221{
    222222    addEnhancedPacketHeader(interfaceId, timestamp, caplen, len);
     
    229229    {
    230230        flags |= 0x00000001;
     231    }
     232    //Biterror
     233    if(bitError){
     234        flags |= 0x01000000;
    231235    }
    232236    std::memcpy((buffer + bufferPos), data, caplen);
  • src/oppresultmanagers/eventlog/pcapng/PCAPNGWriter.h

    re301721 rb506070  
    3636#define PCAPNGWRITER_H_
    3737
    38 enum BlockType{
    39     SectionHeader = BT_SHB,
    40     InterfaceDescriptionHeader = BT_IDB,
    41     EnhancedPacketHeader = BT_EPB,
     38enum BlockType
     39{
     40    SectionHeader = BT_SHB, InterfaceDescriptionHeader = BT_IDB, EnhancedPacketHeader = BT_EPB,
    4241};
    4342
     
    8685        void addEnhancedPacketHeader(uint32_t interfaceId, uint64_t timestamp, uint32_t caplen, uint32_t len);
    8786
     87        void openSection(std::string hardware, std::string os, std::string application);
     88        size_t addInterface(std::string name, std::string description, uint32_t snaplen, uint8_t tsresol,
     89                uint64_t speed);
     90        void addEnhancedPacket(uint32_t interfaceId, bool sender, uint64_t timestamp, uint32_t len, uint32_t caplen,
     91                void* data, bool bitError);
    8892
    89         void openSection(std::string hardware, std::string os, std::string application);
    90         size_t addInterface(std::string name, std::string description, uint32_t snaplen, uint8_t tsresol, uint64_t speed);
    91         void addEnhancedPacket(uint32_t interfaceId, bool sender, uint64_t timestamp, uint32_t len, uint32_t caplen, void* data);
    9293};
    9394
Note: See TracChangeset for help on using the changeset viewer.