Sensing and molecular communication using synthetic cells: Theory and algorithms