|
Bugzilla – Full Text Bug Listing |
| Summary: | TCP Raw socket sends packets indefinitely | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | asydney007 |
| Component: | tcp | Assignee: | Adrian S.-W. Tam <adrian.sw.tam> |
| Status: | RESOLVED INVALID | ||
| Severity: | major | CC: | ns-bugs, tomh |
| Priority: | P5 | ||
| Version: | ns-3.11 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Attachments: | Sample script | ||
Created attachment 1192 [details]
Sample script
(In reply to comment #0) > Hi Everyone, > So I"m using raw TCP sockets and below is my simple network: > > nodeA ------- nodeB > > 1. If I send a packet from A to B and enable line 140 "socket->close()" in the > function "dstSocketSend", B gets only 1 packet and sends a reply back to A > successfully. > > 2. However, I would like to continually send packets from A to B at different > times (or even at the same time) using the same socket. And so, I would like to > keep the socket open for the duration of the simulation. > > 3. When I comment out line 140 ("socket->Close();") from the "dstSocketSend" > function, A indefinitely sends pkts to B, and B indefinitely sends replies back > to A. There are two lines that need to be commented out: srcSocket[0]->SetSendCallback (MakeCallback (&srcSocketSend)); socket->SetSendCallback(MakeCallback (&dstSocketSend)); What is going on is that these callbacks are triggered when the socket tx buffer decreases (i.e. when a packet gets sent out). If you set a callback to send another packet upon this event, you can see that it will trigger infinite send behavior because each send event immediately triggers another application level send. Note also that TCP sockets have stream semantics which means that your send messages can get aggregated in the TCP socket buffer, leading possibly to fewer receives than you expect. For instance, your two send events get bundled together into one read event when you schedule the send events to occur both at time 0, and you only see one "hi" echoed: 0s In srcSocketSend 0s In srcSocketSend 0.0151008s In ServerHandleConnectionCreated 0.0151424s In dstSocketRecv Dst Received hello 0.0151424s In dstSocketSend 0.0202112s In srcSocketRecv Source Received hi But if you space your send events in your script to times 0 and 2, for example, you will see two "hi" messages received. 0s In srcSocketSend 0.0151008s In ServerHandleConnectionCreated 0.0151384s In dstSocketRecv Dst Received hello 0.0151384s In dstSocketSend 0.0202072s In srcSocketRecv Source Received hi 2s In srcSocketSend 2.00504s In dstSocketRecv Dst Received hello 2.00504s In dstSocketSend 2.01007s In srcSocketRecv Source Received hi |
Hi Everyone, So I"m using raw TCP sockets and below is my simple network: nodeA ------- nodeB 1. If I send a packet from A to B and enable line 140 "socket->close()" in the function "dstSocketSend", B gets only 1 packet and sends a reply back to A successfully. 2. However, I would like to continually send packets from A to B at different times (or even at the same time) using the same socket. And so, I would like to keep the socket open for the duration of the simulation. 3. When I comment out line 140 ("socket->Close();") from the "dstSocketSend" function, A indefinitely sends pkts to B, and B indefinitely sends replies back to A. Any help is greatly appreciated! Cheers! Syd