Previous: Tutorial: 3. Create our src-port and dst-port
To easily create a Frame, we use a procedure which is available in our excentis_basic
package. This procedure will generate the bytes of our frame that we can set on our Frame. First we need to resolve our destination Mac address. Following snippet will send an ARP request from our source port to resolve the Mac address.
Protocol.Arp will have as effect the transmission of an ARP packet to resolve the destination. It will return the resolved Mac address.
If it fails, it will throw an exception. Now that we have our destination Mac address, we can generate the bytes of our Frame. We will create an UDP frame of length 64Bytes ( incl Ethernet FCS ) between UDP port 2001 and 2002.
First, we define our Frame content settings:
Now, we can generate the actual Frame content:
As you can see, Layer2 and Layer3 settings are obtained from the current settings of the source and destination port. The destination Mac address is the one we just resolved.
This line of code will return the string representation of the bytes of our frame. If you want to provide UDP content you could create your frame this way
where 0xAA
0xBB
0xCC
0xDD
represents the UDP payload
Further reading: Tutorial: 5. Define a Flow