This is very simple:
For ipv4 :
Mac adress has to start with 01:00:5E the 01 in binary gives 00000001 the the lowest bit of the hihgest byte give multicast or not. This is the first bit received by network card so then can quickly ignore or not multicast packet
So you have 01:00:5E:XX:YY:ZZ the range of available mac adresses goes from 01:00:5e:00:00:00 to 01:00:5e:7f:ff:ff
So you have 23 bits to complete with the 23 lowest bits of the ipv4 adresses
IPV4 adresses multicast go from 224.0.0.0 to 239.255.255.255
So for example OSPF (well know routing protocol) use these ipv4 adresses :
- 224.0.0.5 that give 01:00:5E:00:00:05
- 224.0.0.6 that give 01:00:5E:00:00:06
For ipv6 : ipv6 adress are ff00::/8
You use mac prefix 33:33:XX:YY:ZZ (remark the lowest bit of the highest bytes is 1) and you complete by the lowest bytes of ipv6 adress