All right, folks, happy Monday. You can see here, this is the queue that's being used to grade your homeworks. There's no spikes, there's nothing in the queue. At a certain point, everything was horribly failing. There was like 14 jobs in the queue and nobody could keep up with them through, yeah. So, luckily I was able to mostly fix the issue so everything should be good now and I think jobs get created within about five minutes now. So, and that should continue. There's four pretty big machines that are grading so you can problem less. Well, I'll probably end up spinning up more tomorrow because I don't have them, it's been less. Last 24 hours. There will be, so we're gonna send out information after class. I don't wanna spend class time talking about it but we'll send out on the mailing list all the information for the CTF more Wednesday. So we will not be here. We will be in EDC, is that educational? One, what's that? It's a super nice room.  There'll be a link to it if you won't be, if you have any questions, let us know but, like I said, I wanna get to, I'll grab it. So we've looked at networking so far. What type of communications have we looked at? Actually, we haven't looked at CCB at all. What was that? ARP? What was ARP used for? Yeah, right. To match up IPs with machine addresses, yes. So we want to, we know there's an IP we wanna talk to. Where do we know that IP address is located? Know the machines on our local network which means we can communicate it with it over a key minute and so we need to figure out, we know the IP address, we need to map it to a physical address and that's what ARP gives us. So we looked at that communication but what we haven't talked about is how do our packets get from our machine to a machine on the other side of the world? Right, so let's think about Google. When you go to google.com, how do your packets get from here to Google? Is Google in your local area network? Probably not. So the question then is how do your packets get there? So what do we have? So we talked about before in this situation, we as a node, we wanted to communicate with Google, what do we know, what do we have? So we think about what we know, what is our node? We'll get into it again because that uses UDP to the major request to translate Google.com to an IP address. So let's say now we know the IP address of Google. So we have Google's IP address. What else do we have? The gateway. We have the gateway? What's the gateway? There's information from your local network to the other side of the world. Yeah, so A, well if we go back to what we knew before, we know our subnet, right? So we'd ask the question, is this IP address on our subnet? No, the answer is definitely no. We are on a completely different subnet than Google.com. So now we actually need to know more things. So before, when it's on the local subnet, that's all we need to know. This IP address is on the local subnet. I know how to make an arm request on this network to find out that physical address. So we need something more. We need routing information. So we need to know, hey, so the way to think about essentially a router or a gateway, which are kind of essentially interchangeable terms, it basically means if I have a packet that's not destined to my local network, who does this go to? Exactly, that's what the router or the gateway is, right? So it's an IP address. What must be true about this IP address? Accessible to everyone, everyone on earth? Yes, on the local area network, so we should be able to communicate with it. What else must be true? Kind of inherent in that response. Yeah, exactly. It has to be an IP address on the local network. And so once we have those pieces of information, we have the destination IP address. We know our local subnet, we know our local router, we're actually able to then start the process of sending this packet off. So do we make an arm request for google.com's IP address? No, because we cannot communicate with them because they are on a completely different local network, right? This is kind of reinforcing that. Some people get this confused where they think, oh yeah, we translate these things and you just make the arm request, right? You're not on their network. So this is the idea behind routing and indirect delivery with one slide 54. So, and basically this is incredibly simple process. So the process is essentially, it's all local hops. So essentially, so if we can't send it to the final destination, right? If we can't send this packet to google.com, we have to send it to the router. So we know the router's IP address, what do we do next? Maybe, who's routing table? Ours? The routers? Ours. Not yet, before that. So we have the router's IP address. Capsulate our packet into another packet and send it to the routing information. What do you mean encapsulate our packet into another packet? Information into another packet in the data of another packet, which is another IP packet that we send it to the router. No, so we don't have to encapsulate our packet into anything. Essentially what's gonna happen is we're going to ask the router to send our packet on and that router will have a gateway or router where it knows where to send packets that is not on its local network. And that router knows how to send packets that are on its local network. At each step, it does local delivery. So exactly what we talked about. So I, the next hop, so you think of it in terms of hops, right? Your packet is hopping from your machine to the router and then from the router to the next router and that router to that router. Until finally, one machine, one switch or router has it that is on the local network of the IP address you're trying to talk to where it finally gets delivered. But at each step in the process is direct delivery what we just talked about. So the difference though is, so let's actually draw this packet. Back to the slides. Slide 55 is really just a diagram of what I presented programmatically showing that basically at every step of the process the Ethernet frame is recreated and the IP stays relatively the same. So it used to be that, we talked about some of the old IP options. It used to be that the person sending the packets could actually specify, hey, I want these, I want my packet to go through this route. This has really bad security problems because you could force all of your packets through maybe one router that can handle it and ended up taking down that router. And fundamentally, that's part of the whole point is you shouldn't have to care about what packets, what router packets take. As long as when you send it, the other side hopefully receives that. So okay, so the routing table, slide 58, so the idea is you can configure and you can actually configure all this manually so you can play fun games, creating your own networks, all kinds of stuff. It can be very useful. The idea is you can use the route command on Linux to list the routing tables. So this is exactly what we were talking about here. Basically, let's see. Okay, so the first entry is your IP address. The second entry, so the gem mask is essentially your subnet. So it says that, okay, 255, 255, 255, 0. So as you can think of, that's all ones except for the last octet is zeros. So that defined your subnet. It's the same thing as the slash 24. It says anybody here, so 192.168.1, that slash 24 is on physical interface zero. So this, you can also set up different interfaces with different networks so you can actually make, you can configure your own things as switches and routers. The default here is the destination of all zero. So basically, none of these rules apply to that destination IP address. Then send it to the gateway of <IP_ADDRESS>. So this leads to several interesting attacks that are variations of what we saw before. So, all right, we're gonna move in. The idea being that you can't see the response. So you have to just create habits as an impersonated host. So, and you have to assume that you don't have access to the reply. Now, as we said, so on slide 61, so if we actually do get, so what can we do if we are one of those switches, if we take control of that or somehow compromise that, what can we do? Yeah, it depends. So, not always. So let's say, so the idea would be if there's some trust relationship between B and C, let's say that kind of a famous one or one that actually comes up very often in organizations is to say like, okay, you can log in to this server if only this IP address can log in to this server without password. And so if you're able to then basically send a command to that server saying delete everything on the server coming from that trusted IP address, it will just execute it. Or like a network file share is probably a better example as we'll see later. So you can maybe delete files coming from a trusted IP address. So this is actually why you really can't trust IP address as necessarily as an authentication mechanism. Because you don't know maybe that IP address is being spooked. Okay, so put on your black hats and you control a gateway on the network. Sorry, one kind of router on the network, what do you do? What was that? It's the packets. Hey, you set the packets so you can see all the packets that are going through the network. It's pretty nice. What else? Yeah? Can change the direction of the packets or if you can change the priority between the routers or if there are some routing protocols between the routers, consider that there's three routers, they have access to just one of them and the other router is a high priority router. So you can change your priority to the highest priority and so you can wrap all of the packets in there. So try to configure the other routers to maybe change- First of all, it was to get a five-pack. What else? What was that? Modify the packets. Modify the packets. Yeah, you can change any of the packets, right? So this is why it's important to think about when you think about the internet. So I like to use kind of the example of the mail service. So you have a letter and then you put it in an envelope and then you put it in the mailbox. But that's actually a pretty, that's a bad analogy because it's more like a postcard. Does anybody know what a postcard is? So it's like usually not something you put in an envelope and that's the key idea but it's usually like a picture on one side and then you write on it on the other and it has the address and everything. So you think about when you send that to the mail, every person who touches that piece of mail can read whatever you wrote on that postcard, right? And they could even write on it or do whatever they wanted to it, right? So this is an important thing to remember about the internet and this is why as we'll see other types of authentication and confidentiality, all this crypto has been built on top of these layers because fundamentally at the IP layer, there is nothing to prevent anyone in between from modifying or changing any packets or any data or reading anything that goes across. Oh, we didn't talk about it. We could block the traffic, right? So maybe we wanna stop these two machines from communicating, right? Yeah, so we can inject new data into their connection. We can basically do all kinds of super cool stuff. I'm gonna skip the presentation. So on slide seven, we're talking about ICMP. So it's actually an interesting design question. So you're developing this complex networking protocol with all these different layers and multi-hop routing and you're trying to build a way for the different machines that are running different operating systems operating across the world to be able to communicate with each other. How do you know when something goes wrong? So somebody asked the question earlier, how do you know where your packet is? How do you debug something like this? It took me like four hours or five hours on Saturday to try to fix the servers. That was only like three machines without any things that we looked at so far. A core screen mechanism you could do is control two machines, send one packet from one to the other and then look at what the TTL value is based on what you send and what you receive. Cool, so that may tell you how many hops are in between. Do you have sort of a check sum at each hop? Yes, we didn't talk about it, but there is a check sum value in most of these layers that just looks for bit flips and things like that. You know where, where you broke them. Right, so that's a good mechanism.  You want some way to get like error messages back.  How do you know if they didn't get your packet versus they're actually down? Or any number of things? What if your route's not configured correctly? So this is where ICMP comes in, the Internet Control Message Protocol. The idea is this is a protocol that's designed to communicate about any errors at the IT level. So it's kind of interesting because they're using IT in order to transmit these messages that are about IT problems. So if you have catastrophic failures, this is not going to help you. But as we'll see, it's a nice, not only debugging tool, but also used for attacks and reconnaissance. So we can send requests, get responses, or get error messages. So this is, and so we'll look at this very quickly. The headers are pretty simple. It's like 71. There's a type, a code, a check sum. So we're talking about check sum. There's a check sum at this level. And then the data. So they're very simple. There are all kinds of stuff. Let's skip over some of these. So PING, when you ping another machine, right, you want to see if that machine is actually alive. It uses an ICMP echo request. So that's a simple message that says, hey, send me back whatever I send you. So if it does that, it sends it back. So it's actually a great way to communicate that A, that the host is up, and B, to help debug that what you sent them is what you got back. Which means that no switches in between are accidentally maybe flipping bits or doing something. So back to our lovely friend, the TTL. The TTL zero, we'd want to know about it, right? Because we'd want to know, hey, something's wrong with the network. So the router or the switch that drops the packet will try to send an ICMP message, a TTL expired back to the source IP of that message. There are other fancy ways. Let's say you're on a network with maybe two gateways, and your machine is misconfigured. One gateway can actually tell you to use another gateway. Destination unreachable, this happens a lot when I'm doing stuff and it doesn't work.  Sorry, like. So ICMP echo request. So when you're on PING, this is exactly what it does. So the type, either request or reply, code zero, and identifier, so that that way the responder knows what request you sent in response to. So it's actually interesting that this has this concept of an identifier where it's something like ARP, does it not? So, and this is exactly what it's also used. So what other things do you use PING for? What was that? Yeah, what do you use that for? I mean, we haven't talked about that yet. What do you use the PING program for? Check if the host is accepting finishes. You have to check if the host is, that's one way. It can be misleading because oftentimes, I mean, you can configure a machine to not respond to PING requests. Yeah? You need to reply to another agency. Yeah, right? So if you think about it, you send a request. The time between you sending a request and getting a reply back is roughly the amount of time I can take to get from you to the other side. So this is, I mean, I use this all the time but I'm on either a crappy Wi-Fi or something to figure out what's going on. Is it the latency of the problem or package being dropped? Yeah? I think it also does the host PING program too. Yes, it will also, under the hood, we'll do a DNS query to map a domain name to an IP address. So it's going to be a nice quick dig. DIG is a better tool for that if I find it. Did you get more information back? We can also use this for attacks. So it seems kind of interesting. So it seems like this is such an innocuous functionality, right? It simply just said, hey, are you there? Yes, I'm here, right? So what can we use this for? Send a package with the, we can send a package with a destination as somebody else that actually was responsible for the destination of the problems with more packages. Right, so we know that a fundamental tenet of IP, of the IP layer, is that we can spoof the source address. So we can send a request with a source address to somebody else, and it will respond back to that person. We'll have to see how we can actually turn this into an attack in a second. That's one way. What else? Yeah? It's nice to see that we're quick to spend a lot of time. OK, so I'm going to try to maybe take the machine out by sending a lot of packets. What's that? It's not just knowing what hosts are up, right? So you want to try to break into some company or some website, right? What machines are up in their range? So you can send a ping request to every IP address in there, like, slash 24, and then see what replies you get. And this actually used pretty frequently. I'm thinking of this like a ping scan.  And then that gives you then further directions to attacking. So this is an important concept. I don't know what you're talking about yet, so based on your, hopefully, just knowledge from movies, how do you rob a bank? Physically, not digitally. What's the first step? Get a gun. Get a gun first. And if you bring a gun, then it becomes like a temp. I don't know. It's like, how much higher tire did you get on movies? That's what changes security. Yeah, those do what? So I take the security. Ah, before that, there's a pre-step. You first have to assemble an awesome crew, right? Is it a montage, or you go to people, and they'll be like, no, I'm retired. One more job.  So then you case the joint, right? You go, and you look, and you see, what are all the things you're interested in? The environment. So you're looking at the environment of the building, the layout. You're looking at maybe the traffic patterns. Routines. What was that? Routines. Routines, so you're looking at when do the guards change? When do they go on break? How many guards are there? Where's the manager? What days does what manager work? Which managers have kids, or maybe something that can be blackmail? No. Right? You spend a significant, and they usually don't show some movies. We spend a lot of time trying to figure out every possible detail you can about that bank, right? You're going to look and probably pay somebody to get the plans of the bank, so you can know the exact layout of everything. What type of security system are they using? What type of cameras? Do you have somebody in your crew who can hack those cameras? All this kind of stuff. And then only after you've done all this work, then you actually rob the bank, and then something inevitably goes wrong, and it all goes haywire. But with now doing that reconnaissance step, you don't know what you're walking into. So similar thing occurs in computer security. When you're trying to, let's say, as a pen tester, you're hired to break into some company, you need to know where to go, right? You need to know what hosts do I attack. Can you just ask the company for that? No, because the attacker wouldn't do that. They wouldn't give that information to an attacker, right? So this is part of what I want to be thinking about when we talk about different types of attacks is reconnaissance is a very big part of gathering intel information and trying to understand more things about the network that you're trying to attack. Don't rob banks. It never ends well. They almost never get away. Cool. So NMAP is a tool that will come up very frequently. So it's going to stand for network, like a network map. So it has all types of insane options to do different types of network scanning. So one option you can do is, I don't know what off the top of my head, is to do a ping scan. So you can do a ping scan of a network and send a ping request and see what replies you get. And so some of the things that people are talking about is, and I think it's interesting to look at historical vulnerabilities. Why? Or is it? Maybe I should pose that as a question first. Is it interesting to look at historical vulnerabilities? Why? Are you just there? Can I ask you a leading question? Yeah. If the way in response to those kind of problems, maybe it can still be useful? Yeah, so there's a couple, a lot of reasons. One is that, honestly, these same problems keep coming up in new areas. So you learn about an old attack, and then you found out.  And then, so that's a good example. I mean, a good one is, let's say, well, that hasn't really been solved, but let's say a memory side channel. So basically, they show a long time ago that you can kind of tell if you're on the same machine as somebody, you may be able to tell what programs they're using just by the size of the memory that they're using. And you think, OK, that's a very academic thing. And if you're on the same machine, you already kind of had problems, and you're not in a trusted environment. That was dormant for a long time until Android came out. And they showed that one app can know everything that another app is doing based on the memory usage, like using that as a side channel to figure out what they're doing. So old attacks keep coming up again and again. So even though an ICMP, a SMERF attack, you can't really use anymore, it's still interesting thinking about why this is a problem. So before we talk about this, so this is going to be a denial of service attack I want to talk about. So a denial of service attack is an attack against one part of the security of an application. Yeah, availability, right? What are the other two? I'll put that in here. Yeah, it's difficult when you go in the other direction, right? Commit a shouting attack, right? So it's an attack against availability. So before, whatever reason, we want to take down a specific system. So let's say you want to take down Google.com. That would be great. Or let's take it at a different point. You're interested in causing mayhem, you want to take down Amazon.com. Let's say, and I don't know, maybe I have a rough idea of how much Amazon sells or makes in a half hour or an hour. I'm sure it's something insane, right? It's a very, very high number. So even taking them offline for maybe five minutes or 10 minutes would be a huge deal to them. And maybe if you're really good, you can take them down for an extended period of time. So before you do that, you can short their stock. And that way, when you do that, that's when their stock prices drop. Now, you've made a lot of money. So you want to take down Amazon. How do you do that?  Yeah? I mean, they have the apps on web services, right? So if you could probably just get a big account and see what you could do. Yes, think about network things at the start, though. So I mean, there's a couple different ways, right? We could maybe try to find some vulnerability, a remote vulnerability that exists on their servers. We could get into there and then just shut down. We get remote code execution on their servers. We could shut them down, right? Or worse, make them like, spin forever, or I don't know, make them burst into flames or something, if we know some kind of way to do that. Appear it from the network. So the first thing, as well, is just send in a bunch of packets, right? Is that going to work?  Yeah, why not a bunch? Because they can handle it, they have. Yeah, they're a huge company. They can handle a queue sending for as many packets as your machine on your network can send. You can bet that Amazon can definitely handle it. So what do we need then? And so let's think about it this way. Let's think about Amazon is limited, they can only handle, I don't know, I'm going to make up a number because I know this is not true, but let's say a gigabit per second, let's say.  Let's say you can get 100 megabits. So you can fundamentally never take them offline because all the data that you send to them, they can completely handle all that just fine.  Yeah, so we need some kind of lever or some kind of scale, right? So I can get, what is that, the numbers are going to be, if I can get 100 machines, control of 100 machines, which each have 100 megabits per second, and I guess I need 101 to get over the threshold, but let's say I send over a gigabit per second to Amazon, I can then get them down. But still fundamentally I then need to control one gigabit per second worth of bandwidth, right? Exactly the same amount of size as the attacker. So I can, so the question is how fundamentally, so the one gigabit per second is a little bit misleading because it sounds like, yeah, you could do that, but there are like terabytes, terabits, I guess, per second or petabits per second, something that really you're kind of out of the realm of doing even with if you control fast numbers of machines. I mean, you'd really have to have a huge infection. And at that point, ransomware is much more profitable than anything else. So what would you need instead? Then a lot of payments requests to the data server or that kind of thing. Even though the server is reachable, not you, it's reachable. So we can try to target other areas, so if you look at it as kind of like a dependency chain, if nobody can resolve amazon.com to an IP address, then that could be an average of the tax, so but let's say they're very good, all of their systems all have this, you know, terabit per second. Bandwidth limit, yeah. If you can get into a router and set the source, you can just all point back to the Amazon. Who's that again? If you can set the source IP every back would come in through some switch or router. So how does that help us? Then any packet going through that switch, not only yours, would go back to Amazon. So we need to depend on how many packets are going through that switch. Let's say it's a hundred or a thousand times the traffic we can generate, right? Then that could then be sent back to Amazon. And if we could do this with multiple switches, right? Essentially having to redirect all of their traffic towards Amazon. Or what if we sent one byte and Amazon received a hundred bytes, right? So the thing to think about in denial of service. So a lot of people focused on, they called distributed denial of service or DDoS where you just get a bunch of machines and then launch traffic, they had something to take it down. Really what you're going for with denial of service is some kind of lever, right? Some kind of multiplier, like a 10x or a 100x multiplier that says I can spend, let's say some type of resource, either it's bandwidth, time, or processing power. And I can force you to use 10 or 100 times that processing power. So that's when we get to, when we see these types of denial of service attacks, this is really what's at the core here. So the Smurf attack, which has a great name. The idea is, let's say, so there are three completely disconnected subnets, completely different subnets. There's some server that we want to take down. We'll say in this example, it's at 128, 111, 4110. And we are some attacker on the internet. So this machine, in this picture, it's kind of like a rack so you can think of, it has a pretty good processing power, it has pretty good network capabilities, much more so than us with our laptop. This is kind of the fun, because if we have more resources than you, then yes, I can take you down. That is very useful. That's actually not even cool. I think that's super lame. It's like when people take down, I don't know, a lot on top, like really small websites. It's like, okay, that's lame because they don't have anybody, but if you can take down like Amazon, that's like amazing. You're really doing something cool. Or very bad, so don't do that. Technically, it's technically cool and interesting. So what you would do, so the idea is if you just sent echo requests, let's say to the target server, the victim server, and then we get echo responses, we can't flood their network. There's no way we're gonna be able to flood their network. But what used to be the case is any ICNP echo request sent to the broadcast IP address of a subnet, that packet would then get split to all of the machines on that subnet. So what I would do is the attacker, let's say this subnet is 192.168.1. So what the attacker would do is send an ICNP request message of hanging request, set that from the source destination IP to <IP_ADDRESS>. So this is to the broadcast address in that local subnet, in that subnet. And the source IP address, it's gonna pretend like it was from the victim. So this packet gets sent out, and then every machine in the subnet gets an ICNP request from the victim, 12811, what is it, 4110. And all of them reply back to that. So we sent one packet, and let's say there's 10 machines on the subnet even, or it's a 255, there could be 254 machines on that subnet. They're all then sending 254 packets to the victim. And so we can keep doing this for all these, all these subnets until we send enough to where we've completely wiped out. And then this would be even worse against a class A network, like a class eight, because we're sending basically a ping to their entire network, and so they're all responding. So this was a real problem. And this was a real attack that people would do to take down servers. And this is really cool because you're getting that leverage, right? The attacker is getting that leverage based on how many machines are on the subnet. I send one packet, they receive up to 254. That's awesome leverage. So how do you prevent this? I block ICMP packets. Yes, but you want to keep ICMP packets if you want to debug stuff. Like ping is super useful. Yeah, when you need it. When you need it, exactly. Block ICMP to the broadcast address. Yes, block ICMP to the broadcast address. So no more ICMP. So now, if I can't do this, and I want, and the attacker wants to send 255 packets to the victim, how many packets do I have to send? 255, I have to send all those packets, right? So there's no leverage there. They've reduced that from a 256X to 021X, which is nothing, right? Then why, at that point, why send the packets to the subnet and then back to the victim, right? You might as well just send them directly to the victim. That's that attack, that's one of my favorites. We're gonna skip over that. Okay, we're gonna go to TTL. So we talked about this. And time exceeded packet. So we do want to know for debug purposes, but also for, yeah. No, we want to able to send ICMP packets to the router or the subnet. Even a LAN connection to the local network can also only do that. Can we send ICMP ping packets to our local subnet? Yeah. I think the answer's no. Even a LAN connection. Yes, because I don't know how they would know. Basically, you have to send one ping request per machine on the subnet, which is not that much, I mean it's 255, yeah. What do you think happens if you put the source ID at the station like before us? So put both of them as the same? I think nothing. If you, you mean a source, say that again? It tries to send it, it tries to reverse this order and sends over and over to the subnet on your type. No, the, because the machine knows its IP address, so it would. Then no, I put the subnet on the source ID of the station on the subnet. Yes. And it would try to answer like this. I think it would know that it's IP address, so it would send it on the local interface and not the actual physical interface, and so it would just handle that and it would say that, I don't know, it's interesting, you should try that and see what happens. I don't think it'll loop forever, but I think it will access itself. It all sounds like an SRI or an SPU. So we wanna know if the TTL expires, right? We saw that, that's something that we definitely want to know. And we talked about it, it would be really nice to know the path that our packets take throughout the network. So by combining this, using this idea, this is how, so some of you are familiar with the TraceRoute program, this is how it actually works as it sends out one packet with a TTL value of one, and so that means that gateway is gonna decrement that, it'll be zero, and you'll get an ICMP timing seeded message back, and then you send out another packet with a TTL of two, and you see if you get a response back, then you send a TTL of three further and further, allowing you to map play. So yeah, so this is nice when you're actually testing things. It's actually really cool to just look at what's happening, because oftentimes you can tell, so TraceRoute will do like a reverse DNS lookup to try to map the IP address of the router with its domain name, and sometimes there'll be really interesting things, like you'll be able to see that the packets from here go to LA before going around the world, so it's pretty cool. You guys run TraceRoute, and then the IP address or the DNS address, and it will, you can get all these hops so you can see basically all the steps that these packets take. So we've looked at that. There's no definite rule between the source and the destination. What? There's no definite rule between the source and the destination. I can't hear it. There's no definite rule between the source and the destination. Is that a question, or is it? Yeah, I think that's right. What? There's no definite rule between the source and the destination. I mean, the packets can choose a different number. Yes, yes, yes. Then how does TracingRoute help with debugging? It can, so the routes are mostly static, except when they're not. Yes, the problem is there's no guarantee so you're sending these packets out one after the other. There's no guarantee that when you send out an actual packet, it's gonna go the same route. There's no guarantee that even these TracePaint packets you're sending, that they went the same route. They could go different routes. For the most part, it's fairly stable-ish, so it's more or less okay. So yeah, that's, but yeah, it's exactly that. It's all kind of approximation and best effort. So we looked at how we send packets on our local network. We've looked at how to send packets from one network to another. Now we get to look at actually sending information to each other. So this is where things get interesting. So UDP, so we actually just talked about this, is so it's the layer on top of IP, so it's going to view what the IP packet is sending. It basically provides nothing. So connectionless, unreliable, best effort, so no delivery integrity, no communication ordering, or bandwidth, none of that is guaranteed. So similarly like IP, so the reason, but it does add an important distinction on top of IP address. So you can think of a IP address as essentially a big apartment complex, right? So how do you live in an apartment? In an apartment, in a complex, what kind of complex? So how does the post office distinguish you between all the other people that live in that address? Unit numbers. Unit numbers, right? So similarly, in terms of services that we write that use the network, we want to be able to say, hey I want to talk to the HTTP server, sorry, the HTTP program running on this server, or I want to talk to the FTP program that's running on this server, right? I need to know different, essentially you can think of as different residences or houses, units in that apartment complex. So that's the idea of the important abstraction. So the ports specified in our program, different UDP is the way UDP and TCP both use this port abstraction. UDP is still really important even though it's not used quite as much as TCP. And when we look at on slide 85, a UDP message has a source port, destination port, how big, based on this table, are these values? 16 bits, so how many port numbers do we have? Yeah, zero to two, 65, 65, yeah. The length of the message, the check sum of the data, so we can see that the overhead for the UDP, so why isn't the IP source a destination in the UDP header? Yeah, because that's a nonsensical statement, but that's in the IP layer. All the UDP layer tiers, guys, what port do we want to talk to? And so just like before, so we have our UDP data with the UDP headers, that is encapsulated inside the IP data, which has an IP header, and that's encapsulated inside the frame data with a frame header. All right, when we come back, we'll talk about our fun application of this proofing.


