# Neighbor Session Solutions for Integrated Routing Protocols
## 4 Modeling Protocol Integration Solution Classes
### PISC 3--L3 Transport, Multiple Adjacencies
#### 4.1.1 Sending Part  
We start creating the model of the PISC 3 class by designing the parts of the protocol necessary to establish a neighbor relationship from the point of view of one router (router A). First, based on the neighbor relationship creation process, we create a routing protocol message-generating element. The element that generates the routing protocol messages is represented in Figure 2 by a place called To Send. This place can store tokens with the color RoutePACKET, which is a data structure defined in the CPN ML language as  
```
\(\{\)(right noisy) = 0 then



flag--field of flags (Empty, Init--creation of neighborship, Route--transmission of routing information). The 'to send' place in the preamble contains a single message, the Hello packet, which serves to discover a neighbor and is defined as follows:

1' {typ=Hello, seq=0, ack=0, flag=Empty}

Additional packets needed to establish the adjacency and transmit routing information are generated based on information from the neighbor table, which captures the state the adjacency is in. It is represented by the place, neighbor table, while individual records are represented by a token of color. NEIGHBOR is defined as

colset NEIGHBOR = record id:INT * l2 add:INT * l3 add:INT * seq:INT * ack:INT * neighborhd:BOOL * route:BOOL;

This place, despite its name, does not correspond to the neighbor table in the EIGRP routing protocol, but it captures the state the neighborship is in, as well as whether routing information has been transferred. We consider it a very simplified form of combining some functionalities in EIGRP provided by the DUAL algorithm, neighbor table, and topology table. The entries that each row of the neighbor table contains are as follows:

* id--internal unique identifier of the neighbor;
* l2 add--link address of the neighbor;
* l3 add--network address of the neighbor;
* seq--the sequence number of the message which should be confirmed to the neighbor;
* ack--the sequence number of the message that the neighbor last confirmed to us;
* neighborhd--information whether we received a message with the Init flag, which means that the adjacency is starting to be created;
* route--whether we have received a message with routing records. Generating additional packets to the 'to send' place is performed by calling the function whenever the Encapsulate L3 transition is activated. As soon as we discover the neighbor (we receive a Hello message from him/her), the neighbor's id is set to a non-zero value, and the function generates an Update message with the sequence number 1 and the Init flag. The acknowledgment number in this message is set to 0 if the neighbor does not need to confirm the receipt of the previous message; if necessary, the acknowledge number is set to the sequence number from the neighbor table. After the neighborship is created (we receive an Update message with the Init flag, and the neighbor has confirmed the receipt of an equivalent message from us), an Update message with sequence number 2 and routing information (expressed by the Route flag) is sent. The confirmation number is set the same as in the case of the previous Update message with the Init flag (0 if there is no need to confirm the receipt of the message; the value of the sequence number from the neighbor table if it is necessary to confirm). The last step, performed only if there is still a need to confirm receipt of an acknowledgment message from a neighbor, is to send a Hello message with the acknowledgment number set. The Encapsulate L3 transition encapsulates the routing message into an L3 packet. The input to the transition is the current message from the 'to send' place and the neighbor record from the neighbor table place. The outputs after performing this transition are as follows:

* An IPv4 packet created by encapsulating a routing message with source and destination addresses set is stored in the Added L3 place. * To the 'to send' place, a new packet is generated by calling the generating function.