INET Framework for OMNeT++/OMNEST
inet::SCTPNatServer Class Reference

#include <SCTPNatServer.h>

Inheritance diagram for inet::SCTPNatServer:

Classes

struct  pathStatus
 

Public Member Functions

void initialize () override
 
void handleMessage (cMessage *msg) override
 
void finish () override
 
void handleTimer (cMessage *msg)
 
void generateAndSend ()
 
void sendInfo (NatInfo *info)
 
void printNatVector ()
 

Protected Attributes

int32 notifications
 
uint32 assocId
 
SCTPSocketsocket
 
bool shutdownReceived
 
int64 bytesSent
 
int32 packetsSent
 
int32 packetsRcvd
 
int32 numSessions
 
int32 numRequestsToSend
 
bool ordered
 
int32 outboundStreams
 
int32 inboundStreams
 
int32 lastStream
 
int32 ssn
 

Static Protected Attributes

static NatVector natVector
 

Member Function Documentation

void inet::SCTPNatServer::finish ( )
override
485 {
486  EV << getFullPath() << ": opened " << numSessions << " sessions\n";
487  EV << getFullPath() << ": sent " << bytesSent << " bytes in " << packetsSent << " packets\n";
488 
489  EV << getFullPath() << "Over all " << packetsRcvd << " packets received\n ";
490  EV << getFullPath() << "Over all " << notifications << " notifications received\n ";
491 }
int32 packetsRcvd
Definition: SCTPNatServer.h:56
int64 bytesSent
Definition: SCTPNatServer.h:54
int32 packetsSent
Definition: SCTPNatServer.h:55
int32 notifications
Definition: SCTPNatServer.h:50
int32 numSessions
Definition: SCTPNatServer.h:57
void inet::SCTPNatServer::generateAndSend ( )
154 {
155  cPacket *cmsg = new cPacket("SCTP_C_SEND");
156  SCTPSimpleMessage *msg = new SCTPSimpleMessage("Server");
157  int numBytes = (int)par("requestLength");
158  msg->setDataArraySize(numBytes);
159  for (int i = 0; i < numBytes; i++)
160  msg->setData(i, 's');
161 
162  msg->setDataLen(numBytes);
163  msg->setEncaps(false);
164  msg->setBitLength(numBytes * 8);
165  cmsg->encapsulate(msg);
166  SCTPSendInfo *cmd = new SCTPSendInfo("Send1");
167  cmd->setAssocId(assocId);
168  cmd->setSendUnordered(ordered ? COMPLETE_MESG_ORDERED : COMPLETE_MESG_UNORDERED);
170  cmd->setSid(lastStream);
171  cmd->setLast(true);
172  cmsg->setKind(SCTP_C_SEND);
173  cmsg->setControlInfo(cmd);
174  packetsSent++;
175  bytesSent += msg->getBitLength() / 8;
176  send(cmsg, "sctpOut");
177 }
bool ordered
Definition: SCTPNatServer.h:59
Definition: SCTPCommand.h:33
int32 lastStream
Definition: SCTPNatServer.h:62
uint32 assocId
Definition: SCTPNatServer.h:51
int32 outboundStreams
Definition: SCTPNatServer.h:60
Definition: SCTPCommand.h:87
Definition: SCTPCommand.h:88
int64 bytesSent
Definition: SCTPNatServer.h:54
int32 packetsSent
Definition: SCTPNatServer.h:55
void inet::SCTPNatServer::handleMessage ( cMessage *  msg)
override
180 {
181  int32 id;
182 
183  if (msg->isSelfMessage()) {
184  handleTimer(msg);
185  }
186  else {
187  EV << "SCTPNatServer::handleMessage kind=" << SCTPAssociation::indicationName(msg->getKind()) << " (" << msg->getKind() << ")\n";
188  switch (msg->getKind()) {
189  case SCTP_I_PEER_CLOSED:
190  case SCTP_I_ABORT: {
191  SCTPCommand *ind = check_and_cast<SCTPCommand *>(msg->getControlInfo()->dup());
192  cMessage *cmsg = new cMessage("SCTP_C_ABORT");
193  SCTPSendInfo *cmd = new SCTPSendInfo();
194  id = ind->getAssocId();
195  cmd->setAssocId(id);
196  cmd->setSid(ind->getSid());
197  cmd->setNumMsgs(ind->getNumMsgs());
198  cmsg->setControlInfo(cmd);
199  delete ind;
200  delete msg;
201  cmsg->setKind(SCTP_C_ABORT);
202  send(cmsg, "sctpOut");
203  break;
204  }
205 
206  case SCTP_I_ESTABLISHED: {
207  SCTPConnectInfo *connectInfo = check_and_cast<SCTPConnectInfo *>(msg->removeControlInfo());
208  numSessions++;
209  assocId = connectInfo->getAssocId();
210  id = assocId;
211  inboundStreams = connectInfo->getInboundStreams();
212  outboundStreams = connectInfo->getOutboundStreams();
213 
214  delete connectInfo;
215  delete msg;
216 
217  break;
218  }
219 
221  notifications++;
222  SCTPCommand *ind = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
223  cMessage *cmsg = new cMessage("SCTP_C_RECEIVE");
224  SCTPSendInfo *cmd = new SCTPSendInfo();
225  id = ind->getAssocId();
226  cmd->setAssocId(id);
227  cmd->setSid(ind->getSid());
228  cmd->setNumMsgs(ind->getNumMsgs());
229  cmsg->setKind(SCTP_C_RECEIVE);
230  cmsg->setControlInfo(cmd);
231  delete ind;
232  delete msg;
233  send(cmsg, "sctpOut");
234  break;
235  }
236 
237  case SCTP_I_DATA: {
238  EV << "\nData arrived at server: assoc=" << assocId << "\n";
239  printNatVector();
240  SCTPCommand *ind = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
241  id = ind->getAssocId();
242  SCTPSimpleMessage *smsg = check_and_cast<SCTPSimpleMessage *>(msg);
243  NatMessage *nat = check_and_cast<NatMessage *>(smsg->decapsulate());
244  bool found = false;
245  if (natVector.size() > 0) {
246  for (auto & elem : natVector) {
247  if ((elem)->peer1 == nat->getPeer1() || (elem)->peer1Assoc == assocId) {
248  EV << "found entry: info: Peer1 = " << nat->getPeer1() << " peer1Address1=" << nat->getPeer1Addresses(0) << " peer2=" << nat->getPeer2() << " peer2Address1=" << nat->getPeer2Addresses(0) << "\n";
249  if (nat->getMulti() && nat->getPeer1AddressesArraySize() > 1 && nat->getPeer2AddressesArraySize() > 1) {
250  EV << " peer1Address2=" << nat->getPeer1Addresses(1) << " peer2Address2=" << nat->getPeer2Addresses(1) << endl;
251  }
252  if ((elem)->peer1 == 0 && !(elem)->peer1Address2.isUnspecified()) {
253  (elem)->peer1 = nat->getPeer1();
254  (elem)->peer1Address1 = ind->getRemoteAddr();
255  (elem)->peer1Port = nat->getPortPeer1();
256  if ((elem)->peer2 == 0) {
257  (elem)->peer2 = nat->getPeer2();
258  }
259  }
260  if (nat->getMulti() && (elem)->peer1Address2.isUnspecified()) {
261  (elem)->peer1Address2 = ind->getRemoteAddr();
262  }
263  if (!(elem)->peer2Address1.isUnspecified() && !(elem)->peer1Address1.isUnspecified()) {
264  if (!(elem)->multi || ((elem)->multi && !(elem)->peer2Address2.isUnspecified() && !(elem)->peer1Address2.isUnspecified())) {
265  EV << "entry now: Peer1=" << (elem)->peer1 << " Peer2=" << (elem)->peer2 << " peer1Address1=" << (elem)->peer1Address1 << " peer1Address2=" << (elem)->peer1Address2 << " peer2Address1=" << (elem)->peer2Address1 << " peer2Address2=" << (elem)->peer2Address2 << " peer2Port=" << (elem)->peer2Port << "\n";
266  sendInfo((elem));
267  }
268  }
269  found = true;
270  break;
271  }
272  if ((elem)->peer2 == nat->getPeer1() || (elem)->peer2Assoc == assocId) {
273  EV << "opposite way: info: Peer1 = " << nat->getPeer1() << " peer1Address1=" << nat->getPeer1Addresses(0) << " peer2=" << nat->getPeer2() << " peer2Address1=" << nat->getPeer2Addresses(0) << "\n";
274  if (nat->getMulti() && nat->getPeer1AddressesArraySize() > 1 && nat->getPeer2AddressesArraySize() > 1) {
275  EV << " peer1Address2=" << nat->getPeer1Addresses(1) << " peer2Address2=" << nat->getPeer2Addresses(1) << endl;
276  }
277  if ((elem)->peer2 == 0) {
278  (elem)->peer2 = nat->getPeer1();
279  }
280  if ((elem)->peer1 == 0) {
281  (elem)->peer1 = nat->getPeer2();
282  }
283  if ((elem)->peer2Address1.isUnspecified()) {
284  (elem)->peer2Address1 = ind->getRemoteAddr();
285  (elem)->peer2Assoc = assocId;
286  (elem)->peer2Port = nat->getPortPeer1();
287  (elem)->peer2Gate = ind->getGate();
288  EV << "set peer2Address1=" << ind->getRemoteAddr() << " peer2Assoc=" << assocId << " peer2Port=" << nat->getPortPeer1() << "\n";
289  }
290  else if ((elem)->multi && !(elem)->peer2Address2.isUnspecified())
291  (elem)->peer2Address2 = ind->getRemoteAddr();
292 
293  if (!(elem)->multi || ((elem)->multi && !(elem)->peer2Address2.isUnspecified() && !(elem)->peer1Address2.isUnspecified()
294  && !(elem)->peer2Address1.isUnspecified() && !(elem)->peer1Address1.isUnspecified()))
295  {
296  EV << "entry now: Peer1=" << (elem)->peer1 << " Peer2=" << (elem)->peer2 << " peer1Address1=" << (elem)->peer1Address1 << " peer1Address2=" << (elem)->peer1Address2 << " peer2Address1=" << (elem)->peer2Address1 << " peer2Address2=" << (elem)->peer2Address2 << " peer1Port=" << (elem)->peer1Port << "peer2Port=" << (elem)->peer2Port << "\n";
297  sendInfo((elem));
298  }
299  found = true;
300  break;
301  }
302  }
303  }
304  if (natVector.size() == 0 || !found) {
305  EV << "make new Info for ";
306  NatInfo *info = new NatInfo();
307  info->peer1 = nat->getPeer1();
308  EV << info->peer1 << " and assoc " << assocId << "\n";
309  ;
310  info->multi = nat->getMulti();
311  info->peer1Address1 = ind->getRemoteAddr();
312  if (info->multi) {
313  info->peer1Address2 = L3Address();
314  info->peer2Address2 = L3Address();
315  }
316  info->peer1Port = nat->getPortPeer1();
317  info->peer1Assoc = assocId;
318  info->peer1Gate = ind->getGate();
319  info->peer2 = nat->getPeer2();
320  info->peer2Address1 = L3Address();
321  info->peer2Port = 0;
322  info->peer2Assoc = 0;
323  info->peer2Gate = -1;
324  natVector.push_back(info);
325  EV << "Info: peer1=" << info->peer1 << " peer1Address1=" << info->peer1Address1 << " peer1Address2=" << info->peer1Address2 << " peer1Assoc=" << info->peer1Assoc << "\n peer2=" << info->peer2 << " peer2Address1=" << info->peer2Address1 << " peer2Address2=" << info->peer2Address2 << " peer2Assoc=" << info->peer2Assoc << "\n";
326  }
327  EV << "\n";
328  printNatVector();
329  delete msg;
330 
331  delete ind;
332  delete nat;
333  break;
334  }
335 
337  SCTPCommand *command = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
338  id = command->getAssocId();
339  EV << "server: SCTP_I_SHUTDOWN_RECEIVED for assoc " << id << "\n";
340  cMessage *cmsg = new cMessage("SCTP_C_NO_OUTSTANDING");
341  SCTPInfo *qinfo = new SCTPInfo("Info");
342  cmsg->setKind(SCTP_C_NO_OUTSTANDING);
343  qinfo->setAssocId(id);
344  cmsg->setControlInfo(qinfo);
345  send(cmsg, "sctpOut");
346 
347  delete command;
348  shutdownReceived = true;
349  delete msg;
350  break;
351  }
352 
355  EV << "Streams have been resetted\n";
356  delete msg;
357  break;
358  }
359 
360  case SCTP_I_CLOSED:
361  delete msg;
362  break;
363 
364  case SCTP_I_ADDRESS_ADDED: {
365  SCTPCommand *ind = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
366  bool found = false;
367  printNatVector();
368  EV << " address added: LOCAL=" << ind->getLocalAddr() << ", remote=" << ind->getRemoteAddr() << " assoc=" << assocId << "\n";
369  if (natVector.size() > 0) {
370  for (auto & elem : natVector) {
371  if ((elem)->peer1Assoc == assocId) {
372  EV << "found entry for assoc1 = " << assocId << " Peer1 = " << (elem)->peer1 << " peer1Address1=" << (elem)->peer1Address1 << " peer1Address2=" << (elem)->peer1Address2 << " peer2=" << (elem)->peer2 << " peer2Address1=" << (elem)->peer2Address1 << " peer2Address2=" << (elem)->peer2Address2 << "\n";
373  if ((elem)->multi && (elem)->peer1Address2.isUnspecified()) {
374  (elem)->peer1Address2 = ind->getRemoteAddr();
375  EV << "added peer1Address2=" << ind->getRemoteAddr() << "\n";
376  }
377  if (!(elem)->peer2Address1.isUnspecified()) {
378  if (!(elem)->multi || ((elem)->multi && !(elem)->peer2Address2.isUnspecified() && !(elem)->peer1Address2.isUnspecified())) {
379  EV << "entry now: Peer1=" << (elem)->peer1 << " Peer2=" << (elem)->peer2 << " peer1Address1=" << (elem)->peer1Address1 << " peer1Address2=" << (elem)->peer1Address2 << " peer2Address1=" << (elem)->peer2Address1 << " peer2Address2=" << (elem)->peer2Address2 << " peer2Port=" << (elem)->peer2Port << "\n";
380  sendInfo((elem));
381  }
382  }
383  found = true;
384  break;
385  }
386  else if ((elem)->peer2Assoc == assocId) {
387  EV << "opposite way: found entry for assoc2 = " << assocId << " peer1Address1=" << (elem)->peer1Address1 << " peer1Address2=" << (elem)->peer1Address2 << " peer2Address1=" << (elem)->peer2Address1 << " peer2Address2=" << (elem)->peer2Address2 << "\n";
388  if ((elem)->multi)
389  (elem)->peer2Address2 = ind->getRemoteAddr();
390 
391  if (!(elem)->multi || ((elem)->multi && !(elem)->peer2Address2.isUnspecified() && !(elem)->peer1Address2.isUnspecified())) {
392  EV << "entry now: Peer1=" << (elem)->peer1 << " Peer2=" << (elem)->peer2 << " peer1Address1=" << (elem)->peer1Address1 << " peer1Address2=" << (elem)->peer1Address2 << " peer2Address1=" << (elem)->peer2Address1 << " peer2Address2=" << (elem)->peer2Address2 << " peer1Port=" << (elem)->peer1Port << "peer2Port=" << (elem)->peer2Port << "\n";
393  sendInfo((elem));
394  }
395  found = true;
396  break;
397  }
398  else if ((elem)->peer2Assoc == 0 && ((elem)->multi)) {
399  (elem)->peer2Address2 = ind->getRemoteAddr();
400  (elem)->peer2Assoc = assocId;
401  (elem)->peer2Port = ind->getRemotePort();
402  (elem)->peer2Gate = ind->getGate();
403  EV << "entry now: Peer1=" << (elem)->peer1 << " Peer2=" << (elem)->peer2 << " peer1Address1=" << (elem)->peer1Address1 << " peer1Address2=" << (elem)->peer1Address2 << " peer2Address1=" << (elem)->peer2Address1 << " peer2Address2=" << (elem)->peer2Address2 << " peer1Port=" << (elem)->peer1Port << "peer2Port=" << (elem)->peer2Port << "\n";
404 
405  found = true;
406  }
407  }
408  }
409  else if (natVector.size() == 0 && !found) {
410  EV << "make new Info for ";
411  NatInfo *info = new NatInfo();
412  info->peer1 = 0;
413  info->peer1Assoc = assocId;
414  EV << info->peer1 << " and assoc " << assocId << "\n";
415  ;
416  info->multi = 1;
417  info->peer1Address1 = L3Address();
418  info->peer1Address2 = ind->getRemoteAddr();
419  info->peer1Port = ind->getRemotePort();
420  info->peer1Gate = ind->getGate();
421  info->peer2 = 0;
422  info->peer2Address1 = L3Address();
423  info->peer2Address2 = L3Address();
424  info->peer2Port = 0;
425  info->peer2Assoc = 0;
426  info->peer2Gate = -1;
427  natVector.push_back(info);
428  EV << "Info: peer1=" << info->peer1 << " peer1Address1=" << info->peer1Address1 << " peer1Address2=" << info->peer1Address2 << " peer1Assoc=" << info->peer1Assoc << "\n peer2=" << info->peer1 << " peer2Address1=" << info->peer2Address1 << " peer2Address2=" << info->peer2Address2 << " peer2Assoc=" << info->peer2Assoc << "\n";
429  }
430  delete ind;
431  delete msg;
432  printNatVector();
433  break;
434  }
435 
436  default:
437  EV << "Message type " << SCTPAssociation::indicationName(msg->getKind()) << " not implemented\n";
438  }
439  }
440 }
Definition: SCTPCommand.h:80
int32 inboundStreams
Definition: SCTPNatServer.h:61
void sendInfo(NatInfo *info)
Definition: SCTPNatServer.cc:71
Definition: SCTPCommand.h:67
static const char * indicationName(const int32 code)
Utility: returns name of SCTP_I_xxx constants.
Definition: SCTPAssociationUtil.cc:206
Definition: SCTPCommand.h:79
Definition: SCTPCommand.h:63
uint32 assocId
Definition: SCTPNatServer.h:51
void printNatVector()
Definition: SCTPNatServer.cc:476
Definition: SCTPCommand.h:35
Definition: SCTPCommand.h:37
Definition: SCTPCommand.h:65
Definition: SCTPCommand.h:75
Definition: SCTPCommand.h:44
Definition: SCTPCommand.h:66
Definition: SCTPCommand.h:64
void handleTimer(cMessage *msg)
Definition: SCTPNatServer.cc:442
int32_t int32
Definition: Compat.h:31
Definition: SCTPCommand.h:72
int32 outboundStreams
Definition: SCTPNatServer.h:60
struct inet::natInfo NatInfo
Accepts any number of incoming connections, and sends back whatever arrives on them.
uint16_t id
Definition: TCP_NSC.cc:85
static NatVector natVector
Definition: SCTPNatServer.h:64
bool shutdownReceived
Definition: SCTPNatServer.h:53
int32 notifications
Definition: SCTPNatServer.h:50
int32 numSessions
Definition: SCTPNatServer.h:57
Definition: SCTPCommand.h:82
void inet::SCTPNatServer::handleTimer ( cMessage *  msg)
443 {
444  cMessage *cmsg;
445  int32 id;
446 
447  SCTPConnectInfo *connectInfo = dynamic_cast<SCTPConnectInfo *>(msg->getControlInfo());
448  switch (msg->getKind()) {
449  case SCTP_C_SEND:
450  if (numRequestsToSend > 0) {
451  generateAndSend();
453  }
454  break;
455 
456  case SCTP_I_ABORT: {
457  cmsg = new cMessage("SCTP_C_CLOSE", SCTP_C_CLOSE);
458  SCTPCommand *cmd = new SCTPCommand();
459  id = atoi(msg->getName());
460  cmd->setAssocId(id);
461  cmsg->setControlInfo(cmd);
462  send(cmsg, "sctpOut");
463  break;
464  }
465 
466  case SCTP_C_RECEIVE:
467  send(msg, "sctpOut");
468  break;
469 
470  default:
471  break;
472  }
473  delete connectInfo;
474 }
Definition: SCTPCommand.h:33
Definition: SCTPCommand.h:37
int32_t int32
Definition: Compat.h:31
Definition: SCTPCommand.h:72
uint16_t id
Definition: TCP_NSC.cc:85
int32 numRequestsToSend
Definition: SCTPNatServer.h:58
Definition: SCTPCommand.h:34
void generateAndSend()
Definition: SCTPNatServer.cc:153
void inet::SCTPNatServer::initialize ( )
override
39 {
41  WATCH(numSessions);
42  WATCH(packetsSent);
43  WATCH(packetsRcvd);
44  WATCH(bytesSent);
45  WATCH(numRequestsToSend);
46 
47  // parameters
48  const char *addressesString = par("localAddress");
49  AddressVector addresses = L3AddressResolver().resolve(cStringTokenizer(addressesString).asVector());
50  int32 port = par("localPort");
51  inboundStreams = par("inboundStreams");
52  outboundStreams = par("outboundStreams");
53  ordered = (bool)par("ordered");
54  lastStream = 0;
55 
56  socket = new SCTPSocket();
57  socket->setOutputGate(gate("sctpOut"));
60 
61  if (addresses.size() == 0)
62  socket->bind(port);
63  else
64  socket->bindx(addresses, port);
65  socket->listen(true, false, par("numPacketsToSendPerClient"));
66  EV << "SCTPNatServer::initialized listen port=" << port << "\n";
67 
68  shutdownReceived = false;
69 }
bool ordered
Definition: SCTPNatServer.h:59
int32 inboundStreams
Definition: SCTPNatServer.h:61
void bindx(AddressVector localAddr, int localPort)
Definition: SCTPSocket.cc:165
int32 lastStream
Definition: SCTPNatServer.h:62
int32 packetsRcvd
Definition: SCTPNatServer.h:56
std::vector< L3Address > AddressVector
Definition: SCTPCommand_m.h:41
void bind(int localPort)
Bind the socket to a local port number.
Definition: SCTPSocket.cc:136
int32_t int32
Definition: Compat.h:31
int32 outboundStreams
Definition: SCTPNatServer.h:60
SCTPSocket * socket
Definition: SCTPNatServer.h:52
void setInboundStreams(int streams)
Definition: SCTPSocket.h:183
bool shutdownReceived
Definition: SCTPNatServer.h:53
void setOutboundStreams(int streams)
Setter and getter methods for socket and API Parameters.
Definition: SCTPSocket.h:182
int64 bytesSent
Definition: SCTPNatServer.h:54
int32 numRequestsToSend
Definition: SCTPNatServer.h:58
void listen(bool fork=true, bool streamReset=false, uint32 requests=0, uint32 messagesToPush=0)
Initiates passive OPEN.
Definition: SCTPSocket.cc:177
void setOutputGate(cGate *toSctp)
Sets the gate on which to send to SCTP.
Definition: SCTPSocket.h:177
int32 packetsSent
Definition: SCTPNatServer.h:55
int32 notifications
Definition: SCTPNatServer.h:50
int32 numSessions
Definition: SCTPNatServer.h:57
void inet::SCTPNatServer::printNatVector ( void  )
477 {
478  for (auto & elem : natVector) {
479  EV << "Peer1: " << (elem)->peer1 << " Assoc: " << (elem)->peer1Assoc << " Address1: " << (elem)->peer1Address1 << " Address2: " << (elem)->peer1Address2 << "Port: " << (elem)->peer1Port << endl;
480  EV << "Peer2: " << (elem)->peer2 << " Assoc: " << (elem)->peer2Assoc << " Address1: " << (elem)->peer2Address1 << " Address2: " << (elem)->peer2Address2 << "Port: " << (elem)->peer2Port << endl;
481  }
482 }
static NatVector natVector
Definition: SCTPNatServer.h:64
void inet::SCTPNatServer::sendInfo ( NatInfo info)
72 {
73  NatMessage *msg = new NatMessage("Rendezvous");
74  msg->setKind(SCTP_C_NAT_INFO);
75  msg->setMulti(info->multi);
76  msg->setPeer1(info->peer1);
77  msg->setPeer1AddressesArraySize(2);
78  msg->setPeer1Addresses(0, info->peer1Address1);
79  msg->setPeer1Addresses(1, info->peer1Address2);
80  msg->setPortPeer1(info->peer1Port);
81  msg->setPeer2(info->peer2);
82  msg->setPeer2AddressesArraySize(2);
83  msg->setPeer2Addresses(0, info->peer2Address1);
84  msg->setPeer2Addresses(1, info->peer2Address2);
85  msg->setPortPeer2(info->peer2Port);
86  EV << "Info for peer1: peer1-1=" << msg->getPeer1Addresses(0) << " peer2-1=" << msg->getPeer2Addresses(0) << "\n";
87  if (info->multi)
88  EV << " peer1-2=" << msg->getPeer1Addresses(1) << " peer2-2=" << msg->getPeer2Addresses(1) << endl;
89  cPacket *cmsg = new cPacket(msg->getName());
90  SCTPSimpleMessage *smsg = new SCTPSimpleMessage("nat_data");
91  smsg->setEncaps(true);
92  smsg->encapsulate(msg);
93  smsg->setCreationTime(simTime());
94  smsg->setByteLength(16);
95  smsg->setDataLen(16);
96  cmsg->encapsulate(PK(smsg));
97  SCTPSendInfo *cmd = new SCTPSendInfo();
98  cmd->setAssocId(info->peer1Assoc);
99  cmd->setGate(info->peer1Gate);
100  cmd->setSendUnordered(COMPLETE_MESG_UNORDERED);
101  cmd->setSid(0);
102  cmd->setLast(true);
103  cmsg->setKind(SCTP_C_SEND);
104  cmsg->setControlInfo(cmd);
105  send(cmsg, "sctpOut");
106  EV << "info sent to peer1\n";
107 
108  cMessage *abortMsg = new cMessage("abortPeer1", SCTP_C_SHUTDOWN);
109  abortMsg->setControlInfo(cmd->dup());
110  send(abortMsg, "sctpOut");
111  EV << "abortMsg sent to peer1\n";
112 
113  msg = new NatMessage("Rendezvous");
114  msg->setKind(SCTP_C_NAT_INFO);
115  msg->setMulti(info->multi);
116  msg->setPeer1(info->peer2);
117  msg->setPeer1AddressesArraySize(2);
118  msg->setPeer1Addresses(0, info->peer2Address1);
119  msg->setPeer1Addresses(1, info->peer2Address2);
120  msg->setPortPeer1(info->peer2Port);
121  msg->setPeer2(info->peer1);
122  msg->setPeer2AddressesArraySize(2);
123  msg->setPeer2Addresses(0, info->peer1Address1);
124  msg->setPeer2Addresses(1, info->peer1Address2);
125  msg->setPortPeer2(info->peer1Port);
126  EV << "Info for peer2: peer1-1=" << msg->getPeer1Addresses(0) << " peer2-1=" << msg->getPeer2Addresses(0) << "\n";
127  if (info->multi)
128  EV << " peer1-2=" << msg->getPeer1Addresses(1) << " peer2-2=" << msg->getPeer2Addresses(1) << endl;
129  cmsg = new cPacket(msg->getName());
130  smsg = new SCTPSimpleMessage("nat_data");
131  smsg->setEncaps(true);
132  smsg->encapsulate(msg);
133  smsg->setCreationTime(simTime());
134  smsg->setByteLength(16);
135  smsg->setDataLen(16);
136  cmsg->encapsulate(PK(smsg));
137  cmd = new SCTPSendInfo();
138  cmd->setAssocId(info->peer2Assoc);
139  cmd->setGate(info->peer2Gate);
140  cmd->setSendUnordered(COMPLETE_MESG_UNORDERED);
141  cmd->setSid(0);
142  cmd->setLast(true);
143  cmsg->setKind(SCTP_C_SEND);
144  cmsg->setControlInfo(cmd);
145  EV << "info sent to peer2\n";
146  send(cmsg, "sctpOut");
147  abortMsg = new cPacket("abortPeer2", SCTP_C_SHUTDOWN);
148  abortMsg->setControlInfo(cmd->dup());
149  send(abortMsg, "sctpOut");
150  EV << "abortMsg sent to peer2\n";
151 }
Definition: SCTPCommand.h:33
Definition: SCTPCommand.h:43
#define PK(msg)
Definition: INETDefs.h:92
Definition: SCTPCommand.h:48
Definition: SCTPCommand.h:87

Member Data Documentation

uint32 inet::SCTPNatServer::assocId
protected
int64 inet::SCTPNatServer::bytesSent
protected
int32 inet::SCTPNatServer::inboundStreams
protected
int32 inet::SCTPNatServer::lastStream
protected
NatVector inet::SCTPNatServer::natVector
staticprotected
int32 inet::SCTPNatServer::notifications
protected
int32 inet::SCTPNatServer::numRequestsToSend
protected
int32 inet::SCTPNatServer::numSessions
protected
bool inet::SCTPNatServer::ordered
protected
int32 inet::SCTPNatServer::outboundStreams
protected
int32 inet::SCTPNatServer::packetsRcvd
protected
int32 inet::SCTPNatServer::packetsSent
protected
bool inet::SCTPNatServer::shutdownReceived
protected
SCTPSocket* inet::SCTPNatServer::socket
protected
int32 inet::SCTPNatServer::ssn
protected

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