Skip to content

Error with GtpUserX2 #253

@eseglo

Description

@eseglo

In an emulation setup, sending UDP packets, with 2 GNBs, errors occur at the GtpUserMsgSerializer due to not setting the GtpUserMsg length here since it reads the default length of 1B and remainder become <0 here.

I have fixed it by setting gtpMsg->setChunkLenght(B(8)) before inserting and now it seems to work.

In addition, in this setting, errors also occur because there is no X2HandoverDataMsg serializer. I have added a X2HandoverDataMsgSerializer class as below and it fixes it.

using namespace inet;
Register_Serializer(X2HandoverDataMsg, X2HandoverDataMsgSerializer);

void X2HandoverDataMsgSerializer::serialize(inet::MemoryOutputStream &stream,
        const inet::Ptr<const inet::Chunk> &chunk) const {
       auto startPosition = stream.getLength();

        const auto& x2DataMsg = staticPtrCast<const X2HandoverDataMsg>(chunk);

        //We need to write to the stream exactly getChunkLength(), which is 11 for ltex2messages. If we write only 8,  then fill with remainders
        //We cannot write the length because we write 12 bytes and cannot change the ltex2message length

        stream.writeUint24Be(B(x2DataMsg->getChunkLength()).get());

        stream.writeUint32Be(x2DataMsg->getDestinationId());
        stream.writeUint32Be(x2DataMsg->getSourceId());

        int64_t remainders = B(x2DataMsg->getChunkLength() - (stream.getLength() - startPosition)).get();

        if (remainders < 0) {
            throw cRuntimeError("X2HandoverDataMsgSerializer length = %d smaller than required %d bytes", (int)B(x2DataMsg->getChunkLength()).get(), (int)B(stream.getLength() - startPosition).get());
        } else {
            stream.writeByteRepeatedly('?', remainders);
        }
}

const inet::Ptr<inet::Chunk> X2HandoverDataMsgSerializer::deserialize(
        inet::MemoryInputStream &stream) const {
      
       auto startPosition = stream.getPosition();
       auto x2DataMsg = makeShared<X2HandoverDataMsg>();
       B dataLength = B(stream.readUint24Be());

       x2DataMsg->setDestinationId(stream.readUint32Be());
       x2DataMsg->setSourceId(stream.readUint32Be());

       B remainders = dataLength - (stream.getPosition() - startPosition);
       ASSERT(remainders >= B(0));
       if (remainders.get()>=0) {
           stream.readByteRepeatedly('?', B(remainders).get());
       }
       return x2DataMsg;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions