Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:59:13+00:00 2026-05-16T02:59:13+00:00

I wrote a simple server and client apps, where I can switch between TCP,

  • 0

I wrote a simple server and client apps, where I can switch between TCP, DCCP and UDP protocols. The goal was to transfer a file from the one to the other and measure the traffic for each protocol, so I can compare them for different network setups (I know roughly what the result should be, but I need exact numbers/graphs). Anyway after starting both apps on different computers and starting tcpdump I only get in the tcpdump-log the first few MBs (~50MB) from my 4GB file. The apps are written in a standard C/C++ code, which could be found anywhere on the web.
What may be the problem or what could I be doing wrong here?

— Edit

The command line I use is:

tcpdump -s 1500 -w mylog

tcpdump captures then packets only the first ~55 sec. That’s the time the client needs to send the file to the socket. Afterwards it stops, even though the server continues receiving and writing the file to the hard drive.

— Edit2

Source code:

client.cpp
server.cpp
common.hpp
common.cpp

— Edit final

As many of you pointed out (and as I suspected) there were several misconceptions/bugs in the source code. After I cleaned it up (or almost rewrote it), it works as needed with tcpdump. I will accept the answer from @Laurent Parenteau but only for point 5. as it was the only relevant for the problem. If someone is interested in the correct code, here it is:

Source code edited

client.cpp
server.cpp
common.hpp
common.cpp

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:59:14+00:00Added an answer on May 16, 2026 at 2:59 am

    There are many things wrong in the code.

    1. The file size / transfer size is hardcoded to 4294967295 bytes. So, if the file supplied isn’t that many bytes, you’ll have problems.
    2. In the sender, you aren’t checking if the file read is successful or not. So if the file is smaller than 4294967295 bytes, you won’t know it and send junk data (or nothing at all) over the network.
    3. When you use UDP and DDCP, the packets order isn’t guarantee, so the data received may be out of order (ie. junk).
    4. When you use UDP, there’s no retransmission of lost packet, so some data may never be received.
    5. In the receiver, you aren’t check how many bytes you received, you always write MAX_LINE bytes to the file. So even if you receive 0 bytes, you’ll still be writing to the file, which is wrong.
    6. When you use UDP, since you’re sending in a thigh loop, even if the write() call return the same amount of bytes sent that what you requested, a lot of data will probably be dropped by the network stack or the network interface, since there’s no congestion control in place. So, you will need to put some congestion control in place yourself.

    And this is just from a quick scan of the code, there is probably more problems in there…

    My suggestion is :
    Try the transfer with TCP, do a md5sum of the file you read/send, and a md5sum of the file you receive/save, and compare the 2 md5sum. Once you have this case working, you can move to testing (still using the md5sum comparison) with UDP and DCCP…

    For the tcpdump command, you should change -s 1500 for -s 0, which means unlimited. With that tcpdump command, you can trust it that data not seen by it hasn’t been sent/received. Another good thing to do is to compare the tcpdump output of the sender with the receiver. This way you’ll know if some packet lost occurred between the two network stacks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've wrote a simple client and a server. They both can configured to use
I wrote an XML RPC server in python and a simple Test Client for
I wrote a simple client/server in java that transfers files using java NIO Socketchannel.
I'm exploring MSMQ services, and I wrote a simple console client-server application that sends
I wrote a simple HTTP client and server in Python for experimenting. The first
I wrote a simple UDP Server with Netty that simply prints out in logs
i make a simple TCP client/server in C# and i have the problem. When
I wrote two simple programs server and a client using sockets in C++ (Linux).
I wrote a simple server in C. It answers connections on port 8888. It
I wrote a (not-so-)simple websocket server in python, which listens in a port, performs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.