Routing Simulation - Implementation of Design Scheme (6)

zhaozj2021-02-16  49

V. Routing Process

This implementation part is the performance of the entire system, if integrated with the communication simulation system, this section is not required. So this part is written for individual debugging. In order to verify the route analog system, a single packet routing process is written. But semantics are basically complete. If this is achieved in the communication simulation system, you can synchronize the detailed expansion design.

1, single packet routing

Method Name: Communication :: SingleDatarout

Method parameters: no

Return value: no

The purpose of the method: implement a single data package by the whole process of successful success, and may have several network reconstruction during the period.

Possible error: no

// single packet routing

Void Communication :: SingLeDatarout (Void)

{

// Local variable

INDEX = 0, Number = 0;

CHAR CH;

Bool bwritesucc = true;

NetData * pnetdata = null;

LOOP:

// After sending a number of packets, automatically detect if the network has changed; if it has changed,

// Receive network information and create it.

IF (Number == 0)

Net.Recreate ();

Net.RoutComputeBuilder ();

// Index records the source router label of the packet

INDEX = Net.makedata ();

PNETDATA = (PNODEARRAY INDEX) -> PROUT-> NetReadData ();

While (pnetData! = null)

{// This packet is routed

IF (pnetData-> ismessage ())

{// answer message

Index = net.getroutid (pnetData-> getnexthop ());

BWRITESUCC = (PnodeArray Index) -> PROUT-> NetWriteData (* pnetdata);

// Surge Waiting; the perfect hugging processing plan is also achieved.

IF (! BWRITESUCC)

CONTINUE;

Index = net.getroutid (pnetdata-> getprehop ());

} else if (! pnetdata-> ismessage ())

{// network packet

Index = net.getroutid (pnetData-> getnexthop ());

BWRITESUCC = (PnodeArray Index) -> PROUT-> NetWriteData (* pnetdata);

// Surge Waiting; the perfect hugging processing plan is also achieved.

IF (! BWRITESUCC)

CONTINUE;

} // End of else IF

PNETDATA = (PNODEARRAY INDEX) -> PROUT-> NetReadData ();

} // end of while

Number = (NUMBER 1)% 6;

Std :: cout << "/ n / ninput 'e' to exit, or press any char key to payue:"

Std :: CIN >> CH;

Std :: cout << std :: endl;

IF (ch! = 'e')

Goto loop;

}

<2004-4-11 Completion>

转载请注明原文地址:https://www.9cbs.com/read-25380.html

New Post(0)