Berkeley CSUA MOTD:Entry 33015
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/24 [General] UID:1000 Activity:popular
5/24    

2004/8/19-20 [Computer/Networking] UID:33015 Activity:high
8/20    I have a socket protocol that sends each message as a header packet
        + 1 or more data packets, and I'd like to collapse this into a single
        packet for small messages by copying them into a stack-allocated buffer
        and then just sending that.  Any ideas about what sort of cutoff to
        use?  I don't really have the time or need to obsessively optimize
        it, just curious.  Thanks.
            \- Hello, so you are not going to send *anything* unless the
               "cut off" is reached? What if it isnt reached for a "long time"?
               This may be ok in some cases, but say this is a control channel
               of some kind, that delay may not be acceptable. Naive buffering
               can lead to some weird problems. Here is an example on the flip
               side, reading from the network: a process using a packet
               filter may not return to user level until the BPF buffer fills.
               Normally on a busy link this isnt a signficant issue. But on
               totally dead network ... say a LAN at home with one machine ...
               this may be a long long time and can lead to weird problems
               [liek dealing with signals]. So either you have to add some
               timeout code or doin a polling [select] read rather than read-
               ing directly, i.e. not do things the naive way. I assume
               you have already determined Nagling wont solve the problem
               for you? If you do something, I'd be curious to hear if it
               make any measurable difference at all. Ok tnx. --psb
              \_ No, it's more like this:
                  xyzSend(msg) {
                    if (length(msg) < CUTOFF) {
                      msg = makeHeader(msg) + msg
                      send(msg)
                    }
                    else {
                      send(makeHeader(msg)
                      send(msg)
                    }
                90% of the messages are 4 bytes long, so squeezing those is a
                no brainer and the network usage is cut by half.  The rest vary
                in length and most are << 1500 bytes.  I figure a cutoff of
                1024 is reasonable.
                \_ Do you know what the Nagle Algorithm is?
        \_ Try to fit the whole TCP/IP packet size into a single ethernet
           MTU (1500 bytes).
           \_ Go for less than that, I'd shoot for aroud 1400 bytes or so
              to make sure your TCP/IP headers aren't pushing you above 1500.
              If you want to be anal you'd probably want to do smallest MTU
              to host detection as well, not that hard.  Generally if you
              are caring about shit like this you should pick up the Stevens
              networking book and read the pertinant chapters.  It is a pretty
              easy read and you will be much better at this sort of stuff.
              \_ That's what I said.  1500 including the TCP/IP headers.
        \_ Use writev or sendto or sendmsg, then there is no copying.
2025/05/24 [General] UID:1000 Activity:popular
5/24    

You may also be interested in these entries...
2007/11/30-12/6 [Computer/SW/Compilers, Computer/HW/CPU] UID:48719 Activity:moderate
11/29   From the CSUA minutes:
        - Next Gen Console
        -- If we have $1800 in our accounts, should we buy a console:
           4 votes passes.
        -- Console voting: 2 votes each, neither passes
           * 360 = 600, more games
	...
2007/11/27-30 [Computer/SW/Languages/C_Cplusplus, Computer/SW/OS/Solaris] UID:48701 Activity:high
11/27   I'm using select to do a nonblocking check to see if a single socket
        has anything to read off it.  Problem is, I can have up to 12228
        file descriptors, and Linux fd_set only supports up to 4096.  Any idea
        what I can do about this?  (Or a better solution?) -jrleek
        \- 1. who are you
           2. i am busy this week and you didnt mention language
	...
2007/11/13-21 [Computer/Networking] UID:48628 Activity:low
11/13   If I have a application on machine foo sending data really fast to
        an application on machine bar via TCP, and the bar applications job
        is write that to disk as fast as possible, what happens if the
        network stream is faster than the disk writes?
        \_ Look up the differences between TCP/IP flow control and
           congestion control. The answer is in front of you.
	...
2007/4/30-5/4 [Computer/SW/Languages/C_Cplusplus, Computer/SW/WWW/Server] UID:46485 Activity:nil
4/30    Technical question:
        I have a threaded webserver, one thread waits around and calls
        accept, then pulls threads out of a thread pool to handle the
        requests.  I want to be able to shut down the webserver cleanly, so
        I have the main thread wait for a signal to shutdown.  It then
        joins on the accept thread while the accept thread cleans up the
	...
2007/3/23-27 [Computer/SW/Security, Computer/SW/Unix] UID:46068 Activity:nil
3/23    hey root can you turn 'PINGS' to soda.csua back on?
        thanks
        \_ Hey, root, can you disable this h0zer's motd-editing cron-job pls?
        \_ and what's up with crippling traceroute?  It needs setuid to
            function.
            > traceroute scotch
	...
2006/11/3-4 [Computer/SW/WWW/Browsers] UID:45153 Activity:nil
11/3    In my WinSock.h for v1.1 (dated 6/4/02), there is this line:
                #define AF_FIREFOX      19              /* FireFox */
        What is that???  FireFox socket address family?
        \_ It is a hack MS put into the windows network stack back in '02 to
           slow down FireFox network connections.
	...
2006/10/12-14 [Computer/HW/CPU] UID:44789 Activity:nil
10/12   On a dual-processor PC, the two CPUs can concurrently run one thread
        and one interrupt handler, or two interrupt handlers.  Can a dual-core
        processor PC and a hyperthreading processor PC do the same things?
        Thanks.
        \_ Dual-core is basically dual processor sharing the same socket, so
           I don't see why not.  Hyperthreading is weird, I dunno.
	...
2006/7/26-28 [Science/GlobalWarming, Computer/HW/CPU] UID:43810 Activity:nil
7/26    Re the AMD price cuts Monday, http://newegg.com shows the Athlon X2 4600+
        Socket AM2 Windsor as $330 and out of stock, but http://mwave.com has it
        in stock for $240.  Also, the energy-efficient variants are only
        supposed to have a 10% mark-up, but no word on availability.
        Don't get screwed.
        \_ How much MORE efficient?
	...