All of the devices you mentioned have firm-ware installed in the device itself.
Depending on what functions the device has, the more involved the firm-ware will be.
A home grade cable / DSL router is a good place to start. These all have web page based user interfaces that are used to set the options of the device. Just type in the IP address of your router, and you can see the software in action.
Older devices have the firm-ware in a ROM, and cannot be easily updated.
As Flash memory prices have fallen, most new equipment has it's firm-ware stored in Flash memory. This makes it easy to update or even upgrade the firm-ware in the field.
If you want to dig into this further, there are several chapter downloads from Cisco books here at TR that can get you started.
You can also sing up at the Cisco web site and get information on their router and switch software.
Chas