cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
SimTcpSegment Class Reference

Class TCP Segment. More...

#include <SimTcpSegment.hpp>

Public Member Functions

 SimTcpSegment (int segLen)
 
 SimTcpSegment ()
 
void pushChunk (AxisTcp tcpChunk)
 
AxisTcp pullChunk ()
 
int length ()
 
int size ()
 
void clone (SimTcpSegment &tcpSeg)
 Clone a TCP segment. More...
 
void cloneHeader (SimTcpSegment &tcpSeg)
 Clone the header of a TCP segment. More...
 
void setTcpSourcePort (TcpPort port)
 
TcpPort getTcpSourcePort ()
 
LE_TcpPort getLE_TcpSourcePort ()
 
void setTcpDestinationPort (TcpPort port)
 
TcpPort getTcpDestinationPort ()
 
LE_TcpPort getLE_TcpDestinationPort ()
 
void setTcpSequenceNumber (TcpSeqNum num)
 
TcpSeqNum getTcpSequenceNumber ()
 
void setTcpAcknowledgeNumber (TcpAckNum num)
 
TcpAckNum getTcpAcknowledgeNumber ()
 
void setTcpDataOffset (int offset)
 
int getTcpDataOffset ()
 
void setTcpControlFin (TcpCtrlBit bit)
 
TcpCtrlBit getTcpControlFin ()
 
void setTcpControlSyn (TcpCtrlBit bit)
 
TcpCtrlBit getTcpControlSyn ()
 
void setTcpControlRst (TcpCtrlBit bit)
 
TcpCtrlBit getTcpControlRst ()
 
void setTcpControlPsh (TcpCtrlBit bit)
 
TcpCtrlBit getTcpControlPsh ()
 
void setTcpControlAck (TcpCtrlBit bit)
 
TcpCtrlBit getTcpControlAck ()
 
void setTcpControlUrg (TcpCtrlBit bit)
 
TcpCtrlBit getTcpControlUrg ()
 
void setTcpWindow (TcpWindow win)
 
TcpWindow getTcpWindow ()
 
void setTcpChecksum (TcpChecksum csum)
 
TcpCsum getTcpChecksum ()
 
void setTcpUrgentPointer (TcpUrgPtr ptr)
 
TcpUrgPtr getTcpUrgentPointer ()
 
void setTcpOptionKind (TcpOptKind val)
 
TcpOptKind getTcpOptionKind ()
 
void setTcpOptionMss (TcpOptMss val)
 
TcpOptMss getTcpOptionMss ()
 
void addTcpPayload (string pldStr)
 Append data payload to a TCP header. More...
 
TcpCsum calculateTcpChecksum (Ip4Addr ipSa, Ip4Addr ipDa, Ip4DatLen tcpSegLen)
 Calculate the TCP checksum of the segment. More...
 
TcpCsum reCalculateTcpChecksum (Ip4Addr ipSa, Ip4Addr ipDa, Ip4DatLen segLen)
 Recalculate the TCP checksum of this segment. More...
 
bool isWellFormed (const char *callerName, Ip4Addr ipSa, Ip4Addr ipDa)
 Checks if the segment header fields are properly set. More...
 
void dump ()
 Dump this TCP segment as HEX and ASCII characters to screen. More...
 
bool writeAxisTcpToFile (AxisTcp &axisTcp, ofstream &outFileStream)
 Dump an AxisTcp chunk to a file. More...
 
bool writeToDatFile (ofstream &outFileStream)
 Dump this TCP segment as raw AxisTcp chunks into a file. More...
 
bool writePayloadToDatFile (ofstream &outFileStream)
 Dump the payload of this segment as AxisTcp chunks into a file. More...
 

Detailed Description

Class TCP Segment.

This class defines a TCP segment as a stream of 'AxisTcp' data chunks. Such a TCP segment consists of a double-ended queue that is used to accumulate all these data chunks. For the 10GbE MAC, the TCP chunks are 64 bits wide.

Definition at line 54 of file SimTcpSegment.hpp.

Constructor & Destructor Documentation

◆ SimTcpSegment() [1/2]

SimTcpSegment::SimTcpSegment ( int  segLen)
inline

Definition at line 98 of file SimTcpSegment.hpp.