That moves on to the next item of business, which is a debate on motion 1207, the name of Annas Sarwar, on NHS Tayside Public inquiry. Can I invite those members who wish to speak the debate to press the request-to-speak buttons now? I call on Annas Sarwar to speak to and move the motion. That is the relief to hear you are still in a good mood. I move the motion in my name. Last week, the Parliament heard about the tragic case of David Ramsey. David hung himself four days after his second emergency assessment at the Carsview Centre. David's case is sadly not an isolated one. In the past year, there has been a 61 per cent increase in the number of suicides in Dundee. That is not about the statistic, it is about people's lives. Many of the family's effect is to join us in the gallery today. They have been campaigning for an inquiry into mental health services in Tayside for over three years. On Thursday, Richard Leonard raised the case and the demands of the families of First Minister's questions. On Friday, NHS Tayside announced a review into Carsview. The Government's amendment today goes further, with a commitment to a wider inquiry into mental health and suicide prevention services across the region. It should not take raising the issues in this Parliament to get action. I hope that this debate means that, after their three-year struggle, today our Parliament can genuinely unite in solidarity with the family's campaign, demonstrating to them that we have listened and we have acted. I cannot begin to imagine the pain and suffering that they have gone through, so I do not think that we can thank them enough for turning that absolute grief into a campaigning effort, an effort to get answers about what happened to their loved ones, but equally an effort to deliver change to stop it happening to anyone else. To each and every single one of them, we cannot thank you enough. We on those benches are minded to support the Government amendment today, but, like the families, we still have questions and need further reassurances and commitments from the Government. Crucially, the independent inquiry will be a genuinely independent inquiry. We recognise that there are clear trust issues with NHS Tayside, so we will appoint a genuinely independent chair. The families will be included in the process of agreeing the terms of reference of the inquiry. We ensure that the families are part of the process throughout that inquiry and feel included, that the inquiry is open and transparent, and that it includes a public call for evidence. I must emphasise that it cannot just be those things in words, it needs to be visibly independent, it needs to be visibly inclusive, it needs to be visibly open and transparent and it needs to be visibly supporting those families in those demands. I am happy to take an intervention from the cabinet secretary. Can I take the opportunity to say to Annas Sarwar that yes to all those questions and I have had the assurance from the chair of NHS Tayside, John Brown that that will indeed be the case? I thank the cabinet secretary for that. Everyone on this chamber and outside knows that there is at times no love lost between myself and the cabinet secretary, but on this, I hope that we are genuinely at one. If that is the case, I thank her for that, and I thank her for listening to the voices of the families. I hope that, in her own contribution, she can set out in more detail how those five principles will be delivered in practice so that the families can have that comfort of genuine independence and genuinely be part of the process. We must learn the lessons of previous inquiries and ensure that those affected are involved in the process. Presiding Officer, it would be an absolute tragedy if any inquiry didn't have the full support and confidence of the family, both in terms of its process or indeed its final report. Confidence, that is crucial, because we cannot allow that to become a repeat of the mesh inquiry. Now, this inquiry has national significance too. As today's report by Professor Rory O'Connor finds, one in nine young people in Scotland have tried to commit suicide. One in six young people in Scotland, at some point in their lives, will self-harm. The lessons from this inquiry, if done right, can help to better inform and design services, not just for NHS Tayside but for the whole of Scotland. One in three people will have a mental health issue at some point in their lives. The number of children who recorded mental health problems in our schools has more than doubled between 2012 and 2016. That is why we must see a ring fencing of mental health budgets to ensure that resources reach the front line where they need them most. We need a genuine guarantee of access to a schools-based councillor for every pupil in Scotland. However, an area that I think needs specific investigation in NHS Tayside but actually right across Scotland is emergency mental health services. The reality for too many patients is that they cannot wait days to see a GP and then wait weeks or maybe months to see a councillor or a psychologist. We need to build emergency services that could be supported by better use of technology so that people can speak to a councillor quickly. That can be the difference between life and death for many individuals. I have spoken about the wider challenges of mental health, the importance of having the confidence of the families, the importance of having an open and transparent process, the importance of taking the families on a journey and giving them the answers that they want, giving them the answers that they need, giving them the closure that they deserve, but also delivering for the many families in Tayside who are concerned about the situation. However, it is important to highlight that this is not just an issue in Tayside. I have been struck by the number of families from across Scotland who have said that this is about what happens right across Scotland, and we have to make sure that we speak for them. I want to conclude by reading an email that I received from the niece of David Ramsey a couple of weeks ago, because it tells the story of the families in their own words, what they have gone through, what they demand and why they will not give up until they get what they want. It does so better than I or any other member in this Parliament could ever do in their own words. That email opened my eyes. I struggled to read it because of the raw emotion that it contains. David Ramsey's niece, Julie Murray, wrote, There is no doubt in our mind that David has been failed. My family is now another sad statistic in Dundee. There are so many of us in the same situation. It is terrifying. David was not just my uncle. He was my best friend, so watching him literally lose his mind in front of me with no support from the NHS fuels the anger that I feel he was let down. Carseview Centre passed on any responsibility to myself and family. We tried our best, but it was not good enough. I was having to google how to care for a suicidal individual since Carseview and NHS Tayside took no ownership. It is no wonder that I now suffer from post-traumatic stress disorder. It is a living hell knowing that I asked the NHS for help, David asked the NHS for help, as well as other members of my family, and we were repeatedly ignored resulting in David's death. The advice that David got was that they had nipped it in the bud, go out and do normal things like walk the dog. The guilt plagues us every day. I ran around Templeton Woods for over two hours, but by the time I got to David, it was too late. David took the advice. He did go and walk the dog. He hung himself with the dog lead. No other family should have to go through the sheer agony of knowing that their loved one's death was preventable. David's life has been taken from him, my life has been destroyed in the process as has the rest of my families and other families in Dundee. This crisis cannot continue and will not continue. I will not stop. We cannot grieve, we cannot move on with our lives without some form of justice. You wouldn't expect a murder victim's family to simply move on, so why should our families, whose loved ones have lost their lives, be any different? The answer to Gillian is that you shouldn't. I hope that this Parliament stands united with you and all the families in your pursuit of justice. I say very gently, and I understand why, to the public and the gallery, that we don't permit applause in the gallery. I understand why, and I have every sympathy, but it's not permitted. I now call on Maureen Watt, the minister, to speak to and move amendment 121 to 7.3. Six minutes, please, minister. I would like to begin by recognising the strength of those who have raised the cases of their loved one, who has been lost to suicide, and to thank them for their determination to try and prevent the pain and suffering that they are experiencing being visited on others. I would like to commend them for coming to the gallery today and being with us, and I look forward to meeting them soon. It is their efforts that have led the new leadership team of NHS Tayside to set out that they will commission an independent inquiry. I commend Anna Sarwar for his very removing remarks, and as he said on Friday, John Brown and Malcolm Wright, the chair and chief executive of NHS Tayside, announced the inquiry into mental health services at Carthew centre. They have since broadened it to cover mental health services across Tayside. Miles Briggs amendment today sets out that the inquiry should cover the whole region and that the families that have been affected must be involved in the establishment and remit of the inquiry. I agree, and as such, we will support this amendment, as we will, Anna Sarwar. As we know, mental health services do not operate in a vacuum. Their quantity and benefit are dependent on meaningful and coherent links between community, specialist and crisis services. I support the commitment made by NHS Tayside to ensure that the findings and recommendations of the recent reports by the Mental Welfare Commission and Healthcare Improvement Scotland are fully considered through the inquiry. I am also pleased to see the commitment to work with staff and to hear from patients and families. It is vital that their voices are clearly heard and responded to. I am confident that the newly appointed chair and chief executive of NHS Tayside will, together, create the environment for an effective and independent inquiry. That will allow the inquiry to be established and undertake its work quickly and ensure that any necessary changes are expedited. However, should it be apparent that the inquiry is not independent or that barriers to its work exist, the health secretary will use the statutory powers available to her to make that happen. As the cabinet secretary said, it is yes to all Anna Sarwar's asks.  We are currently working with people and organisations from across Scotland to conclude a new suicide prevention plan. The new plan will be published soon in the summer. Progress has been made in the last decade with a 17 per cent reduction in deaths from suicide, but I want us to go further. My view is clear that suicide is preventable. We need our services to work more closely with each other so that the support to those in crisis is coherent and effective. That is not only important for those who are in contact with health services but also for developing new approaches to reaching those who are considering suicide but are not in contact with any service. Currently, around a quarter of deaths from suicide are carried out by those who have not been in contact with health services. As part of the suicide prevention plan work, I want to see a national suicide prevention leadership group that is established to drive the changes that are required. The plan will also support the development of appropriate reviews into every death from suicide. I want to process where necessary involving multidisciplinary reviews ensures that learning and knowledge from every suicide is shared, considered and improvements made. The Parliament has already legislated for a review of the arrangement for reviewing deaths of people receiving mental health treatment through section 37 of the Mental Health Scotland Act 2015. That will report in December this year. I want to ensure that development of a process to review all deaths by suicide takes account of the recommendation of the section 37 review, which will help to drive local and national learning. I also want a more consistent and coherent approach to supporting those who have lost a loved one through suicide or who are themselves at risk of dying from suicide. Buried relatives and friends have told me of the improved support that they require when they are involved in a review. I note that the subtitles have welcomed the proposals in our amendment, and we will continue to work with them on this and other issues that they highlight, not least on isolation and loneliness. We all know that there is rarely any single identifiable causal factor related to individual deaths by suicide, but through sharing knowledge and learning, ensuring that services and support are effective and joined up and that all those at risk of taking their life through suicide get the help that they require, we will deliver the changes required. The independent inquiry in Tayside will be an important part of this learning and improvement of services. I move the amendment in Shona Robison's name. Thank you very much, minister. I call on Miles Briggs to speak to and move amendment 127.2. Mr Briggs, five minutes, please. Thank you, Deputy Presiding Officer. I grew up in Perthshire, and I know many individuals and families who have experience of NHS Tayside's mental health services. In the majority of cases, they have received help, support and treatment, which helped them to get their lives back on track. However, I also know of cases in individuals where they have been failed and questions remain over what has gone wrong. NHS staff in Tayside work hard to deliver the best mental health services that they can under huge resource and patient demands. Today, I want to start by paying tribute to the families who have joined us today in the public gallery and all those who have spoken out. It cannot be easy for them as they seek the answers that they so desperately need as to how their loved ones have not been given the care and support that we all expect our NHS to provide. Deputy Presiding Officer, I also think that it is right to condemn the personal attacks that campaigners have faced, mainly on social media, simply for speaking out. I have to say that this has been shocking to witness. However, I want to particularly pay tribute to Gillian Murray and the Lost Souls Group for the campaign that they have undertaken to seek the answers families in Tayside so desperately need. When NHS Tayside announced last Friday a limited inquiry into Carshview and Dundee, I said then that it was clear that this is not acceptable to families across Tayside, and I made the view known to the Scottish Government. It is clear from the many families across NHS Tayside that there remain many unanswered questions. From the outset, it has been clear that a wider independent inquiry across the region was indeed needed to find out what has gone wrong in so many cases at a number of facilities across the region. It has to go to address the problems and get answers and make sure that we stop those mistakes from ever happening again in the future. I know from my colleagues who represent Mid Scotland 5 in the north-east regions in this Parliament that they have individual families in cases where mental health services have failed. In some cases, suicides have taken place within NHS facilities when individuals have meant to be under the safety, care and supervision of NHS Tayside. From the outset, Scottish Conservatives have focused our attention on supporting the families and making sure that their voice is heard. That is what my amendment seeks to achieve in securing a wider independent inquiry across NHS Tayside, one that would allow for those concerns to be investigated comprehensively in order to restore faith in those services among patients and their relatives and friends. The prevalence of suicide in Scotland, especially among men, should focus all our minds. As has already been said, it is my belief that there will be learnings for other parts of our health service from the inquiry's findings—lessons that must be learnt and services that must be improved. No more individuals should face crisis and then not be denied help. I would like to say this to the cabinet secretary that it is imperative that families seeking answers are really included in the establishment and remit of the wider inquiry, and I would like to endorse Anasawa's points on the five principles of this inquiry. We know that we face a crisis in our mental health services across Scotland. The cases that have come to light in NHS Tayside have demonstrated that in the most concerning of ways. Those who have campaigned to make today happen and for this Parliament to listen should be valued for what they have done to open that up to the rest of our country. Above all, today cannot be about shutting down those concerns, it must be about opening them up. That is what I have sought to deliver today, that is what I hope our Parliament will deliver, and I move amendment in my name. Thank you very much, Mr Briggs. I now call Alison Johnson. Four minutes please, Ms Johnson. Thank you, Presiding Officer. The most serious matters bring us to the chamber today. In Scotland, we have made new commitments to see that people are treated with dignity and respect when they need help from our social security system, and those principles apply to healthcare too. I know that our healthcare system relies on the skill, the professionalism and the compassion of doctors, nurses, pharmacists and all other healthcare professionals every day. Yet there are times when people, vulnerable people, reach out for help and do not get it. That should never happen. We talk easily, at times too easily, about parity of esteem between mental health and physical health, but we know that that is far away from reality. I, too, give my sincere condolences to David Ramsey's family. This Parliament must work together to ensure that every lesson is learned and that we begin to treat mental health with the urgency that it requires. It is right that NHS Tayside has commissioned an independent inquiry into mental health and suicide prevention services, but I join others in stressing that any inquiry must be truly independent. It must involve families from the very start to the very finish, and it must be prepared to go wherever necessary. It would not be right for me, or indeed any of us, to prejudge what the remit of the inquiry should be. Families must help to guide those decisions. However, considering the Government's amendment, I reviewed the recommendations from Health Improvement Scotland and the Mental Welfare Commission, and I was struck that there is a high turnover of locum psychiatrists in NHS Tayside. That cannot be good for continuity of treatment. It cannot be good for sharing information about support and treatment. It cannot be good for building relationships with patients, and it cannot be good for building good relationships between staff. I note, too, that there were also long waiting times to see a clinical psychologist, and I would be grateful if the minister could, in closing, discuss what steps the Government has taken to support recruitment and retention of psychiatrists and clinical psychologists in Tayside. We are all concerned that, outwith acute services, people are waiting far too long to access psychological therapies in Tayside. Only 54.7 per cent of people started treatment within 18 weeks of referral, and only 41.5 per cent of children and young people were seen by CAMHS within 18 weeks of referral. Those figures are shameful. It is clear to me that, as well as investigating specific failings at car's view, we must ensure that community services are well supported and that people have access to psychological therapies when and where they need them. Health Care Improvement Scotland's review also indicated that the crisis resolution and home treatment team have not always been able to work well with community mental health teams in different localities. That is very concerning. If there are systemic or organisational issues at work, they must be addressed now. I would like to briefly discuss the actions on suicide prevention addressed in the Government's amendment, which include creating a suicide prevention leadership group and multi-agency reviews into all deaths by suicide. Those steps are necessary. They are welcomed by Samaritans Scotland, and I thank them for their expert briefing today. Like colleagues, I agree that any inquiry must be as wide in scope as necessary and absolutely must begin and end with family involvement. Thank you very much. Thank you very much, Deputy Presiding Officer. I would like to start by echoing thanks to Anas Sarwar and the Labour Party for using their time to bring this debate to Parliament this afternoon and for the measured tone that they struck at the top of the debate, which has been picked up by other speakers thus far. That is not a debate about personalities, either in Government or on opposition benches in this chamber. It is a debate that is very much steeped in human tragedy. I want to thank David Smith's family and the other campaigners from the Lost Souls group who are here with us today for their courage in bringing this issue to Parliament and for being here to support us in our deliberation of it this afternoon. It says a lot about the state of our public policy response to suicide in this country that we need campaigns such as the Lost Souls group and that, indeed, this debate does come in opposition time. Self-harm, suicide ideation and suicide completion represent the very nexus of human crisis, the very limit of endurance that all too many lives in Dundee and in regions beyond it, to where that crisis is met all too often with silence and devoid in service provision or gaps in service provision. Last week, I want to pay tribute to Richard Leonard for his First Minister's question last week. It was one of those pin drop moments where I think every single member of this chamber couldn't help but feel huge compassion for David Ramsey and for his families that, at the age of 50, he very sadly joined the ranks of all too many young men in this country for whom suicide is the leading cause of death. I wish to associate myself and the Liberal Democrat benches both with Anas's call for those five tests to be met by that independent review into what happened in NHS Tayside. I very much welcome the cabinet secretary's positive response to that, and on that basis we can assure her of our support for the Government amendment tonight. Confidence is absolutely key, not just to the families represented here but to everybody in the Tayside area in terms of the transparency that that review will need if it is to enjoy the confidence and reassurance that it can give to the families affected by suicide in that area. The independence is critical, the public call for evidence is critical. Hearing the stories and lived experiences of those families steeped in tragedy themselves will be vital to learning and ensuring that there can be progress made in this critical area. However, what happened in Dundee and in Tayside is symptomatic of a wider problem, wider deficiencies in our public policy response to suicide as a country. Yes, suicide as a trend has been going down across this country, which we should all be justifiably proud of, but we are seeing anuptik in its resurgence again with an 8 per cent rise last year alone. I have mentioned many times the concerns that those benches have about the 18-month delay in the suicide prevention strategy and the fact that it has been met with some derision from the sector now it has been published in draft from the Samaritans who talked to the fact that it lacks resources, timescales and ambition. In fact, Sam H, who was delivering suicide prevention training in this Parliament just this very week, who said that without an understanding of what is going to be in the plan, they cannot plan for events like this or training events that they held without knowing the Government policy response to which they should underpin. I want to close by thanking again the Lost Souls Group and in particular David's family for having the courage to come to us today, to be part of this debate, because if anything can come from that abject human tragedy, then let that legacy be positive action and concerted consensus across the benches in this chamber to ensure that David leaves a lasting legacy. Thank you very much. We now move to the open debate, speeches of four minutes. I call Jenny Marra to be followed by Ashton and please, Ms Marra. Mental health is a human crisis in the city of Dundee. For years now, I have listened to families concerned about the support and treatment that their loved ones received. The times I find difficult to find words for are the parents who come to me having lost their children, asking why they had been turned away from car's view, asking why their sons had not been admitted, asking why they could not make contact with any services that weekend. Words seem futile as grief overwhelms the room. There is no doubt in my mind that we have a particular problem with the services in car's view. That was confirmed in no uncertain terms when I visited the car's view centre in September 2016 after calling publicly for a full review of the car's view unit. The presentation that I received was possibly one of the most defensive accounts of public services that I have ever heard. After meetings with the then chairman of NHS Tayside raising public concerns about mental health, I asked the new chair and chief executive at a meeting with them on their first day of work, 9 April this year, to please prioritise two issues for our community, mental health provision and deaths from drugs. Like the cabinet secretary and our health spokesperson Anas Sarwar, I am therefore relieved that new management has undertaken to review car's view and mental health services at last. I am also heartened that the Government amendment today agrees with Labour's call that a public inquiry is appropriate if we do not seem to be getting the answers that we need. We will hold them to that if necessary. I have raised those issues time and time again with NHS Tayside, and if I feel powerless, I can only imagine how powerless the families feel and how the lack of answers or redress compounds their loss and grief. I am grateful to Richard Leonard for elevating the call to the level where it is heard and answered. Services are wider and should be wider than car's view. NHS Tayside's recent mental health review resulted in the closure of the Mulberry unit in Angus and, consequently, further pressure on car's view. The reasons that MSPs were given at the time of the closure of the Mulberry unit was that there were not sufficient numbers of psychiatrists to staff the unit safely. No politician can turn their face to this advice, but the reason we got to this place, I believe, is poor workforce planning by the cabinet secretary's team. We have a growing crisis but declining capacity and services ever further from communities and people. Increasing problems with mental health is not unique to Scotland. Other post-industrial countries report the same. That is why I believe that, as well as conducting a full review of health services that are available to support people, the Government has a moral duty to look closely at prevention. Following a meeting with the Lost Souls parents group in Dundee a couple of years back, I met the head of mental health at NHS Tayside and her team at Murray Royal. After discussing the services that the families had received, I asked how we could prevent escalating problems and crisis. Resilience in children was the answer. I believe that we have a duty to start looking at this seriously. Early intervention in mental health is so poor in Dundee. Only 40 per cent of children on the CAMHS waiting lists in NHS Tayside are being seen within 18 weeks. Sam H has recently commissioned a survey to find out how many children are being turned away from CAMHS after being referred by their GP. I have raised the issue of declining numbers of educational psychologists in this chamber on a number of occasions. I believe that changes that the Government has made to the path and the cost of training is depleting this essential workforce further. I welcome the review and the commitment by the Government to look again if we do not get the answers that we need, but this is not job done. There is a huge and escalating problem with mental health from childhood, and we need to think about ways of tackling this as early as possible. Suicide prevention is such a serious subject that I am glad that we have chamber time today to discuss it. I think that there are a number of things in the labour motion that I agree with, namely that, if people are having trouble accessing services, that does need to be addressed, and that people should never be afraid to call out failings in service and then try to get them fixed. In any sphere, be it something like international development, be it a large corporation or a health board, all those areas demand continuous learning in order to improve. We all need to be able to learn from a variety of situations in order to move forward, and an important part of any system is constructive challenge. If people do have the courage to come forward, they need to be listened to, and then the feedback that they give needs to be acted upon. I welcome the fact that the new NHS Tayside chairman, John Brown, has commissioned an independent inquiry into the mental health services that are delivered, both at Carsview and now also the entire region. This inquiry will speak to the families who have experienced of the centre and also review the recommendations that have already been set out in reports by Healthcare Improvement Scotland and the Mental Welfare Commission. If it is found that things need to change, then that change should be undertaken as a priority. Continuous improvement is what we should all be striving for. I was encouraged to see that the Government has been consulting on a suicide prevention action plan with the goal of producing an ambitious strategy, informed by the views of families with experience of suicide and the front-line services that work in that area. The consultation that I am informed has received 280 responses, and I look forward to seeing the consultation responses feed into the finalised action plan. Part of the plan is the development of a world-leading suicide prevention plan for employers. I think that that is ambitious, but I also think that it should be achievable. I know that here in Parliament they have just run a training session for staff on the subject of mental health and suicide prevention. My own staff from my office attended, and I think that that type of thing is useful in itself, but I think that it also has a potentially more important effect than that. That it sends out a wider message, that this is something that we care about, that there shouldn't be stigma around talking about either mental health or suicide, and that support is available for those needing it, if required. The new action plan is key, but more than that, we need to make sure that the implementation does justice to the plan. That is why the Government is setting up the forum of stakeholders to track the real progress on real actions in the real world, is both welcome and also provides a vital oversight. I don't think that any Government can ever get everything right, but I do believe that the Scottish Government is committed to doing more and to doing better on both mental health and suicide prevention. For me, that was particularly signalled, clearly, by the appointment by the First Minister of Scotland's first mental health minister. If those who have experience of this can inform the Government's approach, I have every faith that we will begin to make improvements, and I'll conclude today with a quote from letters of gratitude from this year.  I call Liz Smith to be followed by Claire Hawke. Thank you, Deputy Presiding Officer. I think that the tone of the preceding six speeches speaks volumes about why this debate is taking place and the importance of it. I would like to pay tribute to all the previous speakers. Let me start by adding my welcome to the very genuine commitment to an independent review and agree with the comments made by others that it is vitally important that we take with us the families of the patients who feel that they have had a raw deal or who feel that they have been so badly let down and not listened to. Because if we don't do that, Deputy Presiding Officer, we will not make any progress at all. The Mental Health and Welfare Commission has stated that it is every patient's right, indeed every family's right, to expect the highest standards of care when someone is in a very vulnerable situation—exactly the same expectation that should be evident in any part of the health service. It is in that context that I come to this debate from my own constituency work across three parliamentary sessions in this place. In several cases I am sorry to say when it has been very clear that patients did not receive the highest standard of care. Although I cannot speak about those individuals concerned because of the need to maintain confidentiality, I want to highlight three areas where I think that reform is needed and which, as it happens, tie in with the findings of the Mental Health and Welfare Commission's report. As Alison Johnson and Jenny Marra have rightly said, there are staffing issues. We know across Tayside just now that there are significant pressures on staff with the result that there are currently 21 locums in place, with the additional expense that that brings, but more importantly with the difficulties of patients not having a consistent link to member of staff who can deal with their specific problems. That ends up in them having to retell their story several times over, something that obviously adds to the stress of the situation. Related to this is the issue about care plans and the lack of consistency. The Mental Health Welfare Commission reported that there was very variable information within patients' care plans. While some were described as excellent, one-poke patient told them about having to fill in forms themselves with no assistance from any member's staff because they were too busy doing other things. That was certainly the experience of two of my constituents, whose care was very patchy in terms of its quality, so I think that the recommendations made by the commission in this respect are extremely important and will hopefully provide some essential support to patients and their families at their most vulnerable time. Like so many other professions, mental health care can bring with it a great deal of time-consuming paperwork that often prevents the carers from spending time with their patients, and that is just another reason to hasten the improvements in the electronic record system. I think that we all understand the desire to help patients at home and in the community as far as possible, but for the 6 per cent who require hospital treatment, we need to ensure that there are better standards of care across the board. However, we also need to understand that there is much more work to do to improve the situation when there are crisis administrations. I hope that the independent commission, brought into review matters, will ensure that there is a greater liaison with the police, who are almost always in the front line of such cases. The recent Samaritan's report, which says that suicide is not being treated seriously, could hardly be a more stark warning for us all. May I finish on one final issue? That is the reference to the conflicting requests from health and social work, and it comes to mental health management. Again, it is relevant to the problems within the structures of IGBs, which I spoke about in last week's debate about NHS Tayside. It was an issue that was discussed yesterday between MSPs and John Brown and Malcolm Wright, and I hope that we can address that matter soon. Good quality mental health care depends on clear lines of responsibility and accountability for staff and for patients and families who know exactly what those are. There is no time to waste at all, and I support the motion, the other amendments and the amendment in the name of Miles Briggs. I call Claire Hawke to be followed by Lewis Macdonald. Thank you, Presiding Officer. I start today's speech by referring members to my entry in the register of interests in that I am a registered mental health nurse and currently holding an honorary contract with NHS Greater Glasgow and Clyde. There can be no denying that the death of David Ramsey and others in NHS Tayside is anything but a tragedy. I will repeat the phrase that has been said today already, however it does not diminish its veracity. One suicide is one too many. I wish to extend my own heartfelt sympathies to Mr Ramsey's family and friends. To the lost souls of Dundee campaigners, I pay tribute to their tenacity in ensuring that their campaign is rightly being debated in the Scottish Parliament here today. As a mental health nurse of over 30 years, I know all too well of the effects someone's suicide can have in their loved ones. Therefore, I sincerely hope that the families present here today are able to find some comfort in the months ahead. I have raised the issue of suicide and, in particular, male suicide on a number of occasions in this Parliament. In the same year as Mr Ramsey's passing, another 727 suicides were registered in Scotland, 71 per cent of which were men. Although the suicide rate in Scotland has fallen by 17 per cent over the last decade and the five-year rolling average shows a downward trend, that is little comfort to those whose family, member or friend has already passed away. However, we owe it to them and the others to continue working to ensure that the number of people taking their lives continues to follow. Presiding Officer, suicide is not unique to Tayside. Sadly, 44 people took their lives in South Lanarkshire in 2016, a number of whom will have been from my constituency. However, if his NHS Tayside has been lighting down its patients, then it is correct that it is closely looked into. I therefore welcome the announcement that an independent inquiry into mental health and suicide prevention services across the region has been launched. It is testament to the decisiveness of the new leadership that was installed by the Cabinet Secretary and I am sure that the health board will move in the correct direction under the leadership of John Brown and Malcolm Wright. Within the investigation, the delivery of services at centres such as Carlsview will be closely examined, and should the report highlight areas for improvement or raise issues where lessons can be learned, then NHS Tayside must make the necessary changes immediately. I sincerely hope for the families who are concerned about mental health and suicide prevention services in NHS Tayside that they will not be let down by this process. However, if they are, they can be reassured that the Scottish Government will convert it into an inquiry under the auspices of the inquiries act. The families will be anxiously awaiting the conclusions of the NHS Tayside's investigation, and I hope that time is given to ensure that all relevant details are thoroughly scrutinised. I was heartened by the Cabinet Secretary's comments today on Good Morning Scotland, that the families are to be at the heart of this inquiry, being involved with its terms of reference and that they should have confidence in its chair. Presiding Officer, while the investigation is under way, I feel that it is worthwhile to point out that Scottish Government and health agencies have already been looking into concerns regarding mental health services in NHS Tayside. The Mental Welfare Commission for Scotland carried out an unannounced inspection of car's view in November and made a number of recommendations regarding their care planning, the availability of responsible medical officers and, whilst health improvements Scotland carried out a similar examination in December 2017. Of course, more widely, the Scottish Government has published a 10-year mental health strategy and the new suicide prevention action plan will be published soon. I am incredibly proud that, as the mental health and health Governments, politicians, health services and the public are beginning to see mental health as being equal to that of physical health. However, we are not there yet, and we must all continue to work together until tragic deaths like that of Mr Ramsey are a thing of the past. Colle Lewis MacDonald, to be followed by Bill Bowman. Everyone, I think, has acknowledged that we are having this debate today because of failures in the provision of mental health services to the people of Dundee, Angus and Perthon Cynros. Those failures are to be the subject of the independent inquiry that was announced last week, and it is essential that the terms and references of the inquiry are broadly drawn and that those affected by those failures have a say in the process from the outset. The five principles that are laid out by Anna Sarwar today and the cabinet secretary's positive response to them are very welcome. The last review of mental health services in Tayside led to decisions to cease to provide general adult psychiatry in either Perth or Angus, and those decisions and the process of reaching them must be looked at again as part of this inquiry. The board's view then was that their existing model for delivery of acute admission in patient services was not sustainable and could pose a significant clinical risk to patients and staff. The answer, as Jenny Marra said, was to close the Mulberry unit at Stracathro and to deliver those services only at the Carthage Centre in Dundee. We need to see reconsideration of whether that was the right answer and, if not, what else must be done to deliver safe and sustainable services. We have already heard some of the concerns around Carthage, so I am glad that the remit of the inquiry will now go beyond that unit to look at mental health services across Tayside as a whole. Patients from neighbouring board areas may also be affected because some specialised mental health services are planned and delivered on a regional basis. Other boards are also involved, of course, with the chair of NHS Greater Glasgow and Clyde and the chief executive of NHS Grampian taking on equivalent roles for the time being in NHS Tayside. While John Brown and Malcolm Wright certainly bring fresh pairs of eyes of their own to the problems in front of them, they also acknowledge that, for the planned inquiry to be credible, the appointment of a genuinely independent chair and advisers will be crucial. I welcome their plans to engage with the Mental Welfare Commission and others in seeking to identify the best people. I look forward to hearing who will lead that inquiry, I hope, in the course of this week. The inquiry must also provide a platform for those who are most directly affected to have their voices heard. I join the tributes to those people who have attended this evening. I know that patients and families do not just want to hear the answers, they want and need to be part of framing the questions. One constituent contacted me yesterday evening and put it succinctly. I would like to know, he said, if I and the rest of the general public will be given the opportunity to provide evidence of the failures that I have experienced through supporting friends who have been admitted, and if past and existing patients will also be given the opportunity to provide evidence. We know, since Grenfell, that the public demand to be part of the process, not simply to be its victims or its beneficiaries, and that principle must apply here, too. I hope that one result of the inquiry will be to put in place clear clinical leadership and effective management of mental health services. Achieving that clarity can help to deliver the best possible mental health services in Tayside, including in particular the best hope of reducing the incidence of suicide. The Health and Sport Committee has agreed to take evidence on the Government's suicide prevention strategy before the summer recess. The evidence that we take can influence the final form of that strategy if ministers are open to that evidence having that effect. While the timescale is necessarily different, the independent inquiry in Tayside also has the potential to influence national policy on suicide prevention. If lessons can be learned from the experiences of affected families in recent months, perhaps some other families will be spared that pain. That is why those affected must be front and centre of this inquiry. I look forward to NHS Tayside and ministers laying out exactly how that will be achieved. The last of the open debate contributions is from Bill Bowman. Thank you, Deputy Presiding Officer. I suspect that my remarks will duplicate what others have said, but the subject today is such that I do not think that any apologies are necessary for that. Suicide is preventable. Last week, we heard Richard Leonard highlight the case of David Ramsey, who took his own life after being turned away from the Carsview Centre, a tragic case that speaks to a wider problem in Dundee and Tayside. The campaign group Lost Souls of Dundee has identified at least 10 such cases that could have been prevented if better care had been available at Carsview. Just one week on from Mr Ramsey's case being highlighted, we now have an NHS Tayside inquiry moving forward for which the health secretary has signalled her support. I am pleased to see that swift response and I welcome any move to provide answers and prevent further deaths. Those answers must now be sought and lessons learned, but I note the words of Gillian Murray, who is part of the Lost Souls group and David Ramsey's niece, concerning the inquiry. She said, I am pleased at this announcement, but it is not the end. This is just the first step. I couldn't agree more because research shows that 70 per cent of people who take their own lives do so within a year of having contact with healthcare services. Thus, the proposal to look only at Carsview alone was never sufficient to provide the answers needed. We must ensure that the inquiry covers all mental health needs, resources and provision at NHS Tayside. I was reminded of the importance of that yesterday when I was contacted by a constituent outwith Tayside, who raised some serious concerns about mental health care at NHS Grampian. It was a timely reminder that failings in mental health care are not confined to a particular treatment facility or, for that matter, a particular health board. For NHS Tayside, in particular, a wind-ranging inquiry is vital because it can offer more reassurance to patients and their families that the issue is being taken seriously and let us be clear how serious an issue this is.  In Dundee alone, we have heard the rise of 61 per cent in the recent suicide rate. Almost unbelievably, almost two out of every three Scots have some experience of suicide. A worrying statement that I am sure the ministers opposite will pay heed to. It also reflects a concern that, locally in Tayside, there is a lack of focus on improving mental health outcomes. For example, as I think we have heard, less than half of Tayside children waiting for mental health treatment are seen within 18 weeks. The target is 90 per cent to be seen within this timeframe, whereas NHS's performance at about 42 per cent was the second worst in Scotland. The list goes on. Staff facing difficulties in accessing training, a lack of permanent psychiatrists with patients seeing up to four different consultants during their time in hospital, waiting times for clinical psychologists exceeding the 18-week target and, as we also heard, even one patient being given a blank recovery care plan form to fill in themselves. Treatment is crucial, of course, but we must equally be prepared to tackle the underlying reasons why so many people take their own lives. For example, those living in the most deprived areas are more than three times as likely to die by suicide than those in the least deprived areas. That is a particular challenge in Dundee, which is among the highest levels of deprivation in Scotland. We must stop simply offering apologies and platitudes and getting work to make sure that no more individuals and family suffer. Letters never forget, talk may be cheap, but lives must be held dear. We now move to the closing speeches and I call Annie Wells for around four minutes please, Ms Wells. I too wish to echo Liz Smith's comments regarding the tone of the debate today. I think that it has been a debate where we have been able to be open and frank and honest and also let people know that we are taking mental health and suicide seriously within this Parliament. I wish to pay tribute to the families here in the public gallery and also to the hardworking staff who work tirelessly with difficult circumstances. With mental health services having fallen seriously short of standard expected in NHS Tayside, I welcomed the comments from the minister stating that the investigation will cover the whole of Tayside and all facilities. As we saw with the extremely tragic case of David Ramsey, it is families and friends that live forever with the consequences of the services that field their loved ones. NHS Tayside has come under the media spotlight for very good reason. As Bill Bowman spoke about as an MSP for the area, less than half of Tayside's children who are waiting for mental health treatment were seen within 18 weeks. The NHS Tayside performance of 41.5 per cent was the second worst in Scotland. As Annas Sarwar and others have stated, suicides in Dundee have risen 61 per cent in a year. Along with others in the chamber today, I, too, would like to pay tribute to the bravery and work of lost souls of Dundee. They have identified that at least 10 suicides could have been prevented, had better help been available at Carsview. Four minutes is of course very short for such an important topic, but I want to round off the debate for the Scottish Conservatives by looking at how NHS Tayside sits within the broader context of mental health services, struggling to meet growing demand. Across Scotland we know that they are being pushed to their limit with more than a quarter of adults waiting too long for psychological therapy and more than a quarter of children are waiting too long for mental health treatment. With the publication of the Scottish Government's mental health strategy last year, we have not seen the step change as promised. Mental health charities have publicly stated that it lacks the ambition and investment that is needed, and we have seen with NHS Tayside that the current model is not working. When it comes to suicide, a topic that is incredibly sensitive, I am concerned that we are not seeing the ambition that is so desperately needed. 728 people died from suicide in Scotland in 2016, a rise of 8 per cent from the previous year, and despite that, we have not had a suicide action plan in place since 2016. The draft plan, which was published in March, was met with open disappointment from Samaritan Scotland, who had engaged with the Scottish Government prior to its publication, citing its scarce detail on targets, timeframes and what resources will be allocated. There was also no information on how those disproportionately affected by suicide will be supported, for example men, those in middle age, those in deprivation and those living alone. With a worrying lack of detail so far, I hope that the final strategy that will be published in the summer will clearly outline how suicide will be tackled. To finish today, I would like to echo comments from my colleagues who are a wider inquiry into mental health services on NHS Tayside. With mental health awareness week beginning on Monday, it is time that strong words on the subject are backed up by urgent action. If we do not act now, then mental health will continue to lag behind physical health when it comes to investment and resources with potentially far-reaching consequences. The problems in NHS Tayside have vividly highlighted that we are not disciplined in tackling mental health issues, then we badly let the families down and friends of those with mental health problems. We would be failing in our duty across this chamber if we did not do everything in our power to improve the situation for some of the most vulnerable in our society. Calshona Robison, around four minutes please, cabinet secretary. Thank you, Deputy Presiding Officer. Can I join with others in welcoming the families to the gallery and thanking them for getting us to this point to NHS Tayside? The new leadership team has listened and has come in with a fresh pair of eyes. It has listened and heard the calls from the families and has responded appropriately in the announcement that the chair made on Friday. As others have pointed out, the inquiry and the nature of the inquiry would have been wrong to have focused that purely on Carr's view. It is quite right and proper that the inquiry looks across the whole of Tayside. Others have also said that any lessons for improvements of mental health services in Tayside may well have application elsewhere in Scotland. That again is an important point. As I hope that I gave in my intervention in Annas Sarwar's opening speech, it was that right from the start that what is important here is that the independent inquiry is just that independent. However, most important in all of this is that it has the confidence of the families and that they should be involved right from the start in the reference and that the chair, who will have a very challenging job to take this important work forward, has the right skillset but can also inspire the confidence of the families. All those things are very important. Let me reassure members that I had another further discussion with the chair of NHS Tayside John Brown last night. He absolutely understands the importance of every single one of those issues. He will be putting a lot of thought into the process. Families may wish to be involved in different ways, but they should all have the opportunity to be involved and should have the opportunity to be heard. Annas Sarwar I thank the cabinet secretary for taking that intervention. Can she confirm in appointing that chair that it will not be someone who is an employee of NHS Tayside and it will not be an employee of NHS Scotland in terms of the organisation? It will be a truly independent chair of both the health board and the Scottish Government. Shona Robison That is important. The chair and I have already discussed the importance of that. That they have to have not just the right skillset but need to be independent beyond the health service and the Scottish Government. Importantly, they have to be able to inspire confidence in the families and, indeed, in the public at large, that this will be an inquiry that will make changes and will make positive changes. I want to come back to that in a second. Miles Briggs made an important point. In all of that, we have to recognise the efforts of the staff involved and that, for many people, they have had good treatment in NHS Tayside from mental health services. It is important to put that on the record. Where I would also agree with Miles Briggs is his comment about personal attacks on Gillian Murray. I agree with Miles Briggs that families need to be able to speak out without criticism, whether that is on social media or anywhere else. I certainly made my views very clear about that. I also think that Alison Johnstone had an important point to make about recruitment and retention and the high turnover of locum psychiatrists. That will be a difficult time for Tayside, particularly in trying to attract new staff to mental health services in the region. I hope that the independent inquiry in itself should be seen as a force for good in order to help to bring new staff to NHS Tayside. We need to see it as a positive thing that will help. You have to be very quick. Thank you, cabinet secretary, for taking this intervention. It has already been raised about the mulberry unit. Will the Scottish Government look with NHS Tayside whether it would be appropriate to reopen that unit for patients in Angus? I do not think that it would be appropriate to begin here this afternoon to start to establish the remit of the independent inquiry. We have all agreed that the heart of that has to be the independent chair in consultation with others and with the families. I do not think that we should try to establish the remit in this chamber today. I hope that, out of this debate, the most important thing is that the families leave here today and those families that are not here are back home. They leave with a confidence that we are all agreed that we must use this independent inquiry to, first of all, seek answers to the very pertinent and serious questions that many families have, but, importantly, the changes that come out of this inquiry will make NHS Tayside's mental health service some of the best, not just in Scotland but beyond the shores. If that is what comes out of this independent inquiry, I think that the collective efforts of everyone in this chamber will have been worthwhile. I call Mary Fee to wind up this debate for around five minutes, please. Thank you, Deputy Presiding Officer. In closing this debate today, I begin by thanking the families and the campaigners that have been at the heart of this debate. Their dedication to tackle and highlight the problems within NHS Tayside will help to save lives. Can I also thank speakers from across the chamber for their thoughtful and considered contributions in what I think has been a very powerful debate? The Government amendment today is an indication that they have listened to the campaigners. The stigma of mental health, the lack of support and the lack of understanding for those suffering, poor mental health, still, unfortunately, pervades our society. We cannot allow that to go on. We must change that. Many of the points that I will raise in my closing remarks have been raised already, but they are worthy of repeating. A number of colleagues have praised the Lost Souls group in Dundee. My colleague Lewis MacDonald said that patients and families do not just want to hear the answers, they want and need to be part of framing the questions after he was contacted by a constituent. Jenny Marra spoke of the crisis in mental health and drug-related deaths in Dundee. Along with Richard Leonard and Anas Sarwar, I welcomed the review that was announced last week into the Carsview Centre. However, we knew then that that would not go far enough, and a wider, fuller public inquiry into NHS Tayside was required. I am glad to see in the Government amendment a commitment for an inquiry, but that inquiry must be open, it must be accountable and it must fully involve all of the families. Public services are at the core of what Government provides, and those services should always be accessible when required and transparent and accountable when things go wrong. It should not take a question posed to the First Minister for the Government and NHS Tayside to sit up and listen. The families, like those in the gallery today, have been demanding answers for far too long. The death of David Ramsey is tragic and not only because of the missed opportunities to prevent it. His niece and father should not have to travel to Parliament to be listened to. Although the focus for today's debate is on NHS Tayside, there are problems across Scotland with mental health services, particularly for children and young people. We know that waiting times are on the increase for an initial appointment for child and adolescent mental health services, and more than a quarter of children are not being seen within the 18-week waiting time target. Recent statistics show that 10 out of 14 health boards are not meeting CAMHS targets. I hope that the Audit Scotland review into CAMHS, due to being published in the autumn of this year, will show that improvements are being made. If not, action must be taken immediately to support our young people. The tragic loss of Lee Walsh has brought about a campaign for better mental health services in Tayside. Lee died of suicide last year on the website, not in vain for Lee, tells us that Lee suffered mental health problems on and off for over nine years, being prescribed various alternative medications but never actually receiving a particular diagnosis. Can I close by focusing on the Government amendment, which commits to a full inquiry, and the comments made by my colleague Anas Sarwar in his opening remarks that an independent inquiry must have an independent chair. It must include the families in agreeing the terms of reference, and it must ensure that families are part of that process. It must be open, transparent and inclusive. By taking those steps, we will be a starting point in rebuilding the trust and confidence in mental health services. However, my final thanks and admiration must go to the families. Parliament has listened to you, and I am confident that we stand united in a desire to achieve justice for you all. That concludes the debate on the NHS Tayside public inquiry.