1

Please go easy on me as I'm just a noob in the networking space.

As far as I have learnt, layer 2 protocols use MAC addresses for communication, which doesn't really depend on what network you're in or if you're in a network at all. So my question is, just by being physically adjacent in the real world, can two hosts send each other data, in some form, even if it means communicating via low level frames?

EDIT:

As a clarification, I would like to add that I come here from the assumption that wireless communication is just electromagnetic waves, which a network card should be able to decode. So, can't we just sort of "broadcast" a frame like "MAC Address ABCD here, I wanted to talk to EFGH, and say 'Hello!' ", and if EFGH is nearby it would decode the frame, and instead of dropping it, it could just acknowledge and have conversations like that. What I'm trying to say is, can we have two network card bearing devices act like walkie-talkies essentially, without using external peripherals since network cards seem to have this facility already?

Please don't flag this as belonging to superuser or unix, because I want to ask this from a theoretical point of view if layer 2 protocols are capable of such stuff or not, since hardware seems to be already there?

2
  • 1
    "Network" can be a bit of an overloaded term. In one sense, it means e.g. an IP network, what we'd call a layer 3 concept (that layer of course being the "network layer"). In another sense, it can mean a far wider range of things, from cables upwards. A dumb switch is a piece of "network equipment", even if it doesn't do anything on the "network layer". So, what exactly do you mean with "network" here?
    – ilkkachu
    Apr 16, 2021 at 20:07
  • Thanks for replying! By "network", I mean the network in general, i.e computers linked together by any means. Connected together under a Wi-Fi, or connected together indirectly because of Internet. Apr 17, 2021 at 16:20

4 Answers 4

4

layer 2 protocols use MAC addresses for communication, which doesn't really depend on what network you're in or if you're in a network at all.

Oh yes, it does.

A data link layer (L2) network is required for communication, with an underlying physical layer network (L1: interfaces, ports, cabling) as well. The L2 network doesn't necessarily need to use MAC addresses, but it is required all the same.

A given L2 protocol (e.g. Ethernet) can use various L1 protocols (e.g. 100BASE-TX, 1000BASE-SX, 10GBASE-CX), but both layers are usually referred to when talking about "the network" on a low level.

I'm not sure what you mean by "low level frames" - that is exactly what L2 does, organize bytes into frames and make sure those frames get to their local destination (with or without addressing).

For an L2 protocol that doesn't use addressing, take a look at PPP for instance.

Of course, you could create your own network protocol stack, ignoring all that OSI stuff - but the same functions need to actually be somewhere nonetheless.

The only situation when neither L2 nor L1 functionality is required is when the communication is limited to a single host: without a need for addressing and physically moving data, communication between processes can remain limited to L3 upwards.


Re edit about wireless networking: that also requires framing and addressing - hence a layer 2. A MAC address is a property of the data link layer. Yes, you can have conversations on top of layer 2 (=application layer directly on data link layer), wireless or wired.

If you're asking whether a network-layer protocol is always required: no, it isn't, if you only communicate locally (inside a broadcast domain).

So, can't we just sort of "broadcast" a frame like "MAC Address ABCD here, I wanted to talk to EFGH, and say 'Hello!' ", and if EFGH is nearby it would decode the frame, and instead of dropping it, it could just acknowledge and have conversations like that.

That is roughly how Wi-Fi works.

can we have two network card bearing devices act like walkie-talkies essentially, without using external peripherals since network cards seem to have this facility already?

Yes, that's a wireless ad-hoc network.

1

I come here from the assumption that wireless communication is just electromagnetic waves, which a network card should be able to decode.

Well, depends on the card. If you're thinking of taking two computers with regular wired LAN ports (1000BASE-T / Gigabit Ethernet, or what have you), then no, it doesn't really work like that. The physics of sending a signal over the air are a bit different from sending one over a cable (or fiber). So with wired LAN, you need in the least a cable as an external piece of equipment.

On the other hand, if you have WLAN cards (802.11 / Wifi), then you don't need cables, because the hardware is made for over-the-air transmission. Though you do need some setting up, either have one device act as an Access point, or look into ad-hoc networks.

Now, assuming you do that, and can pass Ethernet frames between the hosts(*), what now? We could also ask if this still counts as "without being on a network", or if we just created one.

Even if you don't need routing between networks (one of the main functions of IP and the network layer in general), there's some useful stuff on the layers above it. TCP gives logical connections, multiplexing, and reliable transport. Or UDP for just multiplexing.

Pretty much every existing application also assumes IP (either IPv4 or IPv6), so you're likely to want to set up an IP network anyway, even if it's with something like Zeroconf and mDNS. It's more or less either that, or you build your own software to talk directly over the low-level protocols, and eventually end up building a network stack of your own.

(* I assumed Ethernet there as a somewhat common case. It could of course be something different.)

0

You can connect two computers with an Ethernet cable and they will communicate (just may have to assign IP addresses manually), or you can have two wireless capable devices communicate if they're in wifi range (this is called an ad-hoc network). The communication will still probably happen using TCP/IP protocol stack, since this is what most OS's support. You can bypass the OS if you want (there is a project called DPDK that does exactly that).

0

Without getting into the physics of it, yes, it's all electromagnetic waves, but unless you use certain frequencies, they don't radiate very far. We have network adapters that are designed for this -- we call them WiFi network adapters. What You're probably using one right now on your phone or laptop.

You can use any medium you like -- cables, radio, light, smoke signals, etc. Your adapters need to be compatible with them, however.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.