Hi, thank you for contacting JustAnswer.com. My name is Russell. I will do my best to provide the right answer to your question.
It could be the cable, both at either end, and anywhere along its length.
Check first the ends, whether they are slipping out (which happens when the latch breaks off a cable, and there is any stress, even minute, on the cables that could pull them loose.)
That's unlikely, but check for it. After that, check the cable along its length, think about how often you have coiled and uncoiled or bent it, whether there might be a puncture along its length, and whether it passes near any
A. other wires
B. major appliances, or minor one with a motor in them.
If 'no' to all that, you might just have to replace it, if the cable was cheaper rather than more expensive. Or at minimum swap it with another of similar or greater length, for a temporary test or a long-term repair (if the test turns out favorably and the length disparity isn't objectionable - if it were, replace it with a new one.)
Then try connecting the cable (if the above does not cure the problem) to a different port on the router or switch.
After that, if the disconnection still happens, it's either
1. the software on your computer - which if infected with malware, can cause just this sort of problem.
2. the network adapter itself, in the computer.