How to deal with the frustration of doing PhD at a low-ranked university
Stop whining and start kicking ass.

Work hard with faculty (and undergrads!) that you respect, do some awesome research, and then (if you are very lucky) move to a better department, either as a PhD student, a postdoc, or even a faculty member.

Meanwhile, own your past mistakes, but forgive yourself for them.  You put yourself in this situation, but holding onto your frustration and loneliness, instead of doing the best with what you have now, is only going to keep you frustrated and lonely.

(My undergrad GPA was 2.4/4.0.)