I am confused with master and slave relationship in OSPF? Why ospf need the election for master and slave relationship to exchange DBD?
This is explained in RFC 2328 - OSPF Version 2, Section 10.8
Master Database Description packets are sent when either a) the slave acknowledges the previous Database Description packet by echoing the DD sequence number or b) RxmtInterval seconds elapse without an acknowledgment, in which case the previous Database Description packet is retransmitted. Slave Database Description packets are sent only in response to Database Description packets received from the master. If the Database Description packet received from the master is new, a new Database Description packet is sent, otherwise the previous Database Description packet is resent.
In short, only one DBD sequence number can be unacknowledged at any given time. The Master is in charge of ensuring that DBD sequence numbers are correctly acknowledged. Two cooks in the kitchen doesn't work... one must have control over sequence numbers (the master) and one must acknowledge (the slave).