Date: 201910
Local time of day: 1801-2400
Location: ZZZ.Airport, US
Flight conditions: VMC
Weather elements / visibility: 10
Light: Dusk
Aircraft: Light Sport Aircraft
Operator: Personal
Operating under: Part 91
Flight plan: VFR
Mission: Personal
Flight phase: Cruise
Airspace: Class B ZZZ3; Class D ZZZ
Reporter organization: Personal
Reporter function: Single Pilot; Pilot Flying
Reporter qualification: Flight Crew Private
Human factors: Situational Awareness; Time Pressure
Anomaly: Airspace Violation All Types; Conflict Airborne Conflict; Deviation / Discrepancy - Procedural Clearance; Deviation / Discrepancy - Procedural Published Material / Policy
Detector: Person Flight Crew
When detected: In-flight
Result: Air Traffic Control Provided Assistance; Flight Crew Took Evasive Action; Flight Crew FLC complied w / Automation / Advisory
Contributing factors: Aircraft; Airspace Structure; Human Factors
Primary problem: Aircraft

Narrative: I was cruising at 3;800 ft. under the Class B airspace on a flight plan leg from ZZZ1 to ZZZ2 that passes approximately 1.5 miles to the west of the ZZZ Class D. The Class B floor at this segment is 4;000 ft.; and the ZZZ class D ceiling is 3;900 ft.While proceeding along this leg; the ADS-B display on my Garmin G3X indicated an aircraft approaching from behind at a speed faster than my aircraft; and climbing within a few 100 ft. of my altitude. I immediately and instinctively initiated a climbing left turn to take me away from the path of the approaching aircraft. The left turn took me briefly approximately 1/2 mile into the ZZZ airspace; initially just below the class D ceiling; and then my climb took me up through the Class D 3;900 ft. ceiling and above the 4;000 ft. floor into the Class B. I estimate my maximum altitude was 4;150 ft. for a period of less than 1 minute before airspace incursion warnings on the G3X obliged me to turn right - away from ZZZ - and down below the Class B floor. I estimate I was above the Class B 4;000 ft. floor for less than 1 minute; and inside ZZZ Class D also for about 1 minute.During this brief period I was watching the approaching aircraft on the ADS-B display and watched the aircraft pass to the right at an estimated distance of 1 - 2 miles. Once I was back on track at a legal altitude; I contacted ZZZ Tower to apologize for and explain the brief incursion; the ZZZ Controller kindly confirmed there was not a problem; and that he had also seen the traffic approaching me from the rear. Rather than try to contact ZZZ3 Approach in flight; I resolved to call the Tower on landing. (I had to leave a voice message and intend to call again tomorrow morning.)Whereas it is highly regrettable to enter controlled airspace with permission at any time; I do believe my immediate and instinctive collision avoidance maneuver was appropriate and instrumental in avoiding a potential collision. However; if such a situation arises again in the future; I would try to do a better job of determining a better action that would keep me away from controlled airspace. In this particular example; a descending right turn away from ZZZ; and keeping me below the Class B; might have been a better option. The G3X does a good job of depicting the relative altitude and relative track of other aircraft; and also will display the N-number of aircraft that are fully ADS-B compliant. If I remember this very sudden incident correctly; the other aircraft's N-number as not displayed; and the relative track was also not fully clear; indicating that the other aircraft was probably not yet fully ADS-B equipped.




Synopsis: Light Sport pilot reported they violated Class D and Class B airspace to avoid a faster moving aircraft.