INET Framework for OMNeT++/OMNEST
PacketDrill.cc File Reference
#include "PacketDrill.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <cinttypes>
#include "PacketDrillUtils.h"
#include "inet/transportlayer/udp/UDPPacket_m.h"
#include "inet/transportlayer/tcp_common/TCPSegment_m.h"
#include "inet/networklayer/ipv4/IPv4Datagram_m.h"
#include "inet/transportlayer/contract/sctp/SCTPCommand_m.h"

Functions

TCPOptionsetOptionValues (PacketDrillTcpOption *opt)
 

Function Documentation

TCPOption* setOptionValues ( PacketDrillTcpOption opt)

Referenced by PacketDrill::buildTCPPacket().

107 {
108  unsigned char length = opt->getLength();
109  switch (opt->getKind()) {
110  case TCPOPT_EOL: // EOL
111  return new TCPOptionEnd();
112  case TCPOPT_NOP: // NOP
113  return new TCPOptionNop();
114  case TCPOPT_MAXSEG:
115  if (length == 4) {
116  auto *option = new TCPOptionMaxSegmentSize();
117  option->setLength(length);
118  option->setMaxSegmentSize(opt->getMss());
119  return option;
120  }
121  break;
122  case TCPOPT_WINDOW:
123  if (length == 3) {
124  auto *option = new TCPOptionWindowScale();
125  option->setLength(length);
126  option->setWindowScale(opt->getWindowScale());
127  return option;
128  }
129  break;
131  if (length == 2) {
132  auto *option = new TCPOptionSackPermitted();
133  option->setLength(length);
134  return option;
135  }
136  break;
137  case TCPOPT_SACK:
138  if (length > 2 && (length % 8) == 2) {
139  auto *option = new TCPOptionSack();
140  option->setLength(length);
141  option->setSackItemArraySize(length / 8);
142  unsigned int count = 0;
143  for (int i = 0; i < 2 * opt->getBlockList()->getLength(); i += 2) {
144  SackItem si;
145  si.setStart(((PacketDrillStruct *) opt->getBlockList()->get(i))->getValue1());
146  si.setEnd(((PacketDrillStruct *) opt->getBlockList()->get(i))->getValue2());
147  option->setSackItem(count++, si);
148  }
149  return option;
150  }
151  break;
152  case TCPOPT_TIMESTAMP:
153  if (length == 10) {
154  auto *option = new TCPOptionTimestamp();
155  option->setLength(length);
156  option->setSenderTimestamp(opt->getVal());
157  option->setEchoedTimestamp(opt->getEcr());
158  return option;
159  }
160  break;
161  default:
162  EV_INFO << "TCP option is not supported (yet).";
163  break;
164  } // switch
165  auto *option = new TCPOptionUnknown();
166  option->setKind(opt->getKind());
167  option->setLength(length);
168  if (length > 2)
169  option->setBytesArraySize(length - 2);
170  for (unsigned int i = 2; i < length; i++)
171  option->setBytes(i-2, length);
172  return option;
173 }
uint16 getMss()
Definition: PacketDrillUtils.h:703
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:182 by nedtool.
Definition: TCPSegment_m.h:552
#define TCPOPT_NOP
Definition: PacketDrillUtils.h:58
int count(const std::vector< T > &v, const T &a)
Definition: stlutils.h:58
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:161 by nedtool.
Definition: TCPSegment_m.h:428
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:154 by nedtool.
Definition: TCPSegment_m.h:389
Definition: PacketDrillUtils.h:627
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:167 by nedtool.
Definition: TCPSegment_m.h:465
#define TCPOPT_EOL
Definition: PacketDrillUtils.h:57
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:116 by nedtool.
Definition: TCPSegment_m.h:134
#define TCPOPT_SACK_PERMITTED
Definition: PacketDrillUtils.h:63
#define TCPOPT_MAXSEG
Definition: PacketDrillUtils.h:59
cQueue * getBlockList()
Definition: PacketDrillUtils.h:711
uint32 getVal()
Definition: PacketDrillUtils.h:707
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:147 by nedtool.
Definition: TCPSegment_m.h:349
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:135 by nedtool.
Definition: TCPSegment_m.h:276
uint32 getEcr()
Definition: PacketDrillUtils.h:709
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:141 by nedtool.
Definition: TCPSegment_m.h:312
uint16 getWindowScale()
Definition: PacketDrillUtils.h:705
#define TCPOPT_WINDOW
Definition: PacketDrillUtils.h:61
#define TCPOPT_SACK
Definition: PacketDrillUtils.h:65
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:174 by nedtool.
Definition: TCPSegment_m.h:510
virtual void setEnd(unsigned int end)
uint16 getKind()
Definition: PacketDrillUtils.h:700
uint16 getLength()
Definition: PacketDrillUtils.h:701
#define TCPOPT_TIMESTAMP
Definition: PacketDrillUtils.h:66
virtual void setStart(unsigned int start)