Given only two hosts:
- A hub or unmanaged switch will be mostly invisible.
- A managed switch and a router will have a MAC address on the interface. If it
is an IP network, these devices will appear as a "hop" in a
Traceroute. From the MAC, you can get some information about the manufacturer
I'm not sure what you mean by "gateway." My understanding is that a gateway is just a role for a router to play. In this case, a router is detected like above.
If your managed switches and routers have SNMP available, you can query these devices to find out a plethora of data about the make/model/type of device.
I said "mostly" invisible above because, theoretically, there is a minuscule latency added to the packet traversal. However, given only two hosts, this latency would be next to impossible to detect.