I teach students to develop network applications, both clients and servers. At this moment, we have not yet touched existing protocols such as HTTP, SMTP, etc. The students write very simple programs on top of the plain socket API. Currently I check a students' work manually, but I want to automate this task and create an automated test bench for networking applications. The most interesting topics for testing are:
read/recv
call and process the received data without checking that all necessary data was received. TCP doesn't guarantee the message boundaries, so in certain circumstances it is necessary to make several read/recv
calls. The problem is that in most simple network applications (for example, in a chat application) messages are small and fit into the single TCP segment, so the issue doesn't appear. My idea is to artificially break messages into several small TCP segments (ie several bytes of data) so the problem will appear. I've found several systems which simulate a bad network (dummynet, clumsy, netem). Hovewer, they all work on the IP level of the stack, so OS and it's TCP implementation will compensate the data loss. Such systems are able to solve the task number 2, but they are not able to solve tasks 1 and 3. So I think that I need to develop my own solution, which will act as a TCP proxy. My questions are:
From WireShark mailing list - Creating and Modifying Packets :
...There's a "Tools" page on the Wireshark Wiki:
which has a "Traffic generators" section:
which lists some tools that might be useful...
The "Traffic generators" chapter also mentions another collection of traffic generators
If you write your own socket code, you can address all 3 tasks.
enable the socket's TCP_NODELAY
option (disable the Nagle Algorithm for Send Coalescing) via setsockopt()
, then you can send()
small fragments of data as you wish, optionally with a delay in between (see #2).
simply put a delay in between your send()
calls.
use setsockopt()
to adjust the socket's SO_LINGER
and SO_DONTLINGER
options to control whether closing the socket performs an abortive or graceful closure, then simply close the socket at some random interval after the connection is established.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.