1

I know that there are many similar questions on this.

I have a UPC router / gateway at home. If I am transferring files via SCP or FTP from one pc to another just on my local network, does this data need to go through my router? or can it not be simply transferred from pc to pc?

The terms gateway and router can be misunderstood, as they involve connecting different networks together.

When transferring data from one computer to another on the same LAN and subnet, my guess is this data must go to the router first, then the router identifies that the IP address is local, gets the MAC address and sends it to the other local pc.

If i'm right on the last point, is there no way to do a direct pc to pc transfer instead of this?

Engineer999
  • 193
  • 1
  • 1
  • 10
  • *Does traffic on the same LAN and subnet travel through the router / switch* If a router acts as a bridge, and PCs posesses in different branches, then yes. otherwise no. Through the switch (including router's switch part) - yes. – Akina Sep 09 '19 at 19:52

4 Answers4

1

Assuming you have the computers connected to a switch, and that switch connects to a router -

In order for the PCs to be able to talk to anything they need IPs in the same subnet. These can be manually configured or use fallback IPs, but typically these will be assigned by the router. This, of-course involves sending traffic to the router. Depending on how the transfer is initiated the router may also be used in helping the machines find each other by name (but not usually).

To actually transfer the data between devices, data will go through the switch but not to the router. The systems will find each other because they are both in the same IP range as defined by the IP address and subnet. (That's why subnets exist). At a low level this is done by the computer broadcasting "an ARP reques for an IP" which is picked up by all devices on the LAN, and the system with the appropriate IP address responds with its MAC address - after this the 2 systems know his to find each other.

As mentioned, it may be possible to simply connect 2 PCs together using a regular cable (for gigabit connections) or a crossover cable will work, assuming you solve the IP addressing problem and the name resolution question.

davidgo
  • 68,623
  • 13
  • 106
  • 163
  • 1
    "As mentioned, it may be possible to simply connect 2 PCs together using a regular cable (for gigabit connections)" - exactly. Just to add that *only one NIC* needs Gigabit Ethernet to guarantee this will work. The other NIC could even be an ancient relic from the 1980s and it wouldn't be a problem! – Mr Ethernet Sep 11 '19 at 00:56
0

A router is a box with two network adapters, one connecting inward and the other usually connecting out to the internet (or to some other router).

When all computers are connected to the router as their only common point, then local LAN messages will pass only through the one inner interface, so the router will function more efficiently than if the communication was with the internet and needed to pass from the inner interface to the outer.

For direct connection, you will need to connect an Ethernet cable between the computers, or in the case of WiFi create a Access Point on one of the computers.

Both solutions, if you wish to keep the connection to the router and the internet at the same time as connecting directly the two computers, will require two network adapters on each computer, which is a bit heavy. You may also need to attribute static IP to the two adapters, if one of the participating computers doesn't have a DHCP server (which is the likeliest situation). It is also unclear what the performance gain will be (if any).

Last remark: For direct Ethernet connection you will need what is called a cross-over cable which avoids the need for a router. Modern good-quality cables/NICs adapt automatically and can serve for both purposes.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • 2
    "For direct Ethernet connection you will need what is called a cross-over cable." No he won't. That was true many years ago but not anymore. Auto MDI-X support is fairly standard in modern NICs, and only *one* of them needs to have it in order for a direct connection to work with a regular network cable. – Mr Ethernet Sep 09 '19 at 19:51
  • 1
    @wrecclesham: As written above. Clarified. – harrymc Sep 09 '19 at 19:52
  • +1. However for direct connections, you might want to add that the fact the DHCP server is likely bypassed. Therefore proper manual TCPIP information needs to be entered into each computer. – Keltari Sep 09 '19 at 20:34
  • @Keltari "likely bypassed"? If the router is unplugged, it's *definitely* bypassed! The good news is that that's a non-issue, thanks to APIPA. – Mr Ethernet Sep 09 '19 at 20:37
  • @wrecclesham You are assuming the DHCP server is on the router. While ***likely*** it is not guaranteed. You know what they say about making assumptions.... – Keltari Sep 09 '19 at 20:41
  • I added the part about DHCP. Thanks. – harrymc Sep 10 '19 at 07:32
  • @Keltari Think about it. If you directly connect two Ethernet cards together with a single network cable, *whatever* previous DHCP server they were using, whether it was on the router or some other network device on the LAN, is no longer accessible to either NIC. In the absence of a DHCP server, APIPA takes over as a fallback and the NICs self assign IP addresses, to restore a basic level of connectivity. That's all there is to it. What do you mean by "while *likely* is not guaranteed?" How can a PC's wired NIC reach a DHCP server if it's *only* directly connected to another DHCP client? – Mr Ethernet Sep 11 '19 at 00:42
  • @wrecclesham OK, lets take this further. We are assuming a DHCP server is involved. This was never mentioned. The IP addressed could be static on different subnets. APIPA addresses would not be assigned and the machines would not talk to each other. Additionally, we are *assuming* TCPIP is the protocol, that was not specifically mentioned. While these are probably the case, they are ***NOT*** absolute facts. You can only provide a definitive answer with the information given. Yes, assumptions can be made, but those assumptions are not always correct. – Keltari Sep 11 '19 at 01:03
  • @Keltari It's important to understand the context of a question. This is described as a *home* network. "I have a UPC router / gateway *at home*". If this was a corporate network, sure, different subnets could be expected, but the odds of a regular *home* user intentionally putting his PCs on different subnets is vanishingly small. We can always deal with that remote possibility if we come to it. There's maybe a 90% chance he's using DHCP, a 9.999999% chance he's using static, and maybe 0.000001% chance he's using static IPs on *different subnets*! – Mr Ethernet Sep 11 '19 at 01:24
  • @wrecclesham There you go making assumptions again. I run a home based router, but run my own DNS and DHCP server. I also have different subnets, hardcode several IPs , and more. Just because it is common that does not make it the case. Just because something is likely, doesnt mean it *is*. – Keltari Sep 11 '19 at 06:31
  • @Keltari you're not the OP. This is for his configuration, not yours. – Mr Ethernet Sep 11 '19 at 06:33
  • @wrecclesham ***EXACTLY*** he never specified all the details. Therefore, YOU dont know what the facts are. – Keltari Sep 11 '19 at 06:35
  • @Keltari the OP himself said "...on the same LAN *and subnet*". It appears the PCs, whether using DHCP or static IPs, are on the same subnet. Someone with enough networking knowledge to set up multiple subnets on their home network wouldn't be asking this in the first place! I agree with you about generally trying to avoid assumptions but some assumptions are just the product of common sense. If I'm wrong, I'll eat my hat! – Mr Ethernet Sep 11 '19 at 06:50
0

Can it not be simply transferred from PC to PC?

The answer is simple: yes!

Direct PC-to-PC data transfer via a single Ethernet cable is 100% fine.

If i'm right on the last point, is there no way to do a direct pc to pc transfer instead of this?

This is easy to do and requires no special configuration or hardware.

You (almost) certainly won't need a crossover cable, you definitely don't need a wireless router and you don't need to manually assign static IP addresses either.

APIPA automatically handles IP address assignments in the absence of a DHCP server, while auto MDI-X automatically handles the lack of a crossover cable.

All Gigabit Ethernet NICs have auto MDI-X support!

Let's get started:

  1. Connect your two computers directly together using a regular network cable.
  2. Run ipconfig in Command Prompt on each PC, to see what APIPA (Automatic Private IP Addressing) address they each automatically assign themselves. If this step fails, then you need a crossover cable, but it's unlikely. APIPA addresses are easily recognized as they are always in the format: 169.254.x.x.
  3. You can now access your network shares directly, either by IP address or hostname, just as if the PCs were connected conventionally using a switch or router.

enter image description here

Mr Ethernet
  • 4,191
  • 2
  • 16
  • 28
  • APIPA = OS agnostic? => Linux / AVAHI – Hannu Sep 09 '19 at 20:14
  • Good question. Macs apparently also use APIPA. Linux has an implementation called AVAHI which also assigns the same first two octets of 169.254.x.x. I only have experience of actually using it in Windows though. – Mr Ethernet Sep 09 '19 at 20:22
  • I read "Avahi provides similar functionality to Bonjour or Rendezvous for Linux", somewhere... – Hannu Sep 09 '19 at 20:36
  • "avahi-autoipd implements IPv4LL... It is primarily intended to be used in ad-hoc networks which lack a DHCP server." https://linux.die.net/man/8/avahi-autoipd – Mr Ethernet Sep 09 '19 at 20:39
  • Apparently; zeroconf <-> Apple Bonjour <-> Rendezvous - hmm... need to look further. – Hannu Sep 09 '19 at 20:48
  • @Hannu it's a good question. It's worth mentioning that the OP is specifically asking about directly connecting two PCs, rather than computers *in general*. So it should at least work for him! – Mr Ethernet Sep 11 '19 at 01:05
-1

Yes and no, but mostly no. They will go through switches (because how else will the signals travel from device to device?) but they will not go through any router (because they're in the same subnet).

Usually, "same subnet" by definition means that the other host is accessible directly through the local ethernet, without going through any router/gateway system.

In other words, PC1 can directly query ARP for PC2's MAC address, and the packets can be directly addressed from the source device to the target device's MAC.

Both hosts can determine whether their peer is local simply by using the "subnet mask" configured in them. (Depending on the router to identify this would kinda defeat the point...)

The terms gateway and router can be misunderstood, as they involve connecting different networks together.

The packets may go through the built-in switch that a home router most likely has (depending on whether that is the shortest path), but as they're sent directly to the target device's MAC and not to the router's MAC, they won't actually be seen by the router's main OS at all.

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966