it seems correct, but it isn't. Of course (otherwise you wouldn't have posted).
Setting the local address twice is a bad idea. Only the first one is correct (since you're installing the Ping application on node 0 of i1).
i3.SetForwarding (1, true);
This should be:
i3.SetForwarding (0, true);
Node 2 is the first one in i3. Since it's the node at the star center, all its interfaces should be forwarding.
There, all working as intended.
However, you'd better double check the source code before posting...
monitor->SerializeToXmlFile("node2", true, true);
Monitor is not defined.
Moreover, the gnuplot part is just plotting an example graph, useless and confusing for whoever was debugging it (I needed a good 5 seconds to figure out it was useless).
Last but not least, I added FlowMonitor to it. Of course it's showing nothing. Zero. No packet traced.
Error? Bug? Nope, a feature.
ICMP isn't tracked by FlowMonitor, so there's nothing to track, and no results.
Hence, before you ask about it... you have to use UDP or TCP to see something tracked by FlowMonitor.
And before you (or someone) ask this one... No, I'm not going to add support to ICMP in FlowMonitor. The reason is: ICMP packets are not a "flow", they're just single packets. There's no real way to say if two ICMP packets are part of a flow, as there's no port in ICMP, and without ports there's no flow.
Cheers,
T.