A knife is probably better than nothing, as most have said, a stick might work better.
In case you don't have anything (I can imagine you don't want to walk continuously with a stick and you could unexpectedly face a dog).
Whenever you get caught by a dog and he is near, two good things to do are: poke in their eyes, or hit as hard as you can on their nose ...
Most of the times the hikers might be more afraid of the owners having big dogs than the dogs themselves.
So (if you at least want this), make yourself and/or the dogs as least aggressive looking as possible. Maybe by putting some funny accessory on the dogs, or the leash, or on yourself.
If you look like a macho guy with some macho dogs, than less macho ...
Most things already have been said above.
What I can add is that if you find a tree, a dog can stay there for very long time.
A (domestic) dog we had once sat an entire day under a tree because of a cat.
I'm sure in a real situation you're not going to search for a 'comfortable' tree, but the most nearest tree, but it might be useful if possible to go to ...