if rubjonny's treatment doesn't work (or even if it does) check the cable coming from the knock sensor on the front of the block. If its the original sensor, it might need replaced. The cable coming from it is a shielded, coax type and if the shielding or insulation is split, it wont be sending the correct signal to the ecu. Mine used to rattle pretty bad and I got a new one from bosch for about £40 which sorted it. Only rattles the odd time now, on hot days at low engine speed on wot.