98  {
99  this->myName = "SimTcpSegment";
100  setLen(0);
101  if (segLen > 0 && segLen <= MTU) { // [FIXME - Why MTU and not 64KB]
102  int noBytes = segLen;
103  while(noBytes > 8) {
104  pushChunk(AxisTcp(0x0000000000000000, 0xFF, 0));
105  noBytes -= 8;
106  }
107  pushChunk(AxisTcp(0x0000000000000000, lenToLE_tKeep(noBytes), TLAST));
108  }
109  }
void pushChunk(AxisTcp tcpChunk)
LE_tKeep lenToLE_tKeep(ap_uint< 4 > noValidBytes)
A function to set a number of '1' in an 8-bit field. It is used here to set the number of valid bytes...
Definition: nts_utils.cpp:307
#define TLAST
Definition: AxisRaw.hpp:116
#define MTU
Definition: udp.hpp:71
Here is the call graph for this function:

◆ SimTcpSegment() [2/2]

SimTcpSegment::SimTcpSegment ( )
inline

Definition at line 110 of file SimTcpSegment.hpp.

110  {
111  this->myName = "SimTcpSegment";
112  this->len = 0;
113  }

Member Function Documentation

◆ addTcpPayload()

void SimTcpSegment::addTcpPayload ( string  pldStr)
inline

Append data payload to a TCP header.

Parameters
[in]pldStrThe payload to add as a string.

[FIXME - Works only for a default header of 20 bytes]

Definition at line 238 of file SimTcpSegment.hpp.

238  {
239  if (this->getLen() != TCP_HEADER_LEN) {
240  printFatal(this->myName, "Empty segment is expected to be of length %d bytes (was found to be %d bytes).\n",
241  TCP_HEADER_LEN, this->getLen());
242  }
243  int hdrLen = this->getLen(); // in bytes
244  int pldLen = pldStr.size();
245  int q = (hdrLen / 8);
246  int b = (hdrLen % 8);
247  int i = 0;
248  AxisTcp currChunk(0, 0, 0);
249  // At this point we are not aligned on an 8-byte data chunk because the
250  // default TCP headet length is 20 bytes. Alignement only occurs when
251  // the number of TCP option bytes is a multiple of 4 bytes.
252  if (b != 0) {
253  currChunk = this->back();
254  this->pop_back();
255  }
256  while (i < pldLen) {
257  while (b != 8) {
258  unsigned char datByte = pldStr[i];
259  currChunk.setLE_TData(datByte, (b*8+7), (b*8+0));
260  currChunk.setLE_TKeep(1, b, b);
261  i++;
262  b++;
263  if (i == pldLen) {
264  currChunk.setLE_TLast(TLAST);
265  break;
266  }
267  }
268  pushChunk(currChunk);
269  // Prepare a new chunk
270  currChunk.setLE_TData(0);
271  currChunk.setLE_TKeep(0);
272  currChunk.setLE_TLast(0);
273  b = 0;
274  }
275  } // End-of: addTcpPayload
#define TCP_HEADER_LEN
Definition: AxisTcp.hpp:81
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
Definition: nts_utils.hpp:208
Here is the call graph for this function:

◆ calculateTcpChecksum()

TcpCsum SimTcpSegment::calculateTcpChecksum ( Ip4Addr  ipSa,
Ip4Addr  ipDa,
Ip4DatLen  tcpSegLen 
)
inline

Calculate the TCP checksum of the segment.

  • This method computes the TCP checksum over the pseudo header, the TCP header and TCP data. According to RFC793, the pseudo header consists of the IP-{SA,DA,Prot} fields and the TCP length field. 0 7 8 15 16 23 24 31 +-----—+-----—+-----—+-----—+ | source address | +-----—+-----—+-----—+-----—+ | destination address | +-----—+-----—+-----—+-----—+ | zero |protocol| TCP length | +-----—+-----—+-----—+-----—+

@Warning The TCP Length is the TCP header length plus the data length in octets (this is not an explicitly transmitted quantity, but is computed), and it does not count the 12 octets of the pseudo header.

@Warning The checksum is computed on the double-ended queue which holds the TCP chunks in little-endian order (see AxisTcp) !

Returns
the computed checksum.

