Date: 202106
Local time of day: 1201-1800
Location: ZZZ.Airport, US
Flight conditions: VMC
Weather elements / visibility: Turbulence; 10
Light: Daylight
Aircraft: Skyhawk 172/Cutlass 172
Operator: Personal
Operating under: Part 91
Flight plan: None
Mission: Personal
Flight phase: Climb
Airspace: Class B ZZZ; Class E ZZZ
Aircraft component: Engine
Component problem: Malfunctioning
Reporter organization: Personal
Reporter function: Single Pilot; Pilot Flying
Reporter qualification: Flight Crew Instrument; Flight Crew Multiengine; Flight Crew Flight Instructor
Human factors: Situational Awareness; Troubleshooting; Communication Breakdown; Distraction
Anomaly: Aircraft Equipment Problem Less Severe; Airspace Violation All Types; Deviation / Discrepancy - Procedural Published Material / Policy; Deviation / Discrepancy - Procedural FAR
Result: Flight Crew Exited Penetrated Airspace; Flight Crew Overcame Equipment Problem; General Maintenance Action
Contributing factors: Aircraft; Human Factors
Primary problem: Aircraft

Narrative: On Date at ZZZ airport; I fueled the airplane; conducted a preflight (includes checking oil quantity and taking a sample of all three fuel sumps); reviewed my direct course back home and updated my weather (VMC) for the short flight to ZZZ1. During the pre-takeoff checklist (engine run up); I notice a slight roughness in the engine. I leaned out the mixture control which cleared out the roughness. I set the mixture control for my takeoff; but not to full rich. I left it leaned out a little for the departure and climb. During my climbout; I always look for off airport landing spots (should I need one). I did not see any good locations and I told myself that I want 4;500 feet once clear of the Class B airspace altitudes. It was shortly after my desire to get to 4;500 feet MSL ASAP that the engine was not performing as it should in cruise climb. I applied full power and checked the engine instruments (all green; but RPM was towards the low end). I was getting a shallow climb at an airspeed of about 90. I then immediately performed the initial emergency procedure; carb heat on; mixture full (then adjust if needed) and check fuel selector on both. That seemed to bring the performance back; but not immediately. Shortly after that the engine then started to run rough. My thought was spark plug fouling or magneto (I know it was not a cylinder failure; because I have experienced that in a twin engine airplane). I adjusted the mixture control first. This is logical; because if you check the mags before the mixture control you could increase spark plug fowling. At some point through all this my mind went into altitude; altitude; altitude. Unfortunately; I had that 4;500 feet MSL in my mind. While dealing with the engine situation; I continued my climb to that altitude. I got the rough running engine cleared out.  Once I was done keeping the airplane in the air (dealing with low performance and then the rough running engine during the cruise climb phase); I checked my position and noticed that I was in ZZZ3 Class B airspace (west end of and close to the 6;000 feet MSL corridor; but I was in the 4;000 feet MSL corridor). I immediately descended below 4;000 feet MSL (3;800 feet MSL). Once clear of the Class B airspace/Mode C veil; I climbed back to 4;500 feet MSL. No airplane conflicts were noted. Once on the ground at the ZZZ1; I performed an engine runup and checked the mags full and leaned mixture settings. Both checked out okay. My plan is to check the oil; fuel and talk with a mechanic. I am confident that the fuel is okay since I checked it after fueling at the ZZZ (but I will check it again). I have cancelled my planned flying for the next week and no flying the Skyhawk until the items are checked out. Once I got home; I chair flew the scenario that I just experienced and realized that all my training and personal home chair flying has been geared to multi-engine; on an IFR flight plan and in radio communications. My scenario was single engine; VFR and not in communication. Do not get me wrong; I always review the emergency procedures before a flight for the airplane that I am flying. Also; the poor engine performance that I experienced did not seem to be carb icing. Since the air filter and bracket were replaced at the annual inspection; the carb air intake system will be looked at. What I learned and what I will do going forward so that this does not happen again:I learned that in my continued personal chair flying training that I need to go over single engine emergency; VFR and not in communications scenarios. This situation reinforced with me that single engine performance (VFR; non-communications) incidents come with a high workload especially when dealing with keeping the airplane in the air. It showed me that I became focused on keeping the plane in the air (altitude and rectifying the engine situation) and that navigating and communicating was lacking with this incident.   Going forward; in addition to reading theemergency procedures that I currently do for every plane that I fly and chair flying multi-engine scenarios; I will chair fly single engine (SE) scenarios. I need to emphasize aviate; navigate; and communicate in any SE situation. When flying under Class B airspace and within a Mode C veil do the following:1.	Obtain flight following when flying VFR; especially when flying in a Mode C veil. I would already be in communications should I need to report a problem.  2.	Mark along the course line a line with an arrow from the departure airport to the point when the plane will be cleared of the Mode C veil. Also; put a B next to this manually drawn line.3.	Apply a post-it-note on the instrument panel that I am in a Mode C veil airspace.I will talk to my Flight Instructor and review this flight to obtain feedback and discuss my ideas and additional ways to prevent this from happening again.




Synopsis: C172 pilot reported an airspace incursion occurred when the engine began running rough and the pilot was troubleshooting. The roughness eventually dissipated and pilot exited the airspace.