Where I teach, if a teacher just needs one class period off, we try to fill the sub in-house so we don't have to pay a sub for a half day, instead only an hourly wage for an hour. I was asked a couple months ago to sub for a teacher during one of my prep periods. It was his last hour of the day and he warned me up front that it would be hard to keep them in line. "They're a handful," he said, "don't be worried if you can't get them to pay attention."
I went into that class expecting the worst.
Which..they definitely weren't angels..but they weren't the worst either.
I have a method that I use in my own class that works really well. Any time I am trying to talk and the other students are talking or goofing around, I stare at the clock. This is my nonverbal way of letting the kids know that they are wasting time. They are very aware that if they waste too much time (usually more than 30 seconds in a class period) then they will start to owe me that time after class.
I applied this to the class I subbed for and it worked like a charm. They were very squirrely and I had a hard time getting a few words in at a time. So I started watching the clock. The first time it took them about 45 seconds to notice I was now silent and looking at the clock. Once it was quiet, I calmly said, "You just wasted 45 seconds of my and your time." I then kept going with what we were doing. I had to do it again a few minutes later, but only for about 15 seconds. By the end of the period, the kids were paying attention to me (for the most part). It's amazing how much a little non-verbal communication can change the attitude of the students.