peugeot 307 diesel

i have got a peugeot 307  sw diesel.sometimes when im driving the engine makes a louder

clattering noise than it does at other times.it can happen any time when engine is hot or cold. can anyone help