Definition at line 300 of file SimTcpSegment.hpp.

300  {
301  ap_uint<32> csum = 0;
302  csum += byteSwap16(ipSa(31, 16)); // Set IP_SA in LE
303  csum += byteSwap16(ipSa(15, 0));
304  csum += byteSwap16(ipDa(31, 16)); // Set IP_DA in LE
305  csum += byteSwap16(ipDa(15, 0));
306  csum += byteSwap16(ap_uint<16>(IP4_PROT_TCP));
307  csum += byteSwap16(tcpSegLen);
308  for (int i=0; i<this->size(); ++i) {
309  LE_tData tempInput = 0;
310  if (segQ[i].getLE_TKeep() & 0x01)
311  tempInput.range( 7, 0) = (segQ[i].getLE_TData()).range( 7, 0);
312  if (segQ[i].getLE_TKeep() & 0x02)
313  tempInput.range(15, 8) = (segQ[i].getLE_TData()).range(15, 8);
314  if (segQ[i].getLE_TKeep() & 0x04)
315  tempInput.range(23,16) = (segQ[i].getLE_TData()).range(23,16);
316  if (segQ[i].getLE_TKeep() & 0x08)
317  tempInput.range(31,24) = (segQ[i].getLE_TData()).range(31,24);
318  if (segQ[i].getLE_TKeep() & 0x10)
319  tempInput.range(39,32) = (segQ[i].getLE_TData()).range(39,32);
320  if (segQ[i].getLE_TKeep() & 0x20)
321  tempInput.range(47,40) = (segQ[i].getLE_TData()).range(47,40);
322  if (segQ[i].getLE_TKeep() & 0x40)
323  tempInput.range(55,48) = (segQ[i].getLE_TData()).range(55,48);
324  if (segQ[i].getLE_TKeep() & 0x80)
325  tempInput.range(63,56) = (segQ[i].getLE_TData()).range(63,56);
326  csum = ((((csum +
327  tempInput.range(63, 48)) + tempInput.range(47, 32)) +
328  tempInput.range(31, 16)) + tempInput.range(15, 0));
329  }
330  while (csum >> 16) {
331  csum = (csum & 0xFFFF) + (csum >> 16);
332  }
333  // Reverse the bits of the result
334  TcpCsum tcpCsum = csum.range(15, 0);
335  tcpCsum = ~tcpCsum;
336  return byteSwap16(tcpCsum);
337  }
TcpSegLen tcpSegLen
Definition: tb_nal.cpp:833
ap_uint< 64 > LE_tData
Definition: AxisRaw.hpp:122
ap_uint< 16 > TcpCsum
Definition: AxisTcp.hpp:114
#define IP4_PROT_TCP
Definition: nts_types.hpp:184
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)
Definition: udp.cpp:82
Here is the call graph for this function:

◆ clone()

void SimTcpSegment::clone ( SimTcpSegment tcpSeg)
inline

Clone a TCP segment.

Parameters
[in]tcpSegA reference to the segment to clone.

Definition at line 147 of file SimTcpSegment.hpp.

147  {
148  AxisTcp newAxisTcp;
149  for (int i=0; i<tcpSeg.segQ.size(); i++) {
150  newAxisTcp = tcpSeg.segQ[i];
151  this->segQ.push_back(newAxisTcp);
152  }
153  this->setLen(tcpSeg.getLen());
154  }

◆ cloneHeader()

void SimTcpSegment::cloneHeader ( SimTcpSegment tcpSeg)
inline

Clone the header of a TCP segment.

Parameters
[in]tcpSegA reference to the segment to clone.

[FIXME - Works only for a default header of 20 bytes]

Definition at line 162 of file SimTcpSegment.hpp.

162  {
163  int cloneBytes = TCP_HEADER_LEN; // in bytes
164  int inpChunkCnt = 0;
165  while(cloneBytes > 0) {
166  if (cloneBytes > 8) {
167  this->pushChunk(tcpSeg.segQ[inpChunkCnt]);
168  }
169  else {
170  AxisTcp lastHdrChunk(tcpSeg.segQ[inpChunkCnt].getLE_TData(),
171  lenToLE_tKeep(cloneBytes), TLAST);
172  this->pushChunk(lastHdrChunk);
173  }
174  cloneBytes -= 8;
175  inpChunkCnt++;
176  }
177  }
Here is the call graph for this function:

