C PROGRAMMING. you are to write a TCP/IP server that can build up a graph of a network of networks (using the supplied graph library (graph.h) and implementation of Dijkstra’s (Dijkstra.h) algorithm) and then query that graph to find out which link between two networks should be used as the next hop to send a packet of data from one network to another within the network of networks (using the supplied implementation of Dijkstra’s algorithm). using the following program as a start point: /* * NetworkServer.c * ProgrammingPortfolio Skeleton * */ /* You will need to include these header files to be able to implement the TCP/IP functions */ #include #include #include #include #include #include #include #include #include #include /* You will also need to add #include for your graph library header files */ int main(int argc, const char * argv[]) { int serverSocket = -1; printf("Programming Portfolio 2022 Implementation\n"); printf("=========================================\n\n"); /* Insert your code here to create, and the TCP/IP socket for the Network Server * * Then once a connection has been accepted implement protocol */
C
you are to write a TCP/IP server that can build up a graph of a network of
networks (using the supplied graph library (graph.h) and implementation of Dijkstra’s (Dijkstra.h)
query that graph to find out which link between two networks should be used as the next hop to
send a packet of data from one network to another within the network of networks (using the
supplied implementation of Dijkstra’s algorithm).
using the following program as a start point:
/*
* NetworkServer.c
* ProgrammingPortfolio Skeleton
*
*/
/* You will need to include these header files to be able to implement the TCP/IP functions */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
/* You will also need to add #include for your graph library header files */
int main(int argc, const char * argv[])
{
int serverSocket = -1;
printf("Programming Portfolio 2022 Implementation\n");
printf("=========================================\n\n");
/* Insert your code here to create, and the TCP/IP socket for the Network Server
*
* Then once a connection has been accepted implement protocol
*/
![h dijkstra.h379 bytes
1
2
3
4
5
6
*
*
*
*/
dijkstras.h
Programming Portfolio
7
#ifndef dijkstra_h
8 #define dijkstra_h
9
10
/* an entry storing the shortest path */
11
/* next_hop is the next vertex in the path */
12
/* weight is the total weight of the path to dst */
13 typedef struct Path
14
{
15
16
17
18
19
20 Path *dijkstra (Graph *graph, int id, int *pnEntries);
21
22 #endif /* dijkstras_h */
23
int next_hop;
double weight;
} Path;
Open in Web IDE
V
Replace
Delete
G](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffa0fe09b-18c9-4500-88e7-342846d6ba83%2Ffec4c66c-bd79-4da8-9363-b19e652b3ed5%2Fhkl2gjp_processed.png&w=3840&q=75)
![h graph.h 1.16 KB
1 #ifndef _GRAPH_H
#define _GRAPH_H
2
3
4 #include "linked_list.h"
5
6
7
8
9
/* each node in the adjacency List stores a vertex */
10 /* a vertex has a unique numerical id */
11
11
12
12
17
13
14
15
16
17
18
LO
19
20
21
4
22
23
24
47
25
4
26
20
27
28
co
29
SO
30
24
34
25
35
36
27
37
20
39
40
40
/* a graph represented as an adjacency List /
typedef LinkedList Graph;
41
41
42
43
T
/* and stores a list of edges from the vertex ³/
typedef struct Vertex {
int id;
LinkedList "edges;
MA
31
32
33 void add_edge_undirected (Graph *, int, int, double);
void remove_edge (Graph *, int, int);
void remove_edges (Graph *, int);
48
19
49
50
} vertex;
/* each node in the list of edges for a vertex store the edge weight */
/* and the destination vertex 3/
typedef struct Edge {
double weight;
Vertex *vertex;
} Edge;
/* function prototypes */
Vertex *init_vertex(int);
20
38 void free_vertex (Vertex *);
Graph *init_graph (void);
void free_graph (Graph *);
void print_graph (Graph *);
Vertex *find_vertex (Graph *, int);
vertex *add_vertex (Graph *, int);
void remove_vertex (Graph *, int);
Edge *add_edge (Graph *, int, int, double);
Edge *init_edge (void);
void free_edge (Edge *);
int *get_vertices (Graph *, int *);
Edge **get_edges (Graph *, Vertex *, int *);
44
44
45 Edge *get_edge (Graph *, int, int);
46 int edge_destination (Edge *);
47
double edge_weight (Edge *);
#endif
Open in Web IDE
v
Replace Delete GOJ](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffa0fe09b-18c9-4500-88e7-342846d6ba83%2Ffec4c66c-bd79-4da8-9363-b19e652b3ed5%2Fpakuo3_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)