30 #ifndef _SIM_ICMP_PACKET_
31 #define _SIM_ICMP_PACKET_
53 std::deque<AxisIcmp> pktQ;
57 void setLen(
int pktLen) {
72 return this->pktQ.front();
76 this->pktQ.pop_front();
80 this->pktQ.push_back(icmpChunk);
87 this->myName =
"SimIcmpPacket";
89 if (pktLen > 0 && pktLen <=
MTU) {
99 this->myName =
"SimIcmpPacket";
105 if (this->
size() > 0) {
107 this->pktQ[this->
size()-1].setLE_TLast(0);
109 this->pktQ.push_back(icmpChunk);
110 setLen(this->getLen() + icmpChunk.
getLen());
115 AxisIcmp headingChunk = this->front();
117 setLen(getLen() - headingChunk.
getLen());
125 int size() {
return this->pktQ.size(); }
150 printFatal(
"IcmpPacket",
"Empty packet is expected to be of length %d bytes (was found to be %d bytes).\n",
153 int hdrLen = this->getLen();
154 int pldLen = pldStr.size();
155 int q = (hdrLen / 8);
156 int b = (hdrLen % 8);
161 unsigned long leQword = 0x0000000000000000;
162 unsigned char leKeep = 0x00;
165 unsigned char datByte = pldStr[i];
166 leQword = leQword | (datByte << b*8);
167 leKeep = leKeep | (1 << b);
182 ap_uint<32> csum = 0;
183 for (uint8_t i=0;i<this->
size();++i) {
184 ap_uint<64> tempInput = 0x0000000000000000;
185 if (pktQ[i].getLE_TKeep() & 0x01)
186 tempInput.range( 7, 0) = (pktQ[i].getLE_TData().range( 7, 0));
187 if (pktQ[i].getLE_TKeep() & 0x02)
188 tempInput.range(15, 8) = (pktQ[i].getLE_TData().range(15, 8));
189 if (pktQ[i].getLE_TKeep() & 0x04)
190 tempInput.range(23,16) = (pktQ[i].getLE_TData().range(23,16));
191 if (pktQ[i].getLE_TKeep() & 0x08)
192 tempInput.range(31,24) = (pktQ[i].getLE_TData().range(31,24));
193 if (pktQ[i].getLE_TKeep() & 0x10)
194 tempInput.range(39,32) = (pktQ[i].getLE_TData().range(39,32));
195 if (pktQ[i].getLE_TKeep() & 0x20)
196 tempInput.range(47,40) = (pktQ[i].getLE_TData().range(47,40));
197 if (pktQ[i].getLE_TKeep() & 0x40)
198 tempInput.range(55,48) = (pktQ[i].getLE_TData().range(55,48));
199 if (pktQ[i].getLE_TKeep() & 0x80)
200 tempInput.range(63,56) = (pktQ[i].getLE_TData().range(63,56));
202 tempInput.range(63, 48)) + tempInput.range(47, 32)) +
203 tempInput.range(31, 16)) + tempInput.range(15, 0));
204 csum = (csum & 0xFFFF) + (csum >> 16);
208 icmpCsum = ~icmpCsum;
225 return (newIcmpCsum);
Class ICMP Packet for simulation.
void setIcmpCode(IcmpCode code)
SimIcmpPacket(int pktLen)
void pushChunk(AxisIcmp icmpChunk)
IcmpCsum calculateIcmpChecksum()
IcmpCsum reCalculateIcmpChecksum()
Recalculate the ICMP checksum of a packet.
void setIcmpIdent(IcmpIdent id)
void setIcmpType(IcmpType type)
void addIcmpPayload(string pldStr)
void setIcmpChecksum(IcmpCsum csum)
IcmpSeqNum getIcmpSeqNum()
void setIcmpSeqNum(IcmpSeqNum num)
IcmpCsum getIcmpChecksum()
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...
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
: Definition of the Network Transport Stack (NTS) component as if it was an HLS IP core.
: Utilities and helpers for the Network-Transport-Stack (NTS) components.
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)