◆ dump()

void SimTcpSegment::dump ( )
inline

Dump this TCP segment as HEX and ASCII characters to screen.

Definition at line 383 of file SimTcpSegment.hpp.

383  {
384  string segStr;
385  for (int q=0; q < this->size(); q++) {
386  AxisTcp axisData = this->segQ[q];
387  for (int b=7; b >= 0; b--) {
388  if (axisData.getTKeep().bit(b)) {
389  int hi = ((b*8) + 7);
390  int lo = ((b*8) + 0);
391  ap_uint<8> octet = axisData.getTData().range(hi, lo);
392  segStr += myUint8ToStrHex(octet);
393  }
394  }
395  }
396  bool endOfSeg = false;
397  int i = 0;
398  int offset = 0;
399  char *ptr;
400  do {
401  string hexaStr;
402  string asciiStr;
403  for (int c=0; c < 16*2; c+=2) {
404  if (i < segStr.length()) {
405  hexaStr += segStr.substr(i, 2);
406  char ch = std::strtoul(segStr.substr(i, 2).c_str(), &ptr, 16);
407  if ((int)ch > 0x1F)
408  asciiStr += ch;
409  else
410  asciiStr += '.';
411 
412  }
413  else {
414  hexaStr += " ";
415  endOfSeg = true;
416  }
417  hexaStr += " ";
418  i += 2;
419  }
420  printf("%4.4X %s %s \n", offset, hexaStr.c_str(), asciiStr.c_str());
421  offset += 16;
422  } while (not endOfSeg);
423  }
tData getTData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:191
tKeep getTKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:207
string myUint8ToStrHex(ap_uint< 8 > inputNumber)
Converts an UINT8 into a string of 2 HEX characters.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLE_TcpDestinationPort()

LE_TcpPort SimTcpSegment::getLE_TcpDestinationPort ( )
inline

Definition at line 188 of file SimTcpSegment.hpp.

188 { return segQ[0].getLE_TcpDstPort(); }

◆ getLE_TcpSourcePort()

LE_TcpPort SimTcpSegment::getLE_TcpSourcePort ( )
inline

Definition at line 183 of file SimTcpSegment.hpp.

183 { return segQ[0].getLE_TcpSrcPort(); }

◆ getTcpAcknowledgeNumber()

TcpAckNum SimTcpSegment::getTcpAcknowledgeNumber ( )
inline

Definition at line 196 of file SimTcpSegment.hpp.

196 { return segQ[1].getTcpAckNum(); }

◆ getTcpChecksum()

TcpCsum SimTcpSegment::getTcpChecksum ( )
inline

Definition at line 221 of file SimTcpSegment.hpp.

221 { return segQ[2].getTcpChecksum(); }

◆ getTcpControlAck()

TcpCtrlBit SimTcpSegment::getTcpControlAck ( )
inline

Definition at line 211 of file SimTcpSegment.hpp.

211 { return segQ[1].getTcpCtrlAck(); }

◆ getTcpControlFin()

TcpCtrlBit SimTcpSegment::getTcpControlFin ( )
inline

Definition at line 203 of file SimTcpSegment.hpp.

203 { return segQ[1].getTcpCtrlFin(); }

◆ getTcpControlPsh()

TcpCtrlBit SimTcpSegment::getTcpControlPsh ( )
inline

Definition at line 209 of file SimTcpSegment.hpp.

209 { return segQ[1].getTcpCtrlPsh(); }

◆ getTcpControlRst()

TcpCtrlBit SimTcpSegment::getTcpControlRst ( )
inline

Definition at line 207 of file SimTcpSegment.hpp.

207 { return segQ[1].getTcpCtrlRst(); }

◆ getTcpControlSyn()

TcpCtrlBit SimTcpSegment::getTcpControlSyn ( )
inline

Definition at line 205 of file SimTcpSegment.hpp.

205 { return segQ[1].getTcpCtrlSyn(); }

◆ getTcpControlUrg()

TcpCtrlBit SimTcpSegment::getTcpControlUrg ( )
inline

Definition at line 213 of file SimTcpSegment.hpp.

