====== Hello, World! ====== //[[https://en.wikipedia.org/wiki/%22Hello,_World!%22_program|Hello, World!]]// is the the type of program that is used to demonstrate the basic syntax of a programming language. In the context of Netualizer, the //**Hello, World!**// project shows the basic functionality of Netualizer. Because Netualizer is a //[[https://www.sciencedirect.com/science/article/abs/pii/S2542660521000408|Protocol Stack Virtualization]]// framework, and not just a programming language, the //**Hello, World!**// project sets two full stacks that send a single //**Hello, World!**// packet from one stack to the other. A Netualizer controller typically includes a built-in agent that can be used for traffic generation on the same system. For sake of simplicity, in this example the controller interacts with its built-in agent to send a packet from one stack to the other. Moreover, since traffic is internal to the agent, it is possible to use the virtual ethernet interface installed by Netualizer. This interface, called VPS, carries IPv4 and IPv6 addresses 192.168.21.5 and 2001::21:5 respectively. Having said this, let's start the project. Start the controller and create a new project by selecting //File ⇒ New ⇒ Project//: {{:wiki:1.png?1000|}} Enter the project name as //Hello// and click the //Attach local agent// option: {{:wiki:2.png?1000|}} This will create a basic empty configuration and an empty LUA script. When the configuration is shown, click the physical layer block //phy// and select the local interface that has //192.168.21.5// as main address: {{:wiki:3.png?1000|}} Next, create an ethernet layer and set it on top of the physical layer. Call it //eth//: {{:wiki:4.png?1000|}} Now, create an IP layer, name it //ip// and put it on top of the ethernet layer: {{:wiki:5.png?1000|}} Create a UDP layer, call it //udp// and set it on top of the IP layer: {{:wiki:6.png?1000|}} These layers end up making the full stack: {{:wiki:7.png?1000|}} As shown below, Netualizer assigns a static IPv4 address. The address can be changed and, alternatively, DHCP can be used instead: {{:wiki:8.png?1000|}} Moreover, Netualizer also assigns an ethernet MAC address. This address can also be changed: {{:wiki:9.png?1000|}} Note that the UDP port (//no shown//) is also assigned automatically by VPS, and yes, it can be changed too. For now, let's leave the defaults. Now, let's repeat the same steps and build another similar stack. Netualizer will assign contiguous MAC and IPv4 addresses as well as UDP ports: {{:wiki:10.png?1000|}} Note that the IP layer of the second stack has IP address //192.168.21.11//: {{:wiki:11.png?1000|}} The UDP layer has port //4001//: {{:wiki:12.png?1000|}} Now let's double click on the script: {{:wiki:13.png?1000|}} And write a simple script: {{:wiki:14.png?1000|}} The code is the following: function main() clearOutput(); waitForIpUp(ip); waitForIpUp(ip2); setUdpDestPort(udp, 4001); setIpDestAddress(ip, "192.168.21.11"); send(udp, "Hello, World!"); end The main function calls //clearOutput()// to clear the output screen. The program then waits for both IP layers to come up. Note that the arguments of the //waitForIpUp// functions are the names of the IP layers. Next, the //setUdpDestPort(udp, 4001)// function sets the destination UDP address of the messages sent from the source UDP layer. The destination IP address is set by means of the //setIpDestAddress(ip, "192.168.21.11")// function call. Again, this is executed on the IP layer named //ip// and specifies //192.168.21.11// as destination IP address. Finally, the program executes //send(udp, "Hello, World!")// in order to send a small datagram with a UDP payload //Hello World!// to the destination. Next thing, let's run the suite by clicking on //Scripts ⇒ Run Suite//: {{:wiki:15.png?1000|}} How do we know if the datagram went from //192.168.21.10:4000// to //192.168.21.11:4001// ? Right click on the UDP layer, select //Statistics ⇒ Upstream Last Packet//: {{:wiki:16.png?1000|}} This shows the last received UDP message: {{:wiki:17.png?1000|}} Alternatively, [[https://www.wireshark.org/|Wireshark]] can be used to verify the transmission: {{:wiki:18.png?1000|}} Note that for simpler cases, like this one, there is no need to write any code. It is possible to directly specify the destination IPv4 address in the stack: {{:wiki:19.png?1000|}} And the destination UDP port too: {{:wiki:20.png?1000|}} Then click //Inject Raw Data//: {{:wiki:21.png?1000|}} And enter the //Hello World!// text in the edit box: {{:wiki:22.png?1000|}} And click //OK// to send it. Then, as before, check on the destination UDP layer to see if the packet was received. Note this is a simple //proof-of-concept// example, not very useful, but good enough to show how Netualizer works. Pretty utilitarian like any other //Hello, World!// example.