Subscribe to Grim's Projects        RSS Feed
-----

Crossover Cable Network File Transfer

Icon Leave Comment
Introduction

So here's the situation. I'm currently running Linux on a variety of machines. I only have one machine running Windows XP because it has a handful of programs (more like one) that I make use of. I have a tower that has a 250 GB drive, and a laptop that has a 20 GB drive. They're both older computers but they run Linux just fine. My laptop's drive was getting filled with data, whereas my tower has nothing but extra space laying around. I didn't really feel like using an external drive, rather I wanted to link the two computers via network and transfer the files that way. That's where the journey begins.

Transferring files between computers on Linux is both easy and complex. It's easy in the sense that Linux networking these days takes care of itself and the operations for transferring files to and fro is pretty straightforward. It's complex in the sense that there are a myriad of ways to do it. I'll name a few so you can get an idea:
  • SSH
  • rsync
  • FTP
  • TCP
  • UDP
  • samba
  • nitroshare
  • Fast Data Transfer
  • SCP
  • netcat


Constraints

A lot of these overlap, and/or build on one another, or use similar protocols, etc. There are also far too many tutorials and such on the web. It's a library's worth of information to pour through. A lot of tutorials online are also using older applications, which wouldn't apply to my situation as all my Linux machines use Arch (which uses newer applications). My parameters were to do it the simplest way possible, with minimal fuss (meaning setups/configs/installs), using up to date applications, and ignoring all manner of security protocols because it's two machines that are physically linked together by a cable without any other network access of any sort.

Rationale

The more complex ways were SSH, samba/nitroshare, FTP/TCP/UDP/SCP, because these involved tinkering with configuration files and knowledge of certain Linux commands. Not to mention also setting up applications on both ends that might involve a complex server/client model (as in samba or FTP). OK some of these aren't that complex either, but I was fairly certain there was an easier way.

The simplest way I found was using the netcat application. Typically, you can find netcat available by default on a lot of distros, and transferring files with it is a breeze. The commands are a tad on the cryptic side, but then again, in the shell what isn't? I avoided netcat because I couldn't decide which version to install, GNU or OpenBSD. From my readings online there were a couple of discrepancies with parameter settings.

I decided on a command line application called Fast Data Transfer (though I'm not entirely sure that's its name, moreso what it does). Of primary note, it's coded in Java, which I'm a fan of, and both of my machines have Java installed. It's simple to use, and the application doubles as server/client. It's pretty damned fast given my computers' ages (~ 4 G transferred in 5 minutes or so).

Prerequisites

Hardware:
  • 2 computers with a functional ethernet port
  • Cat5e crossover cable

Software (Arch Linux specific packages named):
  • iproute2
  • jre7-openjdk-headless
  • iputils


Definitions

The computer which has the files you wish to transfer is denoted as the SERVER. The computer which will receive the files is called the CLIENT.

Physical Setup

Connect both computers via their respective ethernet ports using the crossover cable. Power them on, log in as the root user.

SERVER Setup

On the server computer, open a terminal window or shell and type the following:
ip addr
and then look for the ethernet device name. It can typically be found by looking for an output line that starts with link/ether, the antecedent numbered line shows the device name. In the case of my machine it is called "enp0s20". Now type the following (replace enp0s20 with YOUR device's name):
ip addr flush dev enp0s20
ip link set enp0s20 up
ip addr add 10.0.0.1 peer 10.0.0.2 dev enp0s20
This sequence of commands will flush any addresses on the ethernet port, disable it, assign a new IP address of 10.0.0.1 to the port and (re)enable it. We will follow a similar command scheme for the CLIENT machine.

CLIENT Setup

Determine your ethernet device name on the client machine (it may not be the same as the server's). On my machine the name is different, it's "eth0". Type the following commands:
ip addr flush dev eth0
ip link set eth0 up
ip addr add 10.0.0.2 peer 10.0.0.1 dev eth0


Test Connectivity

To ensure that the computer's are communicating with one another use the following on the SERVER computer:
ping -c 3 10.0.0.2

On the CLIENT computer use the following:
ping -c 3 10.0.0.1

Assuming the ping application does not return some form of network connectivity error, then the two computers are now aware of each other. Sometimes there is a delay on reenabling the ethernet ports, to be sure the ethernet ports are in fact active, use:
ip addr
On either computer the line with the device name should indicate UP near the end of the line, if the device is in fact operational.

Transferring Files

On the SERVER computer, navigate to the directory where you downloaded the Fast Data Transfer application's JAR file, and execute the following command:
java -jar fdt.jar -S

The SERVER computer is now ready to send files to the CLIENT computer.

On the CLIENT computer navigate to the directory where you downloaded the Fast Data Transfer application's JAR file (yes the application needs to be present on BOTH computers). Execute the following comand:
java -jar fdt.jar -pull -r -c 10.0.0.1 -d /home/user/CLIENTdir /home/user/SERVERdir

Here I've used /home/user/CLIENTdir to denote the directory on the CLIENT computer where you wish to save the transferred files. I've used /home/user/SERVERdir/ to denote the directory on the SERVER computer that you wish to transfer to the client. You would need to change these values to match whatever directory structure you intend to use.

You should see a series of cryptic output messages, but of most importance will be the final message(s) that indicate a successful transfer or some error (should the transfer fail).

Keep In Mind

The choice of IP addresses 10.0.0.1 and 10.0.0.2 are completely arbitrary, you can use whichever suits you. The peer is used in conjuction with the ip addr command to denote a point to point communication between two computers. Wherein, the peer is the IP address of the other computer, respectively.

Conclusion

As you can see, there are a few steps to be followed. Fortunately, the steps are fairly similar. The first time around it is a fairly foreign procedure to follow. After a couple of goes it should start to make some sense what's going on. The most difficult part is establishing functional communication between both computers.

Further Information

Fast Data Transfer Examples - Further usage examples of FDT
Internet Sharing (ArchWiki) - Describes a procedure for crossover cables between two computers

0 Comments On This Entry