AS_PATH lists every AS a route has traversed. It's mandatory in every UPDATE.
How it works: When AS originates , the AS_PATH is []. When AS sends this to AS , it becomes [, ].
purposes:
Loop prevention. If you see your own ASN in the path, reject the route.
Path length metric. Shorter AS_PATH often wins.
AS_PATH prepending: Artificially lengthen your AS_PATH by repeating your ASN. This makes a route less attractive.