Table of contents
- Simple signals
- Changing the order of participants
- Actors
- Signal to self
- Expressing loops and conditionals
- Notes in the diagram
- States
- Lifeline activation and destruction
- Including saved diagrams in other diagrams
- Referencing other sequences
- Parallel sequences
- Automatic numbering
- Changing the bottom of participants
Simple signals
Draw a signal from one participant to another like this. The participants are automatically created when they are used.To include a colon in a participant name, enclose it in quotes.
":Alice"->":Bob": Hello
# This is a comment.Alice->Bob: Filled arrowAlice->>Bob: Open arrowBob-->Alice: Dotted lineBob-->>Alice: Dotted Line, open arrowBob-->Alice: Double arrowAlice->(1)Bob: Slightly delayedBob->(5)Alice: Highy delayed
Changing the order of participants
If you want to participants to be shown in a different order than they are used, declare them first using the participant keyword. You can also rename them this way to save typing.participant Bobparticipant Aliceparticipant "I have a really\nlong name" as LAlice->Bob: Authentication RequestBob->Alice: Authentication ResponseBob->L: Log transaction
Grouping signals together
You can group signals together using the alt/else, opt, loop, par, and seq keywords. All of them can take a text description that will be displayed in the group header. Use the end keyword to signal the end of a group. The groups may be nested to any depth.The else part is optional and can be repeated more than once for each condition.
Alice->Bob: Authentication Requestalt successful caseBob->Alice: Authentication Acceptedelse some kind of failureBob->Alice: Authentication Failureoptloop 1000 timesAlice->Bob: DNS Attackendendelse Another type of failureBob->Alice: Please repeatend
Notes in the diagram
You can add notes to the diagram. Notes can be placed to the left or right of a participant, or placed over one or more participants.If a note contains more than one line, it will not be word-wrapped. Instead, it will be formatted exacty as written.
participant Aliceparticipant Bobnote left of AliceThis is displayedleft of Alice.end notenote right of Alice: This is displayed right of Alice.note over Alice: This is displayed over Alice.note over Alice, Bob: This is displayed over Bob and Alice.
Extended text descriptions (premium)
Subscribers can explain sequences that follow simply by indenting your explanations with a space.
You can explain the sequences that followsimply by indenting your explanationswith a space.Alice->Bob: Wow!
States
Premium feature
A rounded box can be useful to show state information. The syntax is identical to the note keyword, except that state is used.participant Clientparticipant Serverparallel {state over Server: LISTENstate over Client: CLOSED}Client->Server: SYNparallel {state over Client: SYN-SENTstate over Server: SYN_RECEIVED}Server->Client: ACK
Lifeline activation and destruction
Use the + and - with signals to denote object activation. While activated, the participant's lifeline will be highlighted. + will activate the receiver, and - will deactivate the sender.
Use * with signals to create a participant.
A->*B: hello.
You can use the destroy keyword to destroy a participant. The participant's lifeline will end at the previous signal.
User->+A: DoWorkA->*+B: <<createRequest>>B->*+C: DoWorkC-->B: WorkDonedestroy CB-->-A: RequestCreatedA->User: Done
Alternate syntax
Ge more control over activations using the activate and deactive keywords. The commands apply to the previous signal.Alice->Bob: Do some work!activate BobBob->Bob: Work routineactivate Bobdeactivate BobBob->Alice: All done!deactivate Bob
Only arrows can cause activations
Activations and deactivations attach themselves to the previoius signal. Neigher a note nor a state can cause a deactivation. If you want to deactivate spontaneously, use a signal-to-self.A->+B: Activate pleaseB->-B: I'm deactivating now\n by myself
One arrow can activate/deactivate many participants at a time.
Using the explict syntax gives more flexibility.A->B:activate Aactivate BB->C:deactivate Adeactivate Bactivate CC->C:deactivate C
Reference other sequences
Premium feature
You can summarize or refer to sequences by drawing a box over one or more participants.You can optionally have a signal going into the box or one coming out.ref over Mobile, Base StationRefer to 3GPP 44.060 6.6.4.1end ref
Alice->ref over Bob, Mary: inputrefer to other diagramend ref -->Alice: output
Parallel sequences
Premium feature
You can make different things happen at the same time using the parallel keyword.Use the serial keyword within a parallel block to describe two parallel sequences of operations.parallel {Client->Proxy: RequestProxy->Server: Forwarded Requestnote right of Server: Web proxy in operation}Server->(3)Proxy: Replyparallel {Client->(3)Proxy:Proxy->(3)Client: Crossed messages}
parallel {serial {Alice->Bob: HelloBob->Alice: Hello}serial {Eve->Carol: HelloCarol->Eve: Hello}}