Integrating the Application layer with VLAN layer
From the documentation, it looks like the socketCommandProcessor, SocketPacketProcessor, and SocketTable modules can be enabled in order to allow the application layer to directly set VLAN tags. However, the documentation for these modules is sparse. I was wondering if anyone could guide me on how to use them, or point me to a resource which can help me out.
In particular, there doesnt seem to be any information on what string format the socketTable uses as an input
The socket modules can be enabled in Ieee8021qProtocol with the hasSocketSupport parameter. These modules can be used together with the Ieee8021qSocket in the application, but it would mean that your application directly talks to the IEEE 802.1Q protocol bypassing all other protocols. I'm not sure if that's what you need though.
Hi @levy , thanks for the response. Essentially, I want to simulate 2 UDP applications running on a single device, with each application having a unique VLAN ID. Having read your response, I think I'll probably implement this using the Ieee8021qSocket. Do you recommend of doing this?
No, not really. Since you want to send UDP datagrams your application needs to talk to the UDP protocol. It can be done using the UdpSocket class. Unfortunately, this class does not support setting the Ethernet VLAN id. You should add that functionality similarly to other socket options. Then in the UDP module you should attach a VlanIdReq packet tag if the vlan ID is set on the socket. This is similar to TTL, DSCP, TOS, etc., see the code. The only remaining problem is that the packet should go to IEEE 802.1Q protocol after IPv4, and only after that should it go to the Ethernet protocol. This can be done by attaching an EncapsulationProtocolReq on the packet in the UDP module I think. If you can solve this, it would be nice to get a pull request.
This sounds doable, but Im missing a little bit more implementation details. My first question is how the tagged incoming packets will be sent to the correct sockets. I haven't looked into the SocketPacketProcessor source code too deeply, but do you think I have to make any changes there to make sure the incoming packets are routed correctly?
This sounds doable, but Im missing a little bit more implementation details. My first question is how the tagged incoming packets will be sent to the correct sockets. I haven't looked into the SocketPacketProcessor source code too deeply, but do you think I have to make any changes there to make sure the incoming packets are routed correctly?
In addition to UDP, I'm also interested in looking into implementing running multiple PingApps in the same device, each with their own VLAN ID. I understand that the overall idea would be the same as the UDP apps. I have a rough VLAN-ICMP implementation working using the EncapsulationRequest mechanism, where the ICMP request packet is tagged with the correct VLAN ID when sent from the source mavhine, but the destination machine strips the VLAN ID when it sends the ICMP response. I think I probably need to modify the PacketReverser source code a little to make sure the correct VLAN tags are added back. If you have any specific suggestions for ICMP, I'd be happy to hear it. I would love to open PRs for these features too.
At the receiver the packet is processed according to the protocol encapsulation order, so you don't have to do anything special as long as the receiver app opens the right socket (IP address, port).
Yes, you are right about PingApp, it is pretty much the same. As for the ICMP at the receiver, it's a bit more tricky. The ICMP protocol will produce the ICMP reply packet and it has to be encapsulated with the same vlan ID. This has nothing to do with the PacketReverser module because that one is used by switches when forwarding a packet. For this to work, you should have a bridging layer below the IP layer that takes care of copying the vlan ID from the VlanInd tag to the VlanReq. I think there's no such module right now but it should be similar to the ones in the linklayer/vlan folder.
@levy I have solved the ICMP VLAN issue by doing the following. In the ICMP module, inside processEchoRequest, when the request packet is read, and the ICMP response packet is generated, I check the ICMP request packet for any VlanInd tags. If they exist, I add a VlanReq tag to the outgoing response packet, with the same VLAN ID. I don't think we need a seperate bridge layer just for this.
This solution certainly works but ICMP should not know anything about vlan IDs. So it's not in solved at the right place.