I'm implementing a discovery mechanism to find out VLAN Id
to tag the packet, i.e. a client device plugs in the network and it does not know the VLAN Id
beforehand, all it knows is that it is connected to a trunk port of the L2 switch and that there is a DHCP
server behind the switch.
So I'm considering to do the following:
- vid=2
- open
SOCK_RAW
socket forIPPROTO_UDP
protocol - construct a
DHCPDISCOVER
packet with the Ethernet header having VID=$vid - send the packet
- wait for response. If received the response, parse the Ethernet header, extract vlan ID, and configure the interface (e.g. create VLAN sub-interface). Done.
- if no response, increment vid and go to step 2)
My question is: does it matter if I send every packet in its own thread, or I could simply do it in a loop, executing e.g. send_dhcp(...)
4K times?