213 { return segQ[1].getTcpCtrlUrg(); }

◆ getTcpDataOffset()

int SimTcpSegment::getTcpDataOffset ( )
inline

Definition at line 200 of file SimTcpSegment.hpp.

200 { return segQ[1].getTcpDataOff(); }

◆ getTcpDestinationPort()

TcpPort SimTcpSegment::getTcpDestinationPort ( )
inline

Definition at line 187 of file SimTcpSegment.hpp.

187 { return segQ[0].getTcpDstPort(); }

◆ getTcpOptionKind()

TcpOptKind SimTcpSegment::getTcpOptionKind ( )
inline

Definition at line 228 of file SimTcpSegment.hpp.

228 { return segQ[2].getTcpOptKind(); }

◆ getTcpOptionMss()

TcpOptMss SimTcpSegment::getTcpOptionMss ( )
inline

Definition at line 230 of file SimTcpSegment.hpp.

230 { return segQ[2].getTcpOptMss(); }

◆ getTcpSequenceNumber()

TcpSeqNum SimTcpSegment::getTcpSequenceNumber ( )
inline

Definition at line 192 of file SimTcpSegment.hpp.

192 { return segQ[0].getTcpSeqNum(); }

◆ getTcpSourcePort()

TcpPort SimTcpSegment::getTcpSourcePort ( )
inline

Definition at line 182 of file SimTcpSegment.hpp.

182 { return segQ[0].getTcpSrcPort(); }

◆ getTcpUrgentPointer()

TcpUrgPtr SimTcpSegment::getTcpUrgentPointer ( )
inline

Definition at line 225 of file SimTcpSegment.hpp.

225 { return segQ[2].getTcpUrgPtr(); }

◆ getTcpWindow()

TcpWindow SimTcpSegment::getTcpWindow ( )
inline

Definition at line 217 of file SimTcpSegment.hpp.

217 { return segQ[1].getTcpWindow(); }

◆ isWellFormed()

bool SimTcpSegment::isWellFormed ( const char *  callerName,
Ip4Addr  ipSa,
Ip4Addr  ipDa 
)
inline

Checks if the segment header fields are properly set.

Parameters
[in]callerNameThe name of the calling function or process.
[in]ipSaThe IP source address.
[in]ipDaThe IP destination address.
Returns
true if the cheksum field is valid.

Definition at line 365 of file SimTcpSegment.hpp.

365  {
366  bool rc = true;
367  // Assess the checksum is valid (or 0xDEAD)
368  TcpCsum tcpCsum = this->getTcpChecksum();
369  TcpCsum calcCsum = this->reCalculateTcpChecksum(ipSa, ipDa, (Ip4DatLen)this->getLen());
370  if ((tcpCsum != 0xDEAD) and (tcpCsum != calcCsum)) {
371  // TCP segment comes with an invalid checksum
372  printWarn(callerName, "Malformed TCP segment: 'Checksum' field does not match the checksum of the pseudo-packet.\n");
373  printWarn(callerName, "\tFound 'Checksum' field=0x%4.4X, Was expecting 0x%4.4X)\n",
374  tcpCsum.to_uint(), calcCsum.to_ushort());
375  rc = false;
376  }
377  return rc;
378  }
TcpCsum getTcpChecksum()
TcpCsum reCalculateTcpChecksum(Ip4Addr ipSa, Ip4Addr ipDa, Ip4DatLen segLen)
Recalculate the TCP checksum of this segment.
ap_uint< 16 > Ip4DatLen
Definition: AxisIp4.hpp:173
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182

◆ length()

int SimTcpSegment::length ( )
inline

Definition at line 134 of file SimTcpSegment.hpp.

134  {
135  return this->len;
136  }

◆ pullChunk()

AxisTcp SimTcpSegment::pullChunk ( )
inline

Definition at line 126 of file SimTcpSegment.hpp.

126  {
127  AxisTcp headingChunk = this->front();
128  this->pop_front();
129  setLen(getLen() - headingChunk.getLen());
130  return headingChunk;
131  }
int getLen() const
Definition: AxisRaw.hpp:411
Here is the call graph for this function:

◆ pushChunk()

void SimTcpSegment::pushChunk ( AxisTcp  tcpChunk)
inline

