Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


TCP/IP Question

Posted on 2001-06-06
Medium Priority
Last Modified: 2013-12-03
I'm working on a program that communicates with other instances of the same program running on other PCs.

It's coded using TCP/IP and Windows Sockets. PCs are connected using a switch and the switches are backboned to other switches.

Communication works well with other PCs on the same switch, but becomes inconsistent when receiving packets from PCs on other switches.

Adding switches and PCs degrades communication.

I didn't write the program and I'm not an expert on Sockets programming but I have to find a solution.
Whether it's improving the existing TCP code or some other method of communication altogether.

What I'm looking for is suggestions on what to look for in the existing code. I know sockets programming well enough to find my way around it and debug it.

If it's coded correctly, doesn't TCP/IP have guaranteed delivery? Is degradation to be expected when the number of PCs increases? Is there anything that can be done to improve/overcome this problem?

Question by:trishm
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Author Comment

ID: 6161378
BTW: I prefer improving the existing sockets code versus changing the communication method altogether. (If it's possible).
LVL 32

Expert Comment

ID: 6161841
You frame the question in generalities (degrades, becomes inconsistent) but you ask for specific recommendations.  Not really likely...

>>doesn't TCP/IP have guaranteed delivery?

No, that's impossible.  But the SENDER will know if the connection failed if using TCP vs. UDP.

>>Is degradation to be expected

Of course.  You have an increasing number of consumers (i.e. client PCs) competing for a finite resource (the available network bandwidth).  You will get performance degradation with greater demands on the network.

>>Is there anything that can be done to improve/overcome this problem

Lots of things.  Increase the bandwidth of the network, split the network into subnets, add additional network connections between heavily loaded segments, choose a different network technology that give better high load performance (i.e. token ring).  There are entire book on this stuff...

Expert Comment

ID: 6163058
TCP/IP is a stream based connection. The stream will either get to the recipient or else, as JKR says, the connection will be broken and both parties will know about this.

However one major error frequently made is assumptions when sending/recieveing blocks of data. Specifically it is wrong to assume that send/recv will either fail or successfully send/recv all your required data. Let me clarify...

When sending large amounts of data over a poor connection it is likely that the internal send buffers become full, in which case send() will return how many bytes it actually managed to send (or even 0). You must then wait and call send again to send the remaining data.

Similarly when recieving data over a poor connection recv can only return data that has actually arrived (obvious I know). Hence recv() may return less bytes than you expect. Again you should wait and then recv some more.

 PC1 sends 5000 bytes with send()
 PC2 calls recv() and yet only gets 4000bytes
 PC2 examines the data and realises it is incomplete.
 PC2 then waits a bit and calls recv() again to get the remaining 1000 bytes


NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.


Author Comment

ID: 6164519
Thank you both for your informative comments!


You're right. I did ask general questions. I wasn't 100% sure about what to ask.

>>But the SENDER will know if the connection failed ...

How will the SENDER know?

>>Increase the bandwidth of the network, split the network into subnets, add additional network connections between heavily loaded segments ...

Would you elaborate a little bit on each of these?


>>The stream will either get to the recipient or else,
the connection will be broken and both parties will know about this.

How will both parties know that the connection has broken?

LVL 32

Accepted Solution

jhance earned 1200 total points
ID: 6164748
>>How will the SENDER know?

There are two possibilities and usually BOTH should be used:

1) A "broken" socket will return an error to the application that is using it.  Have you ever been using a network application and seen the "connection reset by peer" message?  This is one indication that the network has failed.  There are other possible messages.

2) Any "robust" network client/server setup will include whatever mechanism is needed to get the confirmation needed.  For example after each network send the receiver can acknowledge receipt.  If the sender doesn't receive an error but doesn't get a confirmation, it can resend.  This is NOT handled at the TCPIP protocol level but is handled by the application itself.

>>Increase the bandwidth of the network,

If your network is 10M bps, then that is the maximum bandwidth.  Under NO circumstances can you pump more than 10M bps over such a network.  If you upgrade your hardware to 100BaseT, now you have 10X the bandwidth.

>>split the network into subnets,

Without subnets, every host on the network sees all the traffic.  If A and B are talking, then there is a limit on communications betwen C and D since they share the same "road" so to speak.  But if the network is segmented via routers and switches (as opposed to hubs) then C and D never see A -> B traffic since these machines are on different subnets and the router or switch doesn't pass traffic for B onto C and D's network.  So A and B as well as C and D each have full access to their own networks.  It's only when traffic crosses segments that bandwidth is lost due to this and by careful design of the segments and routes, you can minimize this.

>>add additional network connections between heavily loaded segments ...

If A and B talk to each other a lot, it may be advantageous to add a 2nd network port to each machine and install a dedicated or additional network link between the two.  You can then change the routing priority so that A and B only talk to each other via their "private" link and all other hosts talk to either of them via their public ports.  This is quite commonly done when you have multi-tier server systems where there may be a large amount of traffic between a web server and a database server that implement a system.  Since it is intended that the web server and the database server will be communicating a lot, it may make sense to dedicate a network path for their exclusive use.


Author Comment

ID: 6165102
Great! Thank you very much!


Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question