Definition at line 116 of file SimTcpSegment.hpp.

116  {
117  if (this->size() > 0) {
118  // Always clear 'TLAST' bit of previous chunck
119  this->segQ[this->size()-1].setLE_TLast(0);
120  }
121  this->push_back(tcpChunk);
122  this->setLen(this->getLen() + tcpChunk.getLen());
123  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reCalculateTcpChecksum()

TcpCsum SimTcpSegment::reCalculateTcpChecksum ( Ip4Addr  ipSa,
Ip4Addr  ipDa,
Ip4DatLen  segLen 
)
inline

Recalculate the TCP checksum of this segment.

  • While re-computing the checksum, the checksum field itself is replaced with zeros.
  • This will also overwrite the former TCP checksum.
  • You typically use this method if the segment was modified or when the checksum has not yet been calculated.
Returns
the computed checksum.

Definition at line 349 of file SimTcpSegment.hpp.

349  {
350  this->setTcpChecksum(0x0000);
351  TcpCsum newTcpCsum = calculateTcpChecksum(ipSa, ipDa, segLen);
352  // Overwrite the former TCP checksum
353  this->setTcpChecksum(newTcpCsum);
354  return (newTcpCsum);
355  }
TcpCsum calculateTcpChecksum(Ip4Addr ipSa, Ip4Addr ipDa, Ip4DatLen tcpSegLen)
Calculate the TCP checksum of the segment.
void setTcpChecksum(TcpChecksum csum)
Here is the caller graph for this function:

◆ setTcpAcknowledgeNumber()

void SimTcpSegment::setTcpAcknowledgeNumber ( TcpAckNum  num)
inline

Definition at line 194 of file SimTcpSegment.hpp.

194 { segQ[0].setTcpAckNum(num); }

◆ setTcpChecksum()

void SimTcpSegment::setTcpChecksum ( TcpChecksum  csum)
inline

Definition at line 219 of file SimTcpSegment.hpp.

219 { segQ[2].setTcpChecksum(csum); }

◆ setTcpControlAck()

void SimTcpSegment::setTcpControlAck ( TcpCtrlBit  bit)
inline

Definition at line 210 of file SimTcpSegment.hpp.

210 { segQ[1].setTcpCtrlAck(bit); }

◆ setTcpControlFin()

void SimTcpSegment::setTcpControlFin ( TcpCtrlBit  bit)
inline

Definition at line 202 of file SimTcpSegment.hpp.

202 { segQ[1].setTcpCtrlFin(bit); }

◆ setTcpControlPsh()

void SimTcpSegment::setTcpControlPsh ( TcpCtrlBit  bit)
inline

Definition at line 208 of file SimTcpSegment.hpp.

208 { segQ[1].setTcpCtrlPsh(bit); }

◆ setTcpControlRst()

void SimTcpSegment::setTcpControlRst ( TcpCtrlBit  bit)
inline

Definition at line 206 of file SimTcpSegment.hpp.

206 { segQ[1].setTcpCtrlRst(bit); }

◆ setTcpControlSyn()

void SimTcpSegment::setTcpControlSyn ( TcpCtrlBit  bit)
inline

Definition at line 204 of file SimTcpSegment.hpp.

204 { segQ[1].setTcpCtrlSyn(bit); }

◆ setTcpControlUrg()

void SimTcpSegment::setTcpControlUrg ( TcpCtrlBit  bit)
inline

Definition at line 212 of file SimTcpSegment.hpp.

212 { segQ[1].setTcpCtrlUrg(bit); }

◆ setTcpDataOffset()

void SimTcpSegment::setTcpDataOffset ( int  offset)
inline

Definition at line 198 of file SimTcpSegment.hpp.

198 { segQ[1].setTcpDataOff(offset); }

◆ setTcpDestinationPort()

void SimTcpSegment::setTcpDestinationPort ( TcpPort  port)
inline

Definition at line 185 of file SimTcpSegment.hpp.

185 { segQ[0].setTcpDstPort(port); }

◆ setTcpOptionKind()

void SimTcpSegment::setTcpOptionKind ( TcpOptKind  val)
inline

Definition at line 227 of file SimTcpSegment.hpp.

227 { segQ[2].setTcpOptKind(val); }

◆ setTcpOptionMss()

void SimTcpSegment::setTcpOptionMss ( TcpOptMss  val)
inline

Definition at line 229 of file SimTcpSegment.hpp.

229 { segQ[2].setTcpOptMss(val); }

◆ setTcpSequenceNumber()

void SimTcpSegment::setTcpSequenceNumber ( TcpSeqNum  num)
inline

Definition at line 190 of file SimTcpSegment.hpp.

190 { segQ[0].setTcpSeqNum(num); }

◆ setTcpSourcePort()

void SimTcpSegment::setTcpSourcePort ( TcpPort  port)
inline

Definition at line 180 of file SimTcpSegment.hpp.

180 { segQ[0].setTcpSrcPort(port); }

◆ setTcpUrgentPointer()

void SimTcpSegment::setTcpUrgentPointer ( TcpUrgPtr  ptr)
inline

Definition at line 223 of file SimTcpSegment.hpp.

223 { segQ[2].setTcpUrgPtr(ptr); }

◆ setTcpWindow()

void SimTcpSegment::setTcpWindow ( TcpWindow  win)
inline

Definition at line 215 of file SimTcpSegment.hpp.

215 { segQ[1].setTcpWindow(win); }

◆ size()

int SimTcpSegment::size ( )
inline

Definition at line 139 of file SimTcpSegment.hpp.

139  {
140  return this->segQ.size();
141  }

◆ writeAxisTcpToFile()

bool SimTcpSegment::writeAxisTcpToFile ( AxisTcp axisTcp,
ofstream &  outFileStream 
)
inline

Dump an AxisTcp chunk to a file.

Parameters
[in]axisTcpA pointer to the AxisTcp chunk to write.
[in]outFileStreamA reference to the file stream to write.
Returns
true upon success, otherwise false.

Definition at line 431 of file SimTcpSegment.hpp.

431  {
432  if (!outFileStream.is_open()) {
433  printError(myName, "File is not opened.\n");
434  return false;
435  }
436  outFileStream << std::uppercase;
437  outFileStream << hex << noshowbase << setfill('0') << setw(16) << axisTcp.getLE_TData().to_uint64();
438  outFileStream << " ";
439  outFileStream << setw(1) << axisTcp.getLE_TLast().to_int();
440  outFileStream << " ";
441  outFileStream << hex << noshowbase << setfill('0') << setw(2) << axisTcp.getLE_TKeep().to_int() << "\n";
442  if (axisTcp.getLE_TLast()) {
443  outFileStream << "\n";
444  }
445  return(true);
446  }
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:264
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
void uppercase(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NetworkWord > &siSHL_This_Data, stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &soNrc_meta, ap_uint< 32 > *po_rx_ports)
Main process of the Uppercase Application directives.
Definition: uppercase.cpp:335
Here is the call graph for this function:

◆ writePayloadToDatFile()

bool SimTcpSegment::writePayloadToDatFile ( ofstream &  outFileStream)
inline

Dump the payload of this segment as AxisTcp chunks into a file.

Parameters
[in]outFileStreamA reference to the file stream to write.
Returns
true upon success, otherwise false.

Definition at line 468 of file SimTcpSegment.hpp.

468  {
469  for (int i=1; i < this->size(); i++) {
470  AxisTcp axisWord = this->segQ[i];
471  if (not this->writeAxisTcpToFile(axisWord, outFileStream)) {
472  return false;
473  }
474  }
475  return true;
476  }
bool writeAxisTcpToFile(AxisTcp &axisTcp, ofstream &outFileStream)
Dump an AxisTcp chunk to a file.

◆ writeToDatFile()

bool SimTcpSegment::writeToDatFile ( ofstream &  outFileStream)
inline

Dump this TCP segment as raw AxisTcp chunks into a file.

Parameters
[in]outFileStreamA reference to the file stream to write.
Returns
true upon success, otherwise false.

Definition at line 453 of file SimTcpSegment.hpp.

453  {
454  for (int i=0; i < this->size(); i++) {
455  AxisTcp axisTcp = this->segQ[i];
456  if (not this->writeAxisTcpToFile(axisTcp, outFileStream)) {
457  return false;
458  }
459  }
460  return true;
461  }

The documentation for this class was generated